@fastybird/smart-panel-backend 1.1.0-alpha.5 → 1.1.0-alpha.50

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 (538) hide show
  1. package/dist/app.module.js +9 -1
  2. package/dist/app.module.js.map +1 -1
  3. package/dist/common/utils/cancellable-exec.utils.d.ts +5 -0
  4. package/dist/common/utils/cancellable-exec.utils.js +34 -0
  5. package/dist/common/utils/cancellable-exec.utils.js.map +1 -0
  6. package/dist/common/utils/remote-access-observation.utils.d.ts +11 -0
  7. package/dist/common/utils/remote-access-observation.utils.js +89 -0
  8. package/dist/common/utils/remote-access-observation.utils.js.map +1 -0
  9. package/dist/dataSource.js +1 -0
  10. package/dist/dataSource.js.map +1 -1
  11. package/dist/migrations/1000000000026-AddHardwareInputCategories.d.ts +7 -0
  12. package/dist/migrations/1000000000026-AddHardwareInputCategories.js +364 -0
  13. package/dist/migrations/1000000000026-AddHardwareInputCategories.js.map +1 -0
  14. package/dist/modules/auth/auth.module.js +4 -0
  15. package/dist/modules/auth/auth.module.js.map +1 -1
  16. package/dist/modules/auth/guards/auth.guard.js +8 -21
  17. package/dist/modules/auth/guards/auth.guard.js.map +1 -1
  18. package/dist/modules/auth/services/token-metadata.service.d.ts +42 -0
  19. package/dist/modules/auth/services/token-metadata.service.js +202 -0
  20. package/dist/modules/auth/services/token-metadata.service.js.map +1 -0
  21. package/dist/modules/auth/services/token-usage.service.d.ts +22 -0
  22. package/dist/modules/auth/services/token-usage.service.js +93 -0
  23. package/dist/modules/auth/services/token-usage.service.js.map +1 -0
  24. package/dist/modules/auth/services/tokens.service.d.ts +10 -3
  25. package/dist/modules/auth/services/tokens.service.js +26 -10
  26. package/dist/modules/auth/services/tokens.service.js.map +1 -1
  27. package/dist/modules/devices/controllers/channels.controller.d.ts +5 -1
  28. package/dist/modules/devices/controllers/channels.controller.js +34 -2
  29. package/dist/modules/devices/controllers/channels.controller.js.map +1 -1
  30. package/dist/modules/devices/controllers/channels.properties.controller.js +21 -4
  31. package/dist/modules/devices/controllers/channels.properties.controller.js.map +1 -1
  32. package/dist/modules/devices/controllers/devices.channels.controller.d.ts +5 -1
  33. package/dist/modules/devices/controllers/devices.channels.controller.js +38 -2
  34. package/dist/modules/devices/controllers/devices.channels.controller.js.map +1 -1
  35. package/dist/modules/devices/controllers/devices.channels.properties.controller.js +21 -4
  36. package/dist/modules/devices/controllers/devices.channels.properties.controller.js.map +1 -1
  37. package/dist/modules/devices/devices.constants.d.ts +6 -0
  38. package/dist/modules/devices/devices.constants.js +6 -0
  39. package/dist/modules/devices/devices.constants.js.map +1 -1
  40. package/dist/modules/devices/devices.module.js +27 -0
  41. package/dist/modules/devices/devices.module.js.map +1 -1
  42. package/dist/modules/devices/devices.openapi.d.ts +3 -1
  43. package/dist/modules/devices/devices.openapi.js +7 -0
  44. package/dist/modules/devices/devices.openapi.js.map +1 -1
  45. package/dist/modules/devices/dto/channel-input-occurrence.dto.d.ts +10 -0
  46. package/dist/modules/devices/dto/channel-input-occurrence.dto.js +99 -0
  47. package/dist/modules/devices/dto/channel-input-occurrence.dto.js.map +1 -0
  48. package/dist/modules/devices/dto/property-command.dto.js +2 -8
  49. package/dist/modules/devices/dto/property-command.dto.js.map +1 -1
  50. package/dist/modules/devices/models/channel-input-capabilities.model.d.ts +20 -0
  51. package/dist/modules/devices/models/channel-input-capabilities.model.js +111 -0
  52. package/dist/modules/devices/models/channel-input-capabilities.model.js.map +1 -0
  53. package/dist/modules/devices/models/channel-input-occurrence.model.d.ts +22 -0
  54. package/dist/modules/devices/models/channel-input-occurrence.model.js +154 -0
  55. package/dist/modules/devices/models/channel-input-occurrence.model.js.map +1 -0
  56. package/dist/modules/devices/services/channel-input-deduplication.service.d.ts +17 -0
  57. package/dist/modules/devices/services/channel-input-deduplication.service.js +88 -0
  58. package/dist/modules/devices/services/channel-input-deduplication.service.js.map +1 -0
  59. package/dist/modules/devices/services/channel-input-occurrences.service.d.ts +21 -0
  60. package/dist/modules/devices/services/channel-input-occurrences.service.js +163 -0
  61. package/dist/modules/devices/services/channel-input-occurrences.service.js.map +1 -0
  62. package/dist/modules/devices/services/channels.properties.service.d.ts +32 -3
  63. package/dist/modules/devices/services/channels.properties.service.js +360 -51
  64. package/dist/modules/devices/services/channels.properties.service.js.map +1 -1
  65. package/dist/modules/devices/services/channels.service.d.ts +1 -0
  66. package/dist/modules/devices/services/channels.service.js +52 -38
  67. package/dist/modules/devices/services/channels.service.js.map +1 -1
  68. package/dist/modules/devices/services/command-latency-trace-collector.service.d.ts +101 -0
  69. package/dist/modules/devices/services/command-latency-trace-collector.service.js +451 -0
  70. package/dist/modules/devices/services/command-latency-trace-collector.service.js.map +1 -0
  71. package/dist/modules/devices/services/device-command-graph.service.d.ts +18 -0
  72. package/dist/modules/devices/services/device-command-graph.service.js +92 -0
  73. package/dist/modules/devices/services/device-command-graph.service.js.map +1 -0
  74. package/dist/modules/devices/services/device-structure-lock.service.d.ts +10 -2
  75. package/dist/modules/devices/services/device-structure-lock.service.js +86 -7
  76. package/dist/modules/devices/services/device-structure-lock.service.js.map +1 -1
  77. package/dist/modules/devices/services/devices.service.d.ts +2 -0
  78. package/dist/modules/devices/services/devices.service.js +78 -64
  79. package/dist/modules/devices/services/devices.service.js.map +1 -1
  80. package/dist/modules/devices/services/module-reset.service.d.ts +3 -1
  81. package/dist/modules/devices/services/module-reset.service.js +21 -16
  82. package/dist/modules/devices/services/module-reset.service.js.map +1 -1
  83. package/dist/modules/devices/services/platform.registry.service.d.ts +2 -2
  84. package/dist/modules/devices/services/platform.registry.service.js.map +1 -1
  85. package/dist/modules/devices/services/property-command-dispatch.service.d.ts +47 -0
  86. package/dist/modules/devices/services/property-command-dispatch.service.js +231 -0
  87. package/dist/modules/devices/services/property-command-dispatch.service.js.map +1 -0
  88. package/dist/modules/devices/services/property-command-window.service.d.ts +71 -0
  89. package/dist/modules/devices/services/property-command-window.service.js +206 -0
  90. package/dist/modules/devices/services/property-command-window.service.js.map +1 -0
  91. package/dist/modules/devices/services/property-command.service.d.ts +26 -7
  92. package/dist/modules/devices/services/property-command.service.js +95 -28
  93. package/dist/modules/devices/services/property-command.service.js.map +1 -1
  94. package/dist/modules/devices/services/property-metadata.service.d.ts +38 -0
  95. package/dist/modules/devices/services/property-metadata.service.js +210 -0
  96. package/dist/modules/devices/services/property-metadata.service.js.map +1 -0
  97. package/dist/modules/devices/services/property-state-coordinator.service.d.ts +4 -0
  98. package/dist/modules/devices/services/property-state-coordinator.service.js +35 -0
  99. package/dist/modules/devices/services/property-state-coordinator.service.js.map +1 -0
  100. package/dist/modules/devices/services/property-value-lock.service.d.ts +4 -1
  101. package/dist/modules/devices/services/property-value-lock.service.js +16 -2
  102. package/dist/modules/devices/services/property-value-lock.service.js.map +1 -1
  103. package/dist/modules/devices/services/property-value.service.d.ts +3 -0
  104. package/dist/modules/devices/services/property-value.service.js +29 -5
  105. package/dist/modules/devices/services/property-value.service.js.map +1 -1
  106. package/dist/modules/devices/utils/device-graph-query.utils.d.ts +3 -0
  107. package/dist/modules/devices/utils/device-graph-query.utils.js +23 -0
  108. package/dist/modules/devices/utils/device-graph-query.utils.js.map +1 -0
  109. package/dist/modules/devices/utils/schema.utils.js +1 -1
  110. package/dist/modules/devices/utils/schema.utils.js.map +1 -1
  111. package/dist/modules/devices/validators/channel-exists-constraint.validator.d.ts +1 -3
  112. package/dist/modules/devices/validators/channel-exists-constraint.validator.js +3 -14
  113. package/dist/modules/devices/validators/channel-exists-constraint.validator.js.map +1 -1
  114. package/dist/modules/devices/validators/channel-property-exists-constraint.validator.d.ts +1 -3
  115. package/dist/modules/devices/validators/channel-property-exists-constraint.validator.js +3 -14
  116. package/dist/modules/devices/validators/channel-property-exists-constraint.validator.js.map +1 -1
  117. package/dist/modules/devices/validators/device-exists-constraint.validator.js +1 -2
  118. package/dist/modules/devices/validators/device-exists-constraint.validator.js.map +1 -1
  119. package/dist/modules/devices/validators/property-command-target-constraint.validator.d.ts +9 -0
  120. package/dist/modules/devices/validators/property-command-target-constraint.validator.js +58 -0
  121. package/dist/modules/devices/validators/property-command-target-constraint.validator.js.map +1 -0
  122. package/dist/modules/mdns/services/mdns.service.js +3 -1
  123. package/dist/modules/mdns/services/mdns.service.js.map +1 -1
  124. package/dist/modules/platform/platforms/abstract.platform.d.ts +2 -1
  125. package/dist/modules/platform/platforms/abstract.platform.js +2 -1
  126. package/dist/modules/platform/platforms/abstract.platform.js.map +1 -1
  127. package/dist/modules/platform/platforms/raspberry.platform.js +5 -10
  128. package/dist/modules/platform/platforms/raspberry.platform.js.map +1 -1
  129. package/dist/modules/platform/utils/linux-network-interface.utils.d.ts +3 -0
  130. package/dist/modules/platform/utils/linux-network-interface.utils.js +48 -0
  131. package/dist/modules/platform/utils/linux-network-interface.utils.js.map +1 -0
  132. package/dist/modules/remote-access/controllers/remote-access.controller.js +11 -6
  133. package/dist/modules/remote-access/controllers/remote-access.controller.js.map +1 -1
  134. package/dist/modules/remote-access/models/provider.model.d.ts +3 -0
  135. package/dist/modules/remote-access/models/provider.model.js +23 -0
  136. package/dist/modules/remote-access/models/provider.model.js.map +1 -1
  137. package/dist/modules/remote-access/models/status.model.d.ts +2 -0
  138. package/dist/modules/remote-access/models/status.model.js +18 -1
  139. package/dist/modules/remote-access/models/status.model.js.map +1 -1
  140. package/dist/modules/remote-access/models/urls.model.d.ts +2 -0
  141. package/dist/modules/remote-access/models/urls.model.js +17 -0
  142. package/dist/modules/remote-access/models/urls.model.js.map +1 -1
  143. package/dist/modules/remote-access/platforms/remote-access-provider.platform.d.ts +18 -1
  144. package/dist/modules/remote-access/remote-access.constants.d.ts +2 -1
  145. package/dist/modules/remote-access/remote-access.constants.js +2 -1
  146. package/dist/modules/remote-access/remote-access.constants.js.map +1 -1
  147. package/dist/modules/remote-access/services/remote-access-proxy-contribution.service.d.ts +1 -0
  148. package/dist/modules/remote-access/services/remote-access-proxy-contribution.service.js +4 -1
  149. package/dist/modules/remote-access/services/remote-access-proxy-contribution.service.js.map +1 -1
  150. package/dist/modules/remote-access/services/remote-access-status.service.d.ts +40 -8
  151. package/dist/modules/remote-access/services/remote-access-status.service.js +314 -65
  152. package/dist/modules/remote-access/services/remote-access-status.service.js.map +1 -1
  153. package/dist/modules/remote-access/services/remote-access-url.service.d.ts +2 -2
  154. package/dist/modules/remote-access/services/remote-access-url.service.js +4 -2
  155. package/dist/modules/remote-access/services/remote-access-url.service.js.map +1 -1
  156. package/dist/modules/spaces/services/module-reset.service.d.ts +5 -1
  157. package/dist/modules/spaces/services/module-reset.service.js +10 -2
  158. package/dist/modules/spaces/services/module-reset.service.js.map +1 -1
  159. package/dist/modules/spaces/services/space-activity.service.d.ts +14 -0
  160. package/dist/modules/spaces/services/space-activity.service.js +56 -0
  161. package/dist/modules/spaces/services/space-activity.service.js.map +1 -0
  162. package/dist/modules/spaces/spaces.module.js +5 -0
  163. package/dist/modules/spaces/spaces.module.js.map +1 -1
  164. package/dist/modules/spaces/subscribers/space-activity.subscriber.d.ts +17 -0
  165. package/dist/modules/spaces/subscribers/space-activity.subscriber.js +89 -0
  166. package/dist/modules/spaces/subscribers/space-activity.subscriber.js.map +1 -0
  167. package/dist/modules/storage/services/storage-write-buffer.d.ts +17 -0
  168. package/dist/modules/storage/services/storage-write-buffer.js +67 -0
  169. package/dist/modules/storage/services/storage-write-buffer.js.map +1 -0
  170. package/dist/modules/storage/services/storage.service.d.ts +9 -2
  171. package/dist/modules/storage/services/storage.service.js +54 -1
  172. package/dist/modules/storage/services/storage.service.js.map +1 -1
  173. package/dist/modules/system/scripts/update-worker.sh +1168 -61
  174. package/dist/modules/system/services/privileged-worker.service.d.ts +3 -0
  175. package/dist/modules/system/services/privileged-worker.service.js +62 -27
  176. package/dist/modules/system/services/privileged-worker.service.js.map +1 -1
  177. package/dist/modules/system/services/system.service.d.ts +2 -0
  178. package/dist/modules/system/services/system.service.js +22 -1
  179. package/dist/modules/system/services/system.service.js.map +1 -1
  180. package/dist/modules/system/services/update-executor.service.d.ts +20 -2
  181. package/dist/modules/system/services/update-executor.service.js +272 -26
  182. package/dist/modules/system/services/update-executor.service.js.map +1 -1
  183. package/dist/modules/websocket/gateway/websocket.gateway.d.ts +4 -1
  184. package/dist/modules/websocket/gateway/websocket.gateway.js +29 -5
  185. package/dist/modules/websocket/gateway/websocket.gateway.js.map +1 -1
  186. package/dist/modules/websocket/services/command-acknowledgement-trace.service.d.ts +143 -0
  187. package/dist/modules/websocket/services/command-acknowledgement-trace.service.js +523 -0
  188. package/dist/modules/websocket/services/command-acknowledgement-trace.service.js.map +1 -0
  189. package/dist/modules/websocket/services/ws-auth.service.js +12 -35
  190. package/dist/modules/websocket/services/ws-auth.service.js.map +1 -1
  191. package/dist/modules/websocket/websocket.module.js +9 -1
  192. package/dist/modules/websocket/websocket.module.js.map +1 -1
  193. package/dist/plugins/devices-home-assistant/devices-home-assistant.openapi.d.ts +2 -2
  194. package/dist/plugins/devices-home-assistant/devices-home-assistant.plugin.d.ts +6 -1
  195. package/dist/plugins/devices-home-assistant/devices-home-assistant.plugin.js +16 -1
  196. package/dist/plugins/devices-home-assistant/devices-home-assistant.plugin.js.map +1 -1
  197. package/dist/plugins/devices-home-assistant/dto/mapping-preview.dto.d.ts +1 -0
  198. package/dist/plugins/devices-home-assistant/dto/mapping-preview.dto.js +11 -0
  199. package/dist/plugins/devices-home-assistant/dto/mapping-preview.dto.js.map +1 -1
  200. package/dist/plugins/devices-home-assistant/mappers/button.entity.mapper.service.d.ts +19 -0
  201. package/dist/plugins/devices-home-assistant/mappers/button.entity.mapper.service.js +51 -0
  202. package/dist/plugins/devices-home-assistant/mappers/button.entity.mapper.service.js.map +1 -0
  203. package/dist/plugins/devices-home-assistant/mappings/definitions/entity-mappings.yaml +56 -7
  204. package/dist/plugins/devices-home-assistant/models/mapping-preview.model.d.ts +1 -0
  205. package/dist/plugins/devices-home-assistant/models/mapping-preview.model.js +11 -0
  206. package/dist/plugins/devices-home-assistant/models/mapping-preview.model.js.map +1 -1
  207. package/dist/plugins/devices-home-assistant/services/device-adoption.service.js +17 -0
  208. package/dist/plugins/devices-home-assistant/services/device-adoption.service.js.map +1 -1
  209. package/dist/plugins/devices-home-assistant/services/ha-mdns-discoverer.service.js +3 -1
  210. package/dist/plugins/devices-home-assistant/services/ha-mdns-discoverer.service.js.map +1 -1
  211. package/dist/plugins/devices-home-assistant/services/home-assistant-raw-event.service.d.ts +27 -0
  212. package/dist/plugins/devices-home-assistant/services/home-assistant-raw-event.service.js +271 -0
  213. package/dist/plugins/devices-home-assistant/services/home-assistant-raw-event.service.js.map +1 -0
  214. package/dist/plugins/devices-home-assistant/services/home-assistant.ws.service.d.ts +2 -2
  215. package/dist/plugins/devices-home-assistant/services/home-assistant.ws.service.js +33 -14
  216. package/dist/plugins/devices-home-assistant/services/home-assistant.ws.service.js.map +1 -1
  217. package/dist/plugins/devices-home-assistant/services/mapping-preview.service.js +24 -4
  218. package/dist/plugins/devices-home-assistant/services/mapping-preview.service.js.map +1 -1
  219. package/dist/plugins/devices-home-assistant/services/state-changed.event.service.d.ts +4 -1
  220. package/dist/plugins/devices-home-assistant/services/state-changed.event.service.js +84 -5
  221. package/dist/plugins/devices-home-assistant/services/state-changed.event.service.js.map +1 -1
  222. package/dist/plugins/devices-home-assistant/services/wizard.service.js +1 -0
  223. package/dist/plugins/devices-home-assistant/services/wizard.service.js.map +1 -1
  224. package/dist/plugins/devices-home-assistant/utils/ha-event.utils.d.ts +2 -0
  225. package/dist/plugins/devices-home-assistant/utils/ha-event.utils.js +50 -0
  226. package/dist/plugins/devices-home-assistant/utils/ha-event.utils.js.map +1 -0
  227. package/dist/plugins/devices-homekit/listeners/homekit-event.listener.d.ts +4 -1
  228. package/dist/plugins/devices-homekit/listeners/homekit-event.listener.js +39 -4
  229. package/dist/plugins/devices-homekit/listeners/homekit-event.listener.js.map +1 -1
  230. package/dist/plugins/devices-homekit/mappers/base.mapper.js +30 -6
  231. package/dist/plugins/devices-homekit/mappers/base.mapper.js.map +1 -1
  232. package/dist/plugins/devices-homekit/mappers/button.mapper.d.ts +15 -0
  233. package/dist/plugins/devices-homekit/mappers/button.mapper.js +143 -0
  234. package/dist/plugins/devices-homekit/mappers/button.mapper.js.map +1 -0
  235. package/dist/plugins/devices-homekit/mappers/characteristic-write.d.ts +2 -0
  236. package/dist/plugins/devices-homekit/mappers/characteristic-write.js +17 -0
  237. package/dist/plugins/devices-homekit/mappers/characteristic-write.js.map +1 -0
  238. package/dist/plugins/devices-homekit/mappers/homekit-mapper.interface.d.ts +17 -1
  239. package/dist/plugins/devices-homekit/mappers/thermostat-coordinator.d.ts +7 -0
  240. package/dist/plugins/devices-homekit/mappers/thermostat-coordinator.js +96 -84
  241. package/dist/plugins/devices-homekit/mappers/thermostat-coordinator.js.map +1 -1
  242. package/dist/plugins/devices-homekit/services/homekit-bridge.service.js +2 -0
  243. package/dist/plugins/devices-homekit/services/homekit-bridge.service.js.map +1 -1
  244. package/dist/plugins/devices-homekit/services/homekit-mapper-registry.service.d.ts +5 -1
  245. package/dist/plugins/devices-homekit/services/homekit-mapper-registry.service.js +42 -0
  246. package/dist/plugins/devices-homekit/services/homekit-mapper-registry.service.js.map +1 -1
  247. package/dist/plugins/devices-homekit/utils/ciao-receive-guard.d.ts +1 -0
  248. package/dist/plugins/devices-homekit/utils/ciao-receive-guard.js +36 -0
  249. package/dist/plugins/devices-homekit/utils/ciao-receive-guard.js.map +1 -0
  250. package/dist/plugins/devices-homey/mappings/definitions/channels.yaml +50 -0
  251. package/dist/plugins/devices-homey/mappings/definitions/devices.yaml +18 -0
  252. package/dist/plugins/devices-homey/mappings/definitions/properties.yaml +55 -0
  253. package/dist/plugins/devices-homey/mappings/device-support.js +10 -0
  254. package/dist/plugins/devices-homey/mappings/device-support.js.map +1 -1
  255. package/dist/plugins/devices-homey/mappings/mapping-loader.service.d.ts +1 -0
  256. package/dist/plugins/devices-homey/mappings/mapping-loader.service.js +66 -8
  257. package/dist/plugins/devices-homey/mappings/mapping-loader.service.js.map +1 -1
  258. package/dist/plugins/devices-homey/models/inventory.model.d.ts +2 -1
  259. package/dist/plugins/devices-homey/models/inventory.model.js +1 -0
  260. package/dist/plugins/devices-homey/models/inventory.model.js.map +1 -1
  261. package/dist/plugins/devices-homey/models/mapping-preview.model.d.ts +1 -0
  262. package/dist/plugins/devices-homey/models/mapping-preview.model.js +1 -0
  263. package/dist/plugins/devices-homey/models/mapping-preview.model.js.map +1 -1
  264. package/dist/plugins/devices-homey/services/homey-mapping-preview.service.js +7 -0
  265. package/dist/plugins/devices-homey/services/homey-mapping-preview.service.js.map +1 -1
  266. package/dist/plugins/devices-homey/services/homey-synchronizer.service.d.ts +3 -1
  267. package/dist/plugins/devices-homey/services/homey-synchronizer.service.js +37 -6
  268. package/dist/plugins/devices-homey/services/homey-synchronizer.service.js.map +1 -1
  269. package/dist/plugins/devices-reterminal/services/reterminal-button.service.d.ts +7 -3
  270. package/dist/plugins/devices-reterminal/services/reterminal-button.service.js +63 -17
  271. package/dist/plugins/devices-reterminal/services/reterminal-button.service.js.map +1 -1
  272. package/dist/plugins/devices-shelly-ng/delegates/delegates-manager.service.d.ts +36 -3
  273. package/dist/plugins/devices-shelly-ng/delegates/delegates-manager.service.js +707 -42
  274. package/dist/plugins/devices-shelly-ng/delegates/delegates-manager.service.js.map +1 -1
  275. package/dist/plugins/devices-shelly-ng/delegates/shelly-device.delegate.d.ts +11 -1
  276. package/dist/plugins/devices-shelly-ng/delegates/shelly-device.delegate.js +100 -10
  277. package/dist/plugins/devices-shelly-ng/delegates/shelly-device.delegate.js.map +1 -1
  278. package/dist/plugins/devices-shelly-ng/devices-shelly-ng.constants.js +3 -2
  279. package/dist/plugins/devices-shelly-ng/devices-shelly-ng.constants.js.map +1 -1
  280. package/dist/plugins/devices-shelly-ng/devices-shelly-ng.plugin.js +2 -0
  281. package/dist/plugins/devices-shelly-ng/devices-shelly-ng.plugin.js.map +1 -1
  282. package/dist/plugins/devices-shelly-ng/mappings/definitions/inputs.yaml +80 -0
  283. package/dist/plugins/devices-shelly-ng/mappings/mapping-loader.service.js +7 -1
  284. package/dist/plugins/devices-shelly-ng/mappings/mapping-loader.service.js.map +1 -1
  285. package/dist/plugins/devices-shelly-ng/mappings/mapping.types.d.ts +6 -3
  286. package/dist/plugins/devices-shelly-ng/mappings/schema/mapping-schema.json +5 -0
  287. package/dist/plugins/devices-shelly-ng/services/device-manager.service.js +153 -8
  288. package/dist/plugins/devices-shelly-ng/services/device-manager.service.js.map +1 -1
  289. package/dist/plugins/devices-shelly-ng/services/poll-placement-diagnostics.service.d.ts +51 -0
  290. package/dist/plugins/devices-shelly-ng/services/poll-placement-diagnostics.service.js +549 -0
  291. package/dist/plugins/devices-shelly-ng/services/poll-placement-diagnostics.service.js.map +1 -0
  292. package/dist/plugins/devices-shelly-ng/services/shelly-ng.service.d.ts +15 -2
  293. package/dist/plugins/devices-shelly-ng/services/shelly-ng.service.js +140 -35
  294. package/dist/plugins/devices-shelly-ng/services/shelly-ng.service.js.map +1 -1
  295. package/dist/plugins/devices-shelly-ng/services/shelly-rpc-client.service.js +3 -0
  296. package/dist/plugins/devices-shelly-ng/services/shelly-rpc-client.service.js.map +1 -1
  297. package/dist/plugins/devices-shelly-ng/services/shelly-ws-server.service.d.ts +1 -0
  298. package/dist/plugins/devices-shelly-ng/services/shelly-ws-server.service.js +14 -4
  299. package/dist/plugins/devices-shelly-ng/services/shelly-ws-server.service.js.map +1 -1
  300. package/dist/plugins/devices-shelly-v1/devices-shelly-v1.constants.d.ts +2 -0
  301. package/dist/plugins/devices-shelly-v1/devices-shelly-v1.constants.js +66 -4
  302. package/dist/plugins/devices-shelly-v1/devices-shelly-v1.constants.js.map +1 -1
  303. package/dist/plugins/devices-shelly-v1/devices-shelly-v1.plugin.js +2 -0
  304. package/dist/plugins/devices-shelly-v1/devices-shelly-v1.plugin.js.map +1 -1
  305. package/dist/plugins/devices-shelly-v1/platforms/shelly-v1.device.platform.js +7 -0
  306. package/dist/plugins/devices-shelly-v1/platforms/shelly-v1.device.platform.js.map +1 -1
  307. package/dist/plugins/devices-shelly-v1/services/device-mapper.service.d.ts +3 -1
  308. package/dist/plugins/devices-shelly-v1/services/device-mapper.service.js +20 -2
  309. package/dist/plugins/devices-shelly-v1/services/device-mapper.service.js.map +1 -1
  310. package/dist/plugins/devices-shelly-v1/services/shelly-v1-input-tracker.service.d.ts +16 -0
  311. package/dist/plugins/devices-shelly-v1/services/shelly-v1-input-tracker.service.js +107 -0
  312. package/dist/plugins/devices-shelly-v1/services/shelly-v1-input-tracker.service.js.map +1 -0
  313. package/dist/plugins/devices-shelly-v1/services/shelly-v1.service.d.ts +7 -1
  314. package/dist/plugins/devices-shelly-v1/services/shelly-v1.service.js +98 -3
  315. package/dist/plugins/devices-shelly-v1/services/shelly-v1.service.js.map +1 -1
  316. package/dist/plugins/devices-third-party/controllers/third-party-inputs.controller.d.ts +17 -0
  317. package/dist/plugins/devices-third-party/controllers/third-party-inputs.controller.js +205 -0
  318. package/dist/plugins/devices-third-party/controllers/third-party-inputs.controller.js.map +1 -0
  319. package/dist/plugins/devices-third-party/devices-third-party.openapi.d.ts +1 -1
  320. package/dist/plugins/devices-third-party/devices-third-party.plugin.js +2 -1
  321. package/dist/plugins/devices-third-party/devices-third-party.plugin.js.map +1 -1
  322. package/dist/plugins/devices-third-party/dto/report-input-occurrence-response.dto.d.ts +5 -0
  323. package/dist/plugins/devices-third-party/dto/report-input-occurrence-response.dto.js +50 -0
  324. package/dist/plugins/devices-third-party/dto/report-input-occurrence-response.dto.js.map +1 -0
  325. package/dist/plugins/devices-third-party/dto/report-input-occurrence.dto.d.ts +8 -0
  326. package/dist/plugins/devices-third-party/dto/report-input-occurrence.dto.js +81 -0
  327. package/dist/plugins/devices-third-party/dto/report-input-occurrence.dto.js.map +1 -0
  328. package/dist/plugins/devices-third-party/platforms/third-party-device.platform.js +19 -4
  329. package/dist/plugins/devices-third-party/platforms/third-party-device.platform.js.map +1 -1
  330. package/dist/plugins/devices-virtual/listeners/virtual-projection.listener.d.ts +2 -0
  331. package/dist/plugins/devices-virtual/listeners/virtual-projection.listener.js +57 -0
  332. package/dist/plugins/devices-virtual/listeners/virtual-projection.listener.js.map +1 -1
  333. package/dist/plugins/devices-virtual/platforms/virtual-device.platform.d.ts +3 -8
  334. package/dist/plugins/devices-virtual/platforms/virtual-device.platform.js +6 -31
  335. package/dist/plugins/devices-virtual/platforms/virtual-device.platform.js.map +1 -1
  336. package/dist/plugins/devices-wled/services/wled-mdns-discoverer.service.js +3 -1
  337. package/dist/plugins/devices-wled/services/wled-mdns-discoverer.service.js.map +1 -1
  338. package/dist/plugins/devices-zigbee2mqtt/devices-zigbee2mqtt.constants.d.ts +3 -0
  339. package/dist/plugins/devices-zigbee2mqtt/devices-zigbee2mqtt.constants.js +41 -5
  340. package/dist/plugins/devices-zigbee2mqtt/devices-zigbee2mqtt.constants.js.map +1 -1
  341. package/dist/plugins/devices-zigbee2mqtt/interfaces/zigbee2mqtt.interface.d.ts +7 -1
  342. package/dist/plugins/devices-zigbee2mqtt/mappings/config-driven.converter.js +16 -15
  343. package/dist/plugins/devices-zigbee2mqtt/mappings/config-driven.converter.js.map +1 -1
  344. package/dist/plugins/devices-zigbee2mqtt/mappings/definitions/remotes.yaml +505 -74
  345. package/dist/plugins/devices-zigbee2mqtt/mappings/schema/mapping-schema.json +3 -3
  346. package/dist/plugins/devices-zigbee2mqtt/mappings/transformers/transformer.types.d.ts +1 -1
  347. package/dist/plugins/devices-zigbee2mqtt/services/base-client-adapter.d.ts +8 -2
  348. package/dist/plugins/devices-zigbee2mqtt/services/base-client-adapter.js +6 -5
  349. package/dist/plugins/devices-zigbee2mqtt/services/base-client-adapter.js.map +1 -1
  350. package/dist/plugins/devices-zigbee2mqtt/services/device-adoption.service.js +18 -11
  351. package/dist/plugins/devices-zigbee2mqtt/services/device-adoption.service.js.map +1 -1
  352. package/dist/plugins/devices-zigbee2mqtt/services/device-mapper.service.d.ts +9 -3
  353. package/dist/plugins/devices-zigbee2mqtt/services/device-mapper.service.js +166 -3
  354. package/dist/plugins/devices-zigbee2mqtt/services/device-mapper.service.js.map +1 -1
  355. package/dist/plugins/devices-zigbee2mqtt/services/mqtt-client-adapter.service.js +5 -2
  356. package/dist/plugins/devices-zigbee2mqtt/services/mqtt-client-adapter.service.js.map +1 -1
  357. package/dist/plugins/devices-zigbee2mqtt/services/zigbee2mqtt.service.d.ts +1 -0
  358. package/dist/plugins/devices-zigbee2mqtt/services/zigbee2mqtt.service.js +44 -4
  359. package/dist/plugins/devices-zigbee2mqtt/services/zigbee2mqtt.service.js.map +1 -1
  360. package/dist/plugins/influx-v1/services/influx-v1-managed.service.js +2 -2
  361. package/dist/plugins/influx-v1/services/influx-v1-managed.service.js.map +1 -1
  362. package/dist/plugins/influx-v2/services/influx-v2-managed.service.js +2 -2
  363. package/dist/plugins/influx-v2/services/influx-v2-managed.service.js.map +1 -1
  364. package/dist/plugins/memory-storage/services/memory-storage-managed.service.js +2 -2
  365. package/dist/plugins/memory-storage/services/memory-storage-managed.service.js.map +1 -1
  366. package/dist/plugins/remote-access-cloudflare-tunnel/controllers/setup.controller.d.ts +19 -0
  367. package/dist/plugins/remote-access-cloudflare-tunnel/controllers/setup.controller.js +159 -0
  368. package/dist/plugins/remote-access-cloudflare-tunnel/controllers/setup.controller.js.map +1 -0
  369. package/dist/plugins/remote-access-cloudflare-tunnel/controllers/status.controller.d.ts +13 -0
  370. package/dist/plugins/remote-access-cloudflare-tunnel/controllers/status.controller.js +99 -0
  371. package/dist/plugins/remote-access-cloudflare-tunnel/controllers/status.controller.js.map +1 -0
  372. package/dist/plugins/remote-access-cloudflare-tunnel/dto/update-config.dto.d.ts +9 -0
  373. package/dist/plugins/remote-access-cloudflare-tunnel/dto/update-config.dto.js +94 -0
  374. package/dist/plugins/remote-access-cloudflare-tunnel/dto/update-config.dto.js.map +1 -0
  375. package/dist/plugins/remote-access-cloudflare-tunnel/models/config.model.d.ts +9 -0
  376. package/dist/plugins/remote-access-cloudflare-tunnel/models/config.model.js +92 -0
  377. package/dist/plugins/remote-access-cloudflare-tunnel/models/config.model.js.map +1 -0
  378. package/dist/plugins/remote-access-cloudflare-tunnel/models/install.model.d.ts +7 -0
  379. package/dist/plugins/remote-access-cloudflare-tunnel/models/install.model.js +48 -0
  380. package/dist/plugins/remote-access-cloudflare-tunnel/models/install.model.js.map +1 -0
  381. package/dist/plugins/remote-access-cloudflare-tunnel/models/status.model.d.ts +44 -0
  382. package/dist/plugins/remote-access-cloudflare-tunnel/models/status.model.js +369 -0
  383. package/dist/plugins/remote-access-cloudflare-tunnel/models/status.model.js.map +1 -0
  384. package/dist/plugins/remote-access-cloudflare-tunnel/remote-access-cloudflare-tunnel.constants.d.ts +24 -0
  385. package/dist/plugins/remote-access-cloudflare-tunnel/remote-access-cloudflare-tunnel.constants.js +27 -0
  386. package/dist/plugins/remote-access-cloudflare-tunnel/remote-access-cloudflare-tunnel.constants.js.map +1 -0
  387. package/dist/plugins/remote-access-cloudflare-tunnel/remote-access-cloudflare-tunnel.exceptions.d.ts +8 -0
  388. package/dist/plugins/remote-access-cloudflare-tunnel/remote-access-cloudflare-tunnel.exceptions.js +19 -0
  389. package/dist/plugins/remote-access-cloudflare-tunnel/remote-access-cloudflare-tunnel.exceptions.js.map +1 -0
  390. package/dist/plugins/remote-access-cloudflare-tunnel/remote-access-cloudflare-tunnel.openapi.d.ts +4 -0
  391. package/dist/plugins/remote-access-cloudflare-tunnel/remote-access-cloudflare-tunnel.openapi.js +20 -0
  392. package/dist/plugins/remote-access-cloudflare-tunnel/remote-access-cloudflare-tunnel.openapi.js.map +1 -0
  393. package/dist/plugins/remote-access-cloudflare-tunnel/remote-access-cloudflare-tunnel.plugin.d.ts +21 -0
  394. package/dist/plugins/remote-access-cloudflare-tunnel/remote-access-cloudflare-tunnel.plugin.js +135 -0
  395. package/dist/plugins/remote-access-cloudflare-tunnel/remote-access-cloudflare-tunnel.plugin.js.map +1 -0
  396. package/dist/plugins/remote-access-cloudflare-tunnel/scripts/cloudflared-setup.sh +185 -0
  397. package/dist/plugins/remote-access-cloudflare-tunnel/services/cloudflare-tunnel-managed.service.d.ts +100 -0
  398. package/dist/plugins/remote-access-cloudflare-tunnel/services/cloudflare-tunnel-managed.service.js +564 -0
  399. package/dist/plugins/remote-access-cloudflare-tunnel/services/cloudflare-tunnel-managed.service.js.map +1 -0
  400. package/dist/plugins/remote-access-cloudflare-tunnel/services/cloudflare-tunnel-provider.service.d.ts +22 -0
  401. package/dist/plugins/remote-access-cloudflare-tunnel/services/cloudflare-tunnel-provider.service.js +43 -0
  402. package/dist/plugins/remote-access-cloudflare-tunnel/services/cloudflare-tunnel-provider.service.js.map +1 -0
  403. package/dist/plugins/remote-access-cloudflare-tunnel/services/cloudflare-tunnel-setup.service.d.ts +38 -0
  404. package/dist/plugins/remote-access-cloudflare-tunnel/services/cloudflare-tunnel-setup.service.js +147 -0
  405. package/dist/plugins/remote-access-cloudflare-tunnel/services/cloudflare-tunnel-setup.service.js.map +1 -0
  406. package/dist/plugins/remote-access-cloudflare-tunnel/services/cloudflared-cli.service.d.ts +15 -0
  407. package/dist/plugins/remote-access-cloudflare-tunnel/services/cloudflared-cli.service.js +55 -0
  408. package/dist/plugins/remote-access-cloudflare-tunnel/services/cloudflared-cli.service.js.map +1 -0
  409. package/dist/plugins/remote-access-cloudflare-tunnel/services/cloudflared-metrics.service.d.ts +8 -0
  410. package/dist/plugins/remote-access-cloudflare-tunnel/services/cloudflared-metrics.service.js +49 -0
  411. package/dist/plugins/remote-access-cloudflare-tunnel/services/cloudflared-metrics.service.js.map +1 -0
  412. package/dist/plugins/remote-access-cloudflare-tunnel/services/cloudflared-process.service.d.ts +27 -0
  413. package/dist/plugins/remote-access-cloudflare-tunnel/services/cloudflared-process.service.js +139 -0
  414. package/dist/plugins/remote-access-cloudflare-tunnel/services/cloudflared-process.service.js.map +1 -0
  415. package/dist/plugins/remote-access-tailscale/controllers/setup.controller.d.ts +11 -6
  416. package/dist/plugins/remote-access-tailscale/controllers/setup.controller.js +115 -25
  417. package/dist/plugins/remote-access-tailscale/controllers/setup.controller.js.map +1 -1
  418. package/dist/plugins/remote-access-tailscale/controllers/status.controller.d.ts +6 -5
  419. package/dist/plugins/remote-access-tailscale/controllers/status.controller.js +26 -16
  420. package/dist/plugins/remote-access-tailscale/controllers/status.controller.js.map +1 -1
  421. package/dist/plugins/remote-access-tailscale/models/status.model.d.ts +16 -0
  422. package/dist/plugins/remote-access-tailscale/models/status.model.js +100 -1
  423. package/dist/plugins/remote-access-tailscale/models/status.model.js.map +1 -1
  424. package/dist/plugins/remote-access-tailscale/remote-access-tailscale.constants.d.ts +3 -0
  425. package/dist/plugins/remote-access-tailscale/remote-access-tailscale.constants.js +4 -1
  426. package/dist/plugins/remote-access-tailscale/remote-access-tailscale.constants.js.map +1 -1
  427. package/dist/plugins/remote-access-tailscale/remote-access-tailscale.exceptions.d.ts +17 -1
  428. package/dist/plugins/remote-access-tailscale/remote-access-tailscale.exceptions.js +33 -1
  429. package/dist/plugins/remote-access-tailscale/remote-access-tailscale.exceptions.js.map +1 -1
  430. package/dist/plugins/remote-access-tailscale/remote-access-tailscale.openapi.d.ts +2 -2
  431. package/dist/plugins/remote-access-tailscale/remote-access-tailscale.openapi.js +1 -0
  432. package/dist/plugins/remote-access-tailscale/remote-access-tailscale.openapi.js.map +1 -1
  433. package/dist/plugins/remote-access-tailscale/remote-access-tailscale.plugin.js +3 -1
  434. package/dist/plugins/remote-access-tailscale/remote-access-tailscale.plugin.js.map +1 -1
  435. package/dist/plugins/remote-access-tailscale/services/tailscale-cli.service.d.ts +8 -4
  436. package/dist/plugins/remote-access-tailscale/services/tailscale-cli.service.js +58 -14
  437. package/dist/plugins/remote-access-tailscale/services/tailscale-cli.service.js.map +1 -1
  438. package/dist/plugins/remote-access-tailscale/services/tailscale-login.service.d.ts +8 -3
  439. package/dist/plugins/remote-access-tailscale/services/tailscale-login.service.js +175 -151
  440. package/dist/plugins/remote-access-tailscale/services/tailscale-login.service.js.map +1 -1
  441. package/dist/plugins/remote-access-tailscale/services/tailscale-node-managed.service.d.ts +54 -7
  442. package/dist/plugins/remote-access-tailscale/services/tailscale-node-managed.service.js +528 -109
  443. package/dist/plugins/remote-access-tailscale/services/tailscale-node-managed.service.js.map +1 -1
  444. package/dist/plugins/remote-access-tailscale/services/tailscale-operation-coordinator.service.d.ts +33 -0
  445. package/dist/plugins/remote-access-tailscale/services/tailscale-operation-coordinator.service.js +167 -0
  446. package/dist/plugins/remote-access-tailscale/services/tailscale-operation-coordinator.service.js.map +1 -0
  447. package/dist/plugins/remote-access-tailscale/services/tailscale-provider.service.d.ts +13 -1
  448. package/dist/plugins/remote-access-tailscale/services/tailscale-provider.service.js +8 -2
  449. package/dist/plugins/remote-access-tailscale/services/tailscale-provider.service.js.map +1 -1
  450. package/dist/plugins/remote-access-tailscale/services/tailscale-serve.service.d.ts +1 -1
  451. package/dist/plugins/remote-access-tailscale/services/tailscale-serve.service.js +7 -6
  452. package/dist/plugins/remote-access-tailscale/services/tailscale-serve.service.js.map +1 -1
  453. package/dist/plugins/remote-access-tailscale/services/tailscale-setup.service.d.ts +1 -3
  454. package/dist/plugins/remote-access-tailscale/services/tailscale-setup.service.js +9 -11
  455. package/dist/plugins/remote-access-tailscale/services/tailscale-setup.service.js.map +1 -1
  456. package/dist/plugins/remote-access-tailscale/utils/tailscale-control.utils.d.ts +5 -0
  457. package/dist/plugins/remote-access-tailscale/utils/tailscale-control.utils.js +36 -0
  458. package/dist/plugins/remote-access-tailscale/utils/tailscale-control.utils.js.map +1 -0
  459. package/dist/plugins/scenes-local/platforms/local-scene.platform.d.ts +3 -1
  460. package/dist/plugins/scenes-local/platforms/local-scene.platform.js +12 -7
  461. package/dist/plugins/scenes-local/platforms/local-scene.platform.js.map +1 -1
  462. package/dist/plugins/simulator/controllers/simulator.controller.d.ts +8 -2
  463. package/dist/plugins/simulator/controllers/simulator.controller.js +102 -2
  464. package/dist/plugins/simulator/controllers/simulator.controller.js.map +1 -1
  465. package/dist/plugins/simulator/dto/simulate-occurrence.dto.d.ts +12 -0
  466. package/dist/plugins/simulator/dto/simulate-occurrence.dto.js +122 -0
  467. package/dist/plugins/simulator/dto/simulate-occurrence.dto.js.map +1 -0
  468. package/dist/plugins/simulator/models/simulator-response.model.d.ts +12 -0
  469. package/dist/plugins/simulator/models/simulator-response.model.js +84 -1
  470. package/dist/plugins/simulator/models/simulator-response.model.js.map +1 -1
  471. package/dist/plugins/simulator/scenarios/definitions/small-apartment.yaml +78 -0
  472. package/dist/plugins/simulator/services/scenario-executor.service.js +3 -1
  473. package/dist/plugins/simulator/services/scenario-executor.service.js.map +1 -1
  474. package/dist/plugins/simulator/services/simulation.service.js +10 -1
  475. package/dist/plugins/simulator/services/simulation.service.js.map +1 -1
  476. package/dist/plugins/simulator/simulator.openapi.d.ts +3 -2
  477. package/dist/plugins/simulator/simulator.openapi.js +5 -0
  478. package/dist/plugins/simulator/simulator.openapi.js.map +1 -1
  479. package/dist/plugins/simulator/simulators/device-simulator.interface.d.ts +2 -0
  480. package/dist/plugins/simulator/simulators/device-simulator.interface.js +83 -0
  481. package/dist/plugins/simulator/simulators/device-simulator.interface.js.map +1 -1
  482. package/dist/plugins/simulator/simulators/index.d.ts +1 -0
  483. package/dist/plugins/simulator/simulators/index.js +1 -0
  484. package/dist/plugins/simulator/simulators/index.js.map +1 -1
  485. package/dist/plugins/simulator/simulators/input-controller.simulator.d.ts +10 -0
  486. package/dist/plugins/simulator/simulators/input-controller.simulator.js +57 -0
  487. package/dist/plugins/simulator/simulators/input-controller.simulator.js.map +1 -0
  488. package/dist/plugins/simulator/simulators/lighting.simulator.js +1 -0
  489. package/dist/plugins/simulator/simulators/lighting.simulator.js.map +1 -1
  490. package/dist/plugins/spaces-home-control/listeners/space-activity.listener.d.ts +6 -7
  491. package/dist/plugins/spaces-home-control/listeners/space-activity.listener.js +19 -44
  492. package/dist/plugins/spaces-home-control/listeners/space-activity.listener.js.map +1 -1
  493. package/dist/plugins/spaces-home-control/listeners/space-climate-state.listener.d.ts +4 -4
  494. package/dist/plugins/spaces-home-control/listeners/space-climate-state.listener.js +9 -22
  495. package/dist/plugins/spaces-home-control/listeners/space-climate-state.listener.js.map +1 -1
  496. package/dist/plugins/spaces-home-control/listeners/space-lighting-state.listener.d.ts +4 -4
  497. package/dist/plugins/spaces-home-control/listeners/space-lighting-state.listener.js +9 -22
  498. package/dist/plugins/spaces-home-control/listeners/space-lighting-state.listener.js.map +1 -1
  499. package/dist/plugins/spaces-home-control/listeners/space-sensor-state.listener.d.ts +4 -4
  500. package/dist/plugins/spaces-home-control/listeners/space-sensor-state.listener.js +9 -22
  501. package/dist/plugins/spaces-home-control/listeners/space-sensor-state.listener.js.map +1 -1
  502. package/dist/plugins/spaces-home-control/services/climate-intent.service.d.ts +3 -1
  503. package/dist/plugins/spaces-home-control/services/climate-intent.service.js +6 -3
  504. package/dist/plugins/spaces-home-control/services/climate-intent.service.js.map +1 -1
  505. package/dist/plugins/spaces-home-control/services/covers-intent.service.d.ts +3 -1
  506. package/dist/plugins/spaces-home-control/services/covers-intent.service.js +6 -3
  507. package/dist/plugins/spaces-home-control/services/covers-intent.service.js.map +1 -1
  508. package/dist/plugins/spaces-home-control/services/lighting-intent.service.d.ts +3 -1
  509. package/dist/plugins/spaces-home-control/services/lighting-intent.service.js +7 -4
  510. package/dist/plugins/spaces-home-control/services/lighting-intent.service.js.map +1 -1
  511. package/dist/plugins/spaces-home-control/services/space-climate-state.service.d.ts +3 -5
  512. package/dist/plugins/spaces-home-control/services/space-climate-state.service.js +9 -12
  513. package/dist/plugins/spaces-home-control/services/space-climate-state.service.js.map +1 -1
  514. package/dist/plugins/spaces-home-control/services/space-lighting-state.service.d.ts +3 -5
  515. package/dist/plugins/spaces-home-control/services/space-lighting-state.service.js +7 -10
  516. package/dist/plugins/spaces-home-control/services/space-lighting-state.service.js.map +1 -1
  517. package/dist/plugins/spaces-home-control/services/space-media-activity.service.d.ts +3 -1
  518. package/dist/plugins/spaces-home-control/services/space-media-activity.service.js +11 -5
  519. package/dist/plugins/spaces-home-control/services/space-media-activity.service.js.map +1 -1
  520. package/dist/plugins/spaces-home-control/services/space-sensor-state.service.d.ts +3 -5
  521. package/dist/plugins/spaces-home-control/services/space-sensor-state.service.js +7 -10
  522. package/dist/plugins/spaces-home-control/services/space-sensor-state.service.js.map +1 -1
  523. package/dist/plugins/spaces-home-control/services/space-state-read.service.d.ts +47 -0
  524. package/dist/plugins/spaces-home-control/services/space-state-read.service.js +262 -0
  525. package/dist/plugins/spaces-home-control/services/space-state-read.service.js.map +1 -0
  526. package/dist/plugins/spaces-home-control/services/space-undo-history.service.d.ts +3 -1
  527. package/dist/plugins/spaces-home-control/services/space-undo-history.service.js +8 -5
  528. package/dist/plugins/spaces-home-control/services/space-undo-history.service.js.map +1 -1
  529. package/dist/plugins/spaces-home-control/spaces-home-control.plugin.js +4 -0
  530. package/dist/plugins/spaces-home-control/spaces-home-control.plugin.js.map +1 -1
  531. package/dist/spec/channels.d.ts +51 -1
  532. package/dist/spec/channels.js +64 -1
  533. package/dist/spec/channels.js.map +1 -1
  534. package/dist/spec/devices.d.ts +155 -2
  535. package/dist/spec/devices.js +161 -2
  536. package/dist/spec/devices.js.map +1 -1
  537. package/dist/tsconfig.build.tsbuildinfo +1 -1
  538. package/package.json +4 -4
@@ -8,20 +8,24 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
8
8
  var __metadata = (this && this.__metadata) || function (k, v) {
9
9
  if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
10
10
  };
11
+ var __param = (this && this.__param) || function (paramIndex, decorator) {
12
+ return function (target, key) { decorator(target, key, paramIndex); }
13
+ };
11
14
  var __importDefault = (this && this.__importDefault) || function (mod) {
12
15
  return (mod && mod.__esModule) ? mod : { "default": mod };
13
16
  };
14
17
  Object.defineProperty(exports, "__esModule", { value: true });
15
18
  exports.TailscaleNodeManagedService = void 0;
16
19
  exports.compareTailscaleVersions = compareTailscaleVersions;
17
- const node_child_process_1 = require("node:child_process");
18
20
  const os_1 = __importDefault(require("os"));
19
21
  const path_1 = require("path");
20
22
  const common_1 = require("@nestjs/common");
21
23
  const config_1 = require("@nestjs/config");
22
24
  const event_emitter_1 = require("@nestjs/event-emitter");
23
25
  const logger_1 = require("../../../common/logger");
26
+ const cancellable_exec_utils_1 = require("../../../common/utils/cancellable-exec.utils");
24
27
  const config_utils_1 = require("../../../common/utils/config.utils");
28
+ const remote_access_observation_utils_1 = require("../../../common/utils/remote-access-observation.utils");
25
29
  const config_service_1 = require("../../../modules/config/services/config.service");
26
30
  const base_managed_extension_service_1 = require("../../../modules/extensions/services/base-managed-extension.service");
27
31
  const platform_constants_1 = require("../../../modules/platform/platform.constants");
@@ -31,9 +35,9 @@ const config_model_1 = require("../models/config.model");
31
35
  const remote_access_tailscale_constants_1 = require("../remote-access-tailscale.constants");
32
36
  const remote_access_tailscale_exceptions_1 = require("../remote-access-tailscale.exceptions");
33
37
  const tailscale_cli_service_1 = require("./tailscale-cli.service");
38
+ const tailscale_operation_coordinator_service_1 = require("./tailscale-operation-coordinator.service");
34
39
  const tailscale_serve_service_1 = require("./tailscale-serve.service");
35
40
  const tailscale_status_mapper_service_1 = require("./tailscale-status-mapper.service");
36
- const TAILSCALE_REQUIREMENTS_PERIODIC_REFRESH_MS = 5 * 60 * 1000;
37
41
  const TAILSCALE_PRINT_PLAN_TIMEOUT_MS = 2_000;
38
42
  const OPERATOR_GRANTED_SATISFIED_MESSAGE = 'The smart-panel operator is granted.';
39
43
  const TAILSCALE_DOCUMENTATION_URL = 'https://smart-panel.fastybird.com/docs';
@@ -52,7 +56,7 @@ function compareTailscaleVersions(a, b) {
52
56
  }
53
57
  const UNEVALUATED_MESSAGE = 'Not evaluated: the platform requirement is not satisfied.';
54
58
  let TailscaleNodeManagedService = class TailscaleNodeManagedService extends base_managed_extension_service_1.BaseManagedExtensionService {
55
- constructor(cli, mapper, configService, nestConfigService, platformService, eventEmitter, serveService) {
59
+ constructor(cli, mapper, configService, nestConfigService, platformService, eventEmitter, serveService, operations = new tailscale_operation_coordinator_service_1.TailscaleOperationCoordinatorService()) {
56
60
  super();
57
61
  this.cli = cli;
58
62
  this.mapper = mapper;
@@ -61,22 +65,120 @@ let TailscaleNodeManagedService = class TailscaleNodeManagedService extends base
61
65
  this.platformService = platformService;
62
66
  this.eventEmitter = eventEmitter;
63
67
  this.serveService = serveService;
68
+ this.operations = operations;
64
69
  this.logger = (0, logger_1.createExtensionLogger)(remote_access_tailscale_constants_1.REMOTE_ACCESS_TAILSCALE_PLUGIN_NAME, 'TailscaleNodeManagedService');
65
70
  this.owner = { kind: 'plugin', type: remote_access_tailscale_constants_1.REMOTE_ACCESS_TAILSCALE_PLUGIN_NAME };
66
71
  this.serviceId = 'node';
67
72
  this.activationPolicy = 'owner-enabled';
73
+ this.observations = new remote_access_observation_utils_1.RemoteAccessObservation();
74
+ this.requirementObservations = new remote_access_observation_utils_1.RemoteAccessObservation();
75
+ this.authentication = 'unknown';
76
+ this.identity = {};
77
+ this.connectPromise = null;
78
+ this.stopPromise = null;
68
79
  this.pollTimer = null;
69
80
  this.lastStatus = null;
70
81
  this.lastError = null;
71
82
  this.pluginConfig = null;
83
+ this.pendingAdvertiseTags = null;
72
84
  this.requirementsCache = null;
73
- this.requirementsRefreshedAt = 0;
74
85
  this.lastServeConvergeDenied = false;
75
86
  this.reconnectAttempts = 0;
76
87
  this.nextReconnectAttemptAt = 0;
88
+ this.operations.onSettled((operation) => {
89
+ if (operation !== 'serve' && operation !== 'reconnect') {
90
+ this.schedulePoll(0);
91
+ }
92
+ });
93
+ }
94
+ getOperationCoordinator() {
95
+ return this.operations;
96
+ }
97
+ getControlState() {
98
+ return {
99
+ enabled: this.isPluginEnabled(),
100
+ serviceState: this.state,
101
+ authentication: this.authentication,
102
+ operation: this.operations.getOperation(),
103
+ };
104
+ }
105
+ isPluginEnabled() {
106
+ try {
107
+ return this.configService.getPluginConfig(remote_access_tailscale_constants_1.REMOTE_ACCESS_TAILSCALE_PLUGIN_NAME).enabled;
108
+ }
109
+ catch {
110
+ return false;
111
+ }
112
+ }
113
+ clearAuthentication() {
114
+ this.authentication = 'required';
115
+ this.identity = {};
116
+ }
117
+ observeAuthentication(status) {
118
+ if (status.BackendState === 'NeedsLogin') {
119
+ this.clearAuthentication();
120
+ }
121
+ else if (['Running', 'Starting', 'Stopped', 'NeedsMachineAuth'].includes(status.BackendState)) {
122
+ this.authentication = 'authenticated';
123
+ this.identity = this.mapper.map(status, { port: this.getBackendPort() }).details;
124
+ }
125
+ }
126
+ async onModuleDestroy() {
127
+ await this.stop();
128
+ }
129
+ async ensureSupervisorStartedForLogin() {
130
+ if (!this.isPluginEnabled()) {
131
+ throw new remote_access_tailscale_exceptions_1.TailscalePluginDisabledException();
132
+ }
133
+ if (this.state !== 'started') {
134
+ await this.startNode(false);
135
+ }
136
+ }
137
+ assertRequirements(requirements) {
138
+ const failed = requirements.find((requirement) => !requirement.satisfied);
139
+ if (failed) {
140
+ throw new remote_access_tailscale_exceptions_1.TailscaleRequirementUnsatisfiedException(failed);
141
+ }
142
+ if (requirements.length === 0) {
143
+ throw new tailscale_cli_service_1.TailscaleCliError('unknown', 'Tailscale setup could not be verified. Re-check setup before connecting.');
144
+ }
145
+ }
146
+ async connect() {
147
+ if (!this.isPluginEnabled()) {
148
+ throw new remote_access_tailscale_exceptions_1.TailscalePluginDisabledException();
149
+ }
150
+ if (this.connectPromise !== null) {
151
+ return this.connectPromise;
152
+ }
153
+ this.connectPromise = (this.state === 'started'
154
+ ? this.operations.run('connect', async (token) => {
155
+ const config = this.getPluginConfig();
156
+ const requirements = await this.refreshRequirements('start');
157
+ this.operations.assertCurrent(token);
158
+ this.assertRequirements(requirements);
159
+ const status = await this.cli.getStatus();
160
+ this.operations.assertCurrent(token);
161
+ this.observeAuthentication(status);
162
+ if (!this.mapper.hasExistingKey(status)) {
163
+ throw new tailscale_cli_service_1.TailscaleCliError('needs-login', 'Sign in to Tailscale before connecting.');
164
+ }
165
+ if (this.mapper.map(status, { port: this.getBackendPort() }).state === 'connected') {
166
+ return;
167
+ }
168
+ await this.applyNodePreferences(config);
169
+ this.operations.assertCurrent(token);
170
+ this.schedulePoll(0);
171
+ })
172
+ : this.startNode(true)).finally(() => {
173
+ this.connectPromise = null;
174
+ });
175
+ return this.connectPromise;
77
176
  }
78
177
  async start() {
79
- await this.withLock(async () => {
178
+ return this.startNode(false);
179
+ }
180
+ async startNode(strict) {
181
+ await this.operations.run('connect', async (token) => {
80
182
  if (this.state === 'started') {
81
183
  return;
82
184
  }
@@ -85,18 +187,33 @@ let TailscaleNodeManagedService = class TailscaleNodeManagedService extends base
85
187
  this.reconnectAttempts = 0;
86
188
  this.nextReconnectAttemptAt = 0;
87
189
  const config = this.getPluginConfig();
190
+ this.pendingAdvertiseTags = config.advertiseTags.join(',');
88
191
  this.logger.log('Starting Tailscale node service');
89
192
  try {
90
193
  const requirements = await this.refreshRequirements('start');
194
+ this.operations.assertCurrent(token);
195
+ if (strict) {
196
+ this.assertRequirements(requirements);
197
+ }
91
198
  if (this.requirementsSatisfied(requirements)) {
92
199
  const status = await this.getStatusOrNull();
200
+ this.operations.assertCurrent(token);
201
+ if (status) {
202
+ this.observeAuthentication(status);
203
+ }
93
204
  if (status && this.mapper.hasExistingKey(status)) {
94
- await this.cli.set(this.buildPreferenceFlags(config));
95
- await this.cli.up(this.buildUpFlags(config));
205
+ await this.applyNodePreferences(config);
96
206
  }
97
207
  }
98
208
  }
99
209
  catch (error) {
210
+ this.operations.assertCurrent(token);
211
+ if (strict) {
212
+ this.state = 'error';
213
+ this.lastError = error instanceof Error ? error.message : 'Unknown Tailscale failure.';
214
+ await this.emitStatus();
215
+ throw error;
216
+ }
100
217
  if (error instanceof tailscale_cli_service_1.TailscaleCliError && error.kind === 'permission-denied') {
101
218
  await this.refreshRequirements('permission-denied').catch(() => undefined);
102
219
  }
@@ -109,59 +226,155 @@ let TailscaleNodeManagedService = class TailscaleNodeManagedService extends base
109
226
  });
110
227
  });
111
228
  }
112
- this.schedulePoll(0);
229
+ this.operations.assertCurrent(token);
113
230
  this.state = 'started';
231
+ this.lastError = null;
232
+ this.schedulePoll(0);
114
233
  this.logger.log('Tailscale node service started');
115
234
  });
235
+ if (strict && this.authentication !== 'authenticated') {
236
+ throw new tailscale_cli_service_1.TailscaleCliError('needs-login', 'Sign in to Tailscale before connecting.');
237
+ }
116
238
  }
117
239
  async stop() {
118
- await this.withLock(async () => {
119
- if (this.state === 'stopped') {
240
+ if (this.stopPromise !== null) {
241
+ return this.stopPromise;
242
+ }
243
+ const shouldDown = this.state !== 'stopped' || this.operations.getOperation() !== null || this.operations.hasPendingChildren();
244
+ this.state = 'stopping';
245
+ this.observations.invalidate();
246
+ this.requirementObservations.invalidate();
247
+ this.clearPoll();
248
+ this.stopPromise = this.operations
249
+ .interrupt('disconnect', async (token) => {
250
+ if (!shouldDown) {
251
+ this.state = 'stopped';
252
+ await this.emitStatus();
120
253
  return;
121
254
  }
122
- this.state = 'stopping';
123
- this.clearPoll();
124
255
  try {
125
256
  await this.cli.down();
257
+ this.operations.assertCurrent(token);
126
258
  this.state = 'stopped';
127
259
  }
128
260
  catch (error) {
129
- if (await this.isStopFailureTolerated(error)) {
130
- this.logger.debug('tailscale down failed while stopping (safe to ignore if the node was already down)', {
131
- message: error instanceof Error ? error.message : String(error),
132
- });
133
- this.state = 'stopped';
134
- }
135
- else {
136
- const message = error instanceof Error ? error.message : String(error);
137
- this.state = 'error';
138
- this.lastError = message;
139
- this.logger.error('Failed to stop the Tailscale node service', { message });
140
- await this.emitStatus();
141
- throw new remote_access_tailscale_exceptions_1.TailscaleNodeStopFailedException(message);
261
+ this.operations.assertCurrent(token);
262
+ const tolerated = await this.isStopFailureTolerated(error);
263
+ this.operations.assertCurrent(token);
264
+ if (!tolerated) {
265
+ throw error;
142
266
  }
267
+ this.state = 'stopped';
268
+ }
269
+ this.lastError = null;
270
+ await this.emitStatus();
271
+ })
272
+ .catch(async (error) => {
273
+ if (error instanceof remote_access_tailscale_exceptions_1.TailscaleOperationCancelledException) {
274
+ throw error;
143
275
  }
276
+ this.state = 'error';
277
+ this.lastError = error instanceof Error ? error.message : 'Unknown Tailscale failure.';
144
278
  await this.emitStatus();
145
- this.logger.log('Tailscale node service stopped');
279
+ if (error instanceof Error && 'code' in error) {
280
+ throw error;
281
+ }
282
+ throw new remote_access_tailscale_exceptions_1.TailscaleNodeStopFailedException(this.lastError);
283
+ })
284
+ .finally(() => {
285
+ this.stopPromise = null;
146
286
  });
287
+ return this.stopPromise;
147
288
  }
148
289
  async isStopFailureTolerated(error) {
149
290
  if (error instanceof tailscale_cli_service_1.TailscaleCliError &&
150
291
  (error.kind === 'needs-login' || error.kind === 'daemon-down' || error.kind === 'not-installed')) {
151
292
  return true;
152
293
  }
153
- const status = await this.getStatusOrNull();
294
+ const status = await this.getStatusOrNullWithin(remote_access_tailscale_constants_1.TAILSCALE_STOP_STATUS_TIMEOUT_MS);
154
295
  return status?.BackendState === 'Stopped';
155
296
  }
297
+ async getStatusOrNullWithin(timeoutMs) {
298
+ let timer;
299
+ try {
300
+ return await Promise.race([
301
+ this.getStatusOrNull(),
302
+ new Promise((resolve, reject) => {
303
+ timer = setTimeout(() => {
304
+ void this.operations.reapPendingChildren().then(() => resolve(null), reject);
305
+ }, timeoutMs);
306
+ }),
307
+ ]);
308
+ }
309
+ finally {
310
+ if (timer) {
311
+ clearTimeout(timer);
312
+ }
313
+ }
314
+ }
156
315
  async emitStatus() {
157
- const status = await this.computeStatus();
316
+ const generation = this.operations.getGeneration();
317
+ const status = this.state === 'stopped' || this.state === 'stopping' || this.state === 'error'
318
+ ? this.buildStatus(this.state === 'error' ? 'error' : 'disconnected', this.lastError ?? 'The node service is stopped.', this.identity)
319
+ : await this.computeStatus();
320
+ if (!this.operations.isCurrent(generation)) {
321
+ return;
322
+ }
323
+ this.operations.assertCurrent();
158
324
  this.lastStatus = status;
159
- this.eventEmitter.emit(remote_access_constants_1.EventType.PROVIDER_STATUS, status);
325
+ this.eventEmitter.emit(remote_access_constants_1.EventType.PROVIDER_OBSERVATION, {
326
+ status,
327
+ metadata: { requirements: this.getRequirements(), control: this.getControlState() },
328
+ });
160
329
  }
161
330
  async onConfigChanged() {
331
+ this.observations.invalidate();
332
+ this.requirementObservations.invalidate();
333
+ if (this.stopPromise !== null) {
334
+ await this.stopPromise;
335
+ }
336
+ this.clearPoll();
337
+ return this.operations.interrupt('config', async (token) => {
338
+ let result;
339
+ try {
340
+ result = await this.applyConfigChange();
341
+ }
342
+ catch (error) {
343
+ this.operations.assertCurrent(token);
344
+ this.state = 'error';
345
+ this.lastError = error instanceof Error ? error.message : 'Unknown Tailscale failure.';
346
+ await this.emitStatus();
347
+ throw error;
348
+ }
349
+ this.operations.assertCurrent(token);
350
+ if (this.isPollable()) {
351
+ this.schedulePoll(0);
352
+ }
353
+ return result;
354
+ });
355
+ }
356
+ async applyConfigChange() {
162
357
  const previous = this.pluginConfig;
163
358
  this.pluginConfig = null;
164
359
  const next = this.getPluginConfig();
360
+ if (this.pendingAdvertiseTags !== null || previous?.advertiseTags.join(',') !== next.advertiseTags.join(',')) {
361
+ this.pendingAdvertiseTags = next.advertiseTags.join(',');
362
+ }
363
+ if (!next.enabled) {
364
+ this.state = 'stopping';
365
+ try {
366
+ await this.cli.down();
367
+ }
368
+ catch (error) {
369
+ if (!(await this.isStopFailureTolerated(error))) {
370
+ throw error;
371
+ }
372
+ }
373
+ this.operations.assertCurrent();
374
+ this.state = 'stopped';
375
+ await this.emitStatus();
376
+ return { restartRequired: false };
377
+ }
165
378
  if (!previous || previous.loginServer !== next.loginServer) {
166
379
  this.logger.log('Tailscale login_server changed (or its prior value was unknown), restart required');
167
380
  try {
@@ -178,22 +391,41 @@ let TailscaleNodeManagedService = class TailscaleNodeManagedService extends base
178
391
  throw error;
179
392
  }
180
393
  }
394
+ this.operations.assertCurrent();
395
+ this.clearAuthentication();
181
396
  return { restartRequired: true };
182
397
  }
398
+ if (!this.isPollable()) {
399
+ return { restartRequired: false };
400
+ }
183
401
  try {
184
402
  const requirements = await this.refreshRequirements('start');
185
403
  if (this.requirementsSatisfied(requirements)) {
186
- const status = await this.getStatusOrNull();
404
+ let status = await this.getStatusOrNull();
187
405
  if (status && this.mapper.hasExistingKey(status)) {
188
- await this.cli.set(this.buildPreferenceFlags(next));
406
+ this.operations.assertCurrent();
407
+ if (this.pendingAdvertiseTags !== null) {
408
+ await this.applyNodePreferences(next);
409
+ this.operations.assertCurrent();
410
+ status = await this.getStatusOrNull();
411
+ this.operations.assertCurrent();
412
+ if (status) {
413
+ this.observeAuthentication(status);
414
+ }
415
+ }
416
+ else {
417
+ await this.cli.set(this.buildPreferenceFlags(next));
418
+ this.operations.assertCurrent();
419
+ }
189
420
  const port = this.getBackendPort();
190
- if (this.mapper.map(status, { port }).state === 'connected') {
421
+ if (status && this.mapper.map(status, { port }).state === 'connected') {
191
422
  await this.convergeServe(next, port, status);
192
423
  }
193
424
  }
194
425
  }
195
426
  }
196
427
  catch (error) {
428
+ this.operations.assertCurrent();
197
429
  if (error instanceof tailscale_cli_service_1.TailscaleCliError && error.kind === 'permission-denied') {
198
430
  await this.refreshRequirements('permission-denied').catch(() => undefined);
199
431
  }
@@ -204,52 +436,112 @@ let TailscaleNodeManagedService = class TailscaleNodeManagedService extends base
204
436
  return { restartRequired: false };
205
437
  }
206
438
  async isHealthy() {
439
+ const generation = this.operations.getGeneration();
440
+ if (!this.isPollable()) {
441
+ return false;
442
+ }
207
443
  if (!this.requirementsSatisfied(this.getRequirements())) {
208
444
  return false;
209
445
  }
210
446
  try {
211
- const status = await this.cli.getStatus();
212
- return status.BackendState === 'Running' && status.Self?.Online === true;
447
+ const { raw: status } = await this.computeStatusWithRawStatus();
448
+ return (this.isPollable() &&
449
+ this.operations.isCurrent(generation) &&
450
+ status?.BackendState === 'Running' &&
451
+ status.Self?.Online === true);
213
452
  }
214
453
  catch {
215
454
  return false;
216
455
  }
217
456
  }
218
457
  async factoryReset() {
219
- await this.cli.serveReset().catch(() => undefined);
458
+ this.state = 'stopping';
459
+ this.observations.invalidate();
460
+ this.requirementObservations.invalidate();
461
+ this.clearPoll();
220
462
  try {
221
- await this.cli.logout();
222
- return { success: true };
463
+ return await this.operations.interrupt('reset', async (token) => {
464
+ await this.cli.down().catch((error) => this.isStopFailureTolerated(error).then((safe) => {
465
+ if (!safe) {
466
+ throw error;
467
+ }
468
+ }));
469
+ this.operations.assertCurrent(token);
470
+ await this.cli.serveReset().catch(() => undefined);
471
+ this.operations.assertCurrent(token);
472
+ await this.cli.logout().catch((error) => {
473
+ if (!(error instanceof tailscale_cli_service_1.TailscaleCliError && ['not-installed', 'needs-login', 'daemon-down'].includes(error.kind))) {
474
+ throw error;
475
+ }
476
+ });
477
+ this.operations.assertCurrent(token);
478
+ this.clearAuthentication();
479
+ this.state = 'stopped';
480
+ await this.emitStatus();
481
+ return { success: true };
482
+ });
223
483
  }
224
484
  catch (error) {
225
- if (error instanceof tailscale_cli_service_1.TailscaleCliError && (error.kind === 'not-installed' || error.kind === 'needs-login')) {
226
- return { success: true };
485
+ if (!(error instanceof remote_access_tailscale_exceptions_1.TailscaleOperationCancelledException)) {
486
+ this.state = 'error';
487
+ this.lastError = error instanceof Error ? error.message : 'Unknown error';
488
+ await this.emitStatus();
227
489
  }
228
490
  return { success: false, reason: error instanceof Error ? error.message : 'Unknown error' };
229
491
  }
230
492
  }
231
493
  async evaluateRequirements() {
232
- return this.refreshRequirements('status-read');
494
+ return this.refreshRequirements('setup-complete');
495
+ }
496
+ async reconcileSetup(generation) {
497
+ if (!this.operations.isCurrent(generation) || !this.getControlState().enabled) {
498
+ return;
499
+ }
500
+ await this.operations.run('config', async (token) => {
501
+ this.operations.assertCurrent(token);
502
+ if (!this.operations.isCurrent(generation)) {
503
+ return;
504
+ }
505
+ if (this.state !== 'started') {
506
+ await this.startNode(false);
507
+ }
508
+ else {
509
+ const status = await this.cli.getStatus();
510
+ this.operations.assertCurrent(token);
511
+ this.observeAuthentication(status);
512
+ if (this.mapper.hasExistingKey(status)) {
513
+ await this.applyNodePreferences(this.getPluginConfig());
514
+ this.operations.assertCurrent(token);
515
+ }
516
+ this.schedulePoll(0);
517
+ }
518
+ });
233
519
  }
234
520
  getRequirements() {
235
521
  return this.requirementsCache ?? [];
236
522
  }
237
- async refreshRequirements(reason) {
238
- if (reason === 'periodic' &&
239
- this.requirementsCache &&
240
- Date.now() - this.requirementsRefreshedAt < TAILSCALE_REQUIREMENTS_PERIODIC_REFRESH_MS) {
241
- return this.requirementsCache;
523
+ async refreshRequirements(reason, signal) {
524
+ const generation = this.operations.getGeneration();
525
+ const readOnly = reason === 'periodic' || reason === 'status-read';
526
+ const requirements = await (readOnly
527
+ ? this.requirementObservations.run((readSignal) => this.evaluateRequirementsLive(generation, false, readSignal), signal)
528
+ : this.evaluateRequirementsLive(generation, true, signal));
529
+ signal?.throwIfAborted();
530
+ if (!this.operations.isCurrent(generation)) {
531
+ return this.getRequirements();
242
532
  }
243
- const requirements = await this.evaluateRequirementsLive();
244
533
  this.requirementsCache = requirements;
245
- this.requirementsRefreshedAt = Date.now();
246
534
  return requirements;
247
535
  }
248
536
  requirementsSatisfied(requirements) {
249
537
  return requirements.length > 0 && requirements.every((requirement) => requirement.satisfied);
250
538
  }
251
- async evaluateRequirementsLive() {
539
+ async evaluateRequirementsLive(generation, allowProbe = false, signal) {
252
540
  const platform = await this.evaluatePlatformSupported();
541
+ signal?.throwIfAborted();
542
+ if (!this.operations.isCurrent(generation)) {
543
+ return this.getRequirements();
544
+ }
253
545
  if (!platform.satisfied) {
254
546
  return [
255
547
  await this.finalizeRequirement(platform),
@@ -259,20 +551,34 @@ let TailscaleNodeManagedService = class TailscaleNodeManagedService extends base
259
551
  this.unevaluatedRequirement('version-supported'),
260
552
  ];
261
553
  }
262
- const [{ binary, version }, daemonActive, operatorGranted] = await Promise.all([
263
- this.evaluateBinaryAndVersion(),
264
- this.evaluateDaemonActive(),
265
- this.evaluateOperatorGranted(),
554
+ const results = await Promise.allSettled([
555
+ this.evaluateBinaryAndVersion(signal),
556
+ this.evaluateDaemonActive(signal),
557
+ this.evaluateOperatorGranted(generation, allowProbe, signal),
266
558
  ]);
267
- return this.attachRemedies([platform, binary, daemonActive, operatorGranted, version]);
559
+ signal?.throwIfAborted();
560
+ const [binaryResult, daemonResult, operatorResult] = results;
561
+ if (binaryResult.status === 'rejected') {
562
+ throw binaryResult.reason;
563
+ }
564
+ if (daemonResult.status === 'rejected') {
565
+ throw daemonResult.reason;
566
+ }
567
+ if (operatorResult.status === 'rejected') {
568
+ throw operatorResult.reason;
569
+ }
570
+ const { binary, version } = binaryResult.value;
571
+ const daemonActive = daemonResult.value;
572
+ const operatorGranted = operatorResult.value;
573
+ return this.attachRemedies([platform, binary, daemonActive, operatorGranted, version], signal);
268
574
  }
269
575
  unevaluatedRequirement(code) {
270
576
  return { code, satisfied: false, message: UNEVALUATED_MESSAGE, remedy: null };
271
577
  }
272
- async attachRemedies(requirements) {
578
+ async attachRemedies(requirements, signal) {
273
579
  let installRemedyPromise = null;
274
580
  const getInstallRemedy = () => {
275
- installRemedyPromise ??= this.buildInstallRemedy();
581
+ installRemedyPromise ??= this.buildInstallRemedy(signal);
276
582
  return installRemedyPromise;
277
583
  };
278
584
  return Promise.all(requirements.map((requirement) => this.finalizeRequirement(requirement, getInstallRemedy)));
@@ -301,9 +607,9 @@ let TailscaleNodeManagedService = class TailscaleNodeManagedService extends base
301
607
  return { commands: [], note: TAILSCALE_DOCUMENTATION_URL };
302
608
  }
303
609
  }
304
- async buildInstallRemedy() {
610
+ async buildInstallRemedy(signal) {
305
611
  try {
306
- const stdout = await this.runSetupScriptPrintPlan('install');
612
+ const stdout = await this.runSetupScriptPrintPlan(signal);
307
613
  const lines = stdout
308
614
  .split('\n')
309
615
  .map((line) => line.trim())
@@ -323,37 +629,100 @@ let TailscaleNodeManagedService = class TailscaleNodeManagedService extends base
323
629
  return { commands: [], note: TAILSCALE_VENDOR_DOWNLOAD_URL };
324
630
  }
325
631
  }
326
- runSetupScriptPrintPlan(step) {
632
+ async runSetupScriptPrintPlan(signal) {
327
633
  const script = (0, path_1.join)(__dirname, '..', 'scripts', 'tailscale-setup.sh');
328
- return new Promise((resolve, reject) => {
329
- (0, node_child_process_1.execFile)('bash', [script, '--print-plan', `--step=${step}`], { timeout: TAILSCALE_PRINT_PLAN_TIMEOUT_MS }, (error, stdout) => {
330
- if (error) {
331
- reject(error);
332
- return;
333
- }
334
- resolve(stdout ?? '');
335
- });
336
- });
634
+ return (await (0, cancellable_exec_utils_1.cancellableExecFile)('bash', [script, '--print-plan', '--step=install'], signal, TAILSCALE_PRINT_PLAN_TIMEOUT_MS)).stdout;
635
+ }
636
+ async computeStatus(_requirementsReason = 'status-read', options) {
637
+ return (await this.computeStatusWithRawStatus(options)).status;
638
+ }
639
+ async awaitObservationIdle() {
640
+ await Promise.all([this.observations.awaitIdle(), this.requirementObservations.awaitIdle()]);
641
+ }
642
+ async getStatusSnapshot(options) {
643
+ const observation = await this.computeStatusWithRawStatus(options);
644
+ return {
645
+ status: observation.status,
646
+ metadata: { requirements: observation.requirements, control: this.getControlState() },
647
+ };
648
+ }
649
+ async computeStatusWithRawStatus(options) {
650
+ const generation = this.operations.getGeneration();
651
+ const revision = this.operations.getObservationRevision();
652
+ try {
653
+ const result = await this.observations.run(async (signal) => {
654
+ const requirements = await this.refreshRequirements('status-read', signal);
655
+ const collected = await this.collectStatusWithRawStatus(generation, signal, requirements);
656
+ signal.throwIfAborted();
657
+ return { ...collected, requirements };
658
+ }, options?.signal);
659
+ if (!this.operations.isCurrent(generation) || !this.operations.isObservationCurrent(revision)) {
660
+ return this.supersededObservation();
661
+ }
662
+ if (result.raw && this.isPollable()) {
663
+ this.observeAuthentication(result.raw);
664
+ }
665
+ return result;
666
+ }
667
+ catch (error) {
668
+ if (!this.operations.isCurrent(generation) ||
669
+ !this.operations.isObservationCurrent(revision) ||
670
+ !this.isPollable()) {
671
+ return this.supersededObservation();
672
+ }
673
+ return {
674
+ status: this.buildStatus('error', error instanceof Error ? error.message : 'The status observation failed.'),
675
+ raw: null,
676
+ requirements: this.getRequirements(),
677
+ };
678
+ }
337
679
  }
338
- async computeStatus(requirementsReason = 'status-read') {
339
- return (await this.computeStatusWithRawStatus(requirementsReason)).status;
680
+ supersededObservation() {
681
+ return {
682
+ status: this.buildStatus(this.state === 'error' ? 'error' : 'disconnected', this.lastError ?? 'The observation was superseded by a lifecycle action.'),
683
+ raw: null,
684
+ requirements: this.getRequirements(),
685
+ };
340
686
  }
341
- async computeStatusWithRawStatus(requirementsReason = 'status-read') {
687
+ async collectStatusWithRawStatus(generation = this.operations.getGeneration(), signal, requirements = this.getRequirements()) {
342
688
  if (this.state === 'stopped' || this.state === 'stopping') {
343
- return { status: this.buildStatus('disconnected', 'The node service is stopped.'), raw: null };
689
+ return { status: this.buildStatus('disconnected', 'The node service is stopped.', this.identity), raw: null };
344
690
  }
345
691
  if (this.state === 'error') {
346
692
  return { status: this.buildStatus('error', this.lastError ?? 'The Tailscale node service failed.'), raw: null };
347
693
  }
348
- const platform = await this.evaluatePlatformSupported();
694
+ const platform = requirements.find((requirement) => requirement.code === 'platform-supported') ?? {
695
+ satisfied: false,
696
+ message: 'Platform detection did not complete.',
697
+ };
698
+ signal?.throwIfAborted();
699
+ if (!this.operations.isCurrent(generation)) {
700
+ return {
701
+ status: this.buildStatus('disconnected', 'The observation was superseded by a lifecycle action.', this.identity),
702
+ raw: null,
703
+ };
704
+ }
349
705
  if (!platform.satisfied) {
350
706
  return { status: this.buildStatus('unsupported', platform.message), raw: null };
351
707
  }
352
708
  try {
353
- const status = await this.cli.getStatus();
709
+ const status = await this.cli.getStatus(signal);
710
+ signal?.throwIfAborted();
711
+ if (!this.operations.isCurrent(generation)) {
712
+ return {
713
+ status: this.buildStatus('disconnected', 'The observation was superseded by a lifecycle action.', this.identity),
714
+ raw: null,
715
+ };
716
+ }
354
717
  const port = this.getBackendPort();
355
718
  const postureAdvisories = this.buildPostureAdvisories(status);
356
- const requirements = await this.refreshRequirements(requirementsReason);
719
+ signal?.throwIfAborted();
720
+ if (!this.operations.isCurrent(generation)) {
721
+ return {
722
+ status: this.buildStatus('disconnected', 'The observation was superseded by a lifecycle action.', this.identity),
723
+ raw: null,
724
+ };
725
+ }
357
726
  const operatorRequirement = requirements.find((requirement) => requirement.code === 'operator-granted');
358
727
  if (operatorRequirement && !operatorRequirement.satisfied) {
359
728
  return {
@@ -372,7 +741,7 @@ let TailscaleNodeManagedService = class TailscaleNodeManagedService extends base
372
741
  };
373
742
  }
374
743
  const config = this.getPluginConfig();
375
- const serveResult = await this.serveService.read(config, port, status);
744
+ const serveResult = await this.serveService.read(config, port, status, signal);
376
745
  return {
377
746
  status: this.buildStatus(mapped.state, mapped.message, mapped.details, [...mapped.proxyAddresses, ...serveResult.proxyAddresses], [...mapped.endpoints, ...serveResult.endpoints], [...postureAdvisories, ...serveResult.advisories]),
378
747
  raw: status,
@@ -398,7 +767,11 @@ let TailscaleNodeManagedService = class TailscaleNodeManagedService extends base
398
767
  }
399
768
  }
400
769
  async convergeServe(config, port, status) {
401
- const result = await this.serveService.converge(config, port, status);
770
+ const result = await this.operations.run('serve', async (token) => {
771
+ const converged = await this.serveService.converge(config, port, status);
772
+ this.operations.assertCurrent(token);
773
+ return converged;
774
+ }, false);
402
775
  if (result.permissionDenied) {
403
776
  if (!this.lastServeConvergeDenied) {
404
777
  this.lastServeConvergeDenied = true;
@@ -437,9 +810,9 @@ let TailscaleNodeManagedService = class TailscaleNodeManagedService extends base
437
810
  message: `Tailscale is not supported on the '${platformType}' platform.`,
438
811
  };
439
812
  }
440
- async evaluateBinaryAndVersion() {
813
+ async evaluateBinaryAndVersion(signal) {
441
814
  try {
442
- const info = await this.cli.getVersion();
815
+ const info = await this.cli.getVersion(signal);
443
816
  const supported = compareTailscaleVersions(info.version, remote_access_tailscale_constants_1.TAILSCALE_MIN_VERSION) >= 0;
444
817
  return {
445
818
  binary: { code: 'binary-installed', satisfied: true, message: `Tailscale ${info.version} is installed.` },
@@ -468,21 +841,24 @@ let TailscaleNodeManagedService = class TailscaleNodeManagedService extends base
468
841
  };
469
842
  }
470
843
  }
471
- async evaluateDaemonActive() {
472
- const active = await this.isSystemdUnitActive('tailscaled');
844
+ async evaluateDaemonActive(signal) {
845
+ const active = await this.isSystemdUnitActive('tailscaled', signal);
473
846
  return {
474
847
  code: 'daemon-active',
475
848
  satisfied: active,
476
849
  message: active ? 'tailscaled is active.' : 'tailscaled is not active. Run setup or start the service.',
477
850
  };
478
851
  }
479
- async evaluateOperatorGranted() {
852
+ async evaluateOperatorGranted(generation = this.operations.getGeneration(), allowProbe = false, signal) {
480
853
  const serviceUser = os_1.default.userInfo().username;
481
854
  try {
482
- const prefs = await this.cli.getPrefs();
855
+ const prefs = await this.cli.getPrefs(signal);
483
856
  return this.buildOperatorRequirement(prefs.OperatorUser === serviceUser, serviceUser);
484
857
  }
485
858
  catch (error) {
859
+ if (!this.operations.isCurrent(generation)) {
860
+ return { code: 'operator-granted', satisfied: false, message: 'The requirement observation was superseded.' };
861
+ }
486
862
  if (error instanceof tailscale_cli_service_1.TailscaleCliError) {
487
863
  if (error.kind === 'daemon-down') {
488
864
  return {
@@ -499,12 +875,22 @@ let TailscaleNodeManagedService = class TailscaleNodeManagedService extends base
499
875
  };
500
876
  }
501
877
  }
878
+ if (!allowProbe) {
879
+ const verified = this.getRequirements().find((requirement) => requirement.code === 'operator-granted');
880
+ return verified?.satisfied
881
+ ? verified
882
+ : {
883
+ code: 'operator-granted',
884
+ satisfied: false,
885
+ message: 'The operator grant cannot be verified by this Tailscale version. Run Set up or Connect to verify management access.',
886
+ };
887
+ }
502
888
  return this.evaluateOperatorGrantedViaProbe(serviceUser);
503
889
  }
504
890
  }
505
891
  async evaluateOperatorGrantedViaProbe(serviceUser) {
506
892
  try {
507
- await this.cli.set([`--operator=${serviceUser}`]);
893
+ await this.operations.run('preferences', async () => this.cli.set([`--operator=${serviceUser}`]), false);
508
894
  return this.buildOperatorRequirement(true, serviceUser);
509
895
  }
510
896
  catch (error) {
@@ -547,16 +933,15 @@ let TailscaleNodeManagedService = class TailscaleNodeManagedService extends base
547
933
  return null;
548
934
  }
549
935
  }
550
- isSystemdUnitActive(unit) {
551
- return new Promise((resolve) => {
552
- (0, node_child_process_1.execFile)('systemctl', ['is-active', unit], { timeout: remote_access_tailscale_constants_1.TAILSCALE_SYSTEMCTL_PROBE_TIMEOUT_MS }, (error, stdout) => {
553
- if (error) {
554
- resolve(false);
555
- return;
556
- }
557
- resolve((stdout ?? '').trim() === 'active');
558
- });
559
- });
936
+ async isSystemdUnitActive(unit, signal) {
937
+ try {
938
+ const result = await (0, cancellable_exec_utils_1.cancellableExecFile)('systemctl', ['is-active', unit], signal, remote_access_tailscale_constants_1.TAILSCALE_SYSTEMCTL_PROBE_TIMEOUT_MS);
939
+ return result.exitCode === 0 && result.stdout.trim() === 'active';
940
+ }
941
+ catch {
942
+ signal?.throwIfAborted();
943
+ return false;
944
+ }
560
945
  }
561
946
  isPollable() {
562
947
  return this.state === 'starting' || this.state === 'started';
@@ -567,7 +952,7 @@ let TailscaleNodeManagedService = class TailscaleNodeManagedService extends base
567
952
  return;
568
953
  }
569
954
  this.pollTimer = setTimeout(() => {
570
- void this.pollTick();
955
+ this.operations.withoutOperation(() => void this.pollTick());
571
956
  }, delayMs);
572
957
  this.pollTimer.unref?.();
573
958
  }
@@ -578,9 +963,13 @@ let TailscaleNodeManagedService = class TailscaleNodeManagedService extends base
578
963
  }
579
964
  }
580
965
  async pollTick() {
966
+ const generation = this.operations.getGeneration();
967
+ let revision = this.operations.getObservationRevision();
581
968
  try {
582
- let { status, raw } = await this.computeStatusWithRawStatus('periodic');
583
- if (!this.isPollable()) {
969
+ let { status, raw, requirements } = await this.computeStatusWithRawStatus();
970
+ if (!this.isPollable() ||
971
+ !this.operations.isCurrent(generation) ||
972
+ !this.operations.isObservationCurrent(revision)) {
584
973
  return;
585
974
  }
586
975
  if (status.state === 'connected') {
@@ -593,27 +982,39 @@ let TailscaleNodeManagedService = class TailscaleNodeManagedService extends base
593
982
  this.requirementsSatisfied(this.getRequirements()) &&
594
983
  Date.now() >= this.nextReconnectAttemptAt) {
595
984
  const reconnected = await this.attemptReconnect();
596
- if (!this.isPollable()) {
985
+ revision = this.operations.getObservationRevision();
986
+ if (!this.isPollable() || !this.operations.isCurrent(generation)) {
597
987
  return;
598
988
  }
599
989
  if (reconnected) {
600
- ({ status, raw } = await this.computeStatusWithRawStatus('periodic'));
601
- if (!this.isPollable()) {
990
+ ({ status, raw, requirements } = await this.computeStatusWithRawStatus());
991
+ if (!this.isPollable() || !this.operations.isCurrent(generation)) {
602
992
  return;
603
993
  }
604
994
  }
605
995
  }
606
- if (raw && status.state === 'connected' && this.requirementsSatisfied(this.getRequirements())) {
607
- await this.convergeServe(this.getPluginConfig(), this.getBackendPort(), raw);
996
+ if (!this.isPollable() ||
997
+ !this.operations.isCurrent(generation) ||
998
+ !this.operations.isObservationCurrent(revision)) {
999
+ return;
608
1000
  }
609
1001
  if (this.hasStatusChanged(this.lastStatus, status)) {
610
1002
  this.lastStatus = status;
611
- this.eventEmitter.emit(remote_access_constants_1.EventType.PROVIDER_STATUS, status);
1003
+ this.eventEmitter.emit(remote_access_constants_1.EventType.PROVIDER_OBSERVATION, {
1004
+ status,
1005
+ metadata: { requirements, control: this.getControlState() },
1006
+ });
1007
+ }
1008
+ if (raw && status.state === 'connected' && this.requirementsSatisfied(this.getRequirements())) {
1009
+ await this.convergeServe(this.getPluginConfig(), this.getBackendPort(), raw);
1010
+ }
1011
+ if (!this.isPollable() || !this.operations.isCurrent(generation)) {
1012
+ return;
612
1013
  }
613
1014
  this.schedulePoll(status.state === 'connecting' ? remote_access_tailscale_constants_1.TAILSCALE_POLL_INTERVAL_TRANSITIONING_MS : remote_access_tailscale_constants_1.TAILSCALE_POLL_INTERVAL_STABLE_MS);
614
1015
  }
615
1016
  catch (error) {
616
- if (!this.isPollable()) {
1017
+ if (!this.isPollable() || !this.operations.isCurrent(generation)) {
617
1018
  return;
618
1019
  }
619
1020
  this.logger.error('Tailscale status poll failed', {
@@ -623,20 +1024,21 @@ let TailscaleNodeManagedService = class TailscaleNodeManagedService extends base
623
1024
  }
624
1025
  }
625
1026
  async attemptReconnect() {
626
- return this.withLock(async () => {
1027
+ return this.operations.run('reconnect', async (token) => {
627
1028
  if (this.state !== 'started') {
628
1029
  return false;
629
1030
  }
630
1031
  try {
631
1032
  const config = this.getPluginConfig();
632
- await this.cli.set(this.buildPreferenceFlags(config));
633
- await this.cli.up(this.buildUpFlags(config));
1033
+ await this.applyNodePreferences(config);
1034
+ this.operations.assertCurrent(token);
634
1035
  this.reconnectAttempts = 0;
635
1036
  this.nextReconnectAttemptAt = 0;
636
1037
  this.logger.log('Tailscale node reconnected automatically after being found unexpectedly disconnected.');
637
1038
  return true;
638
1039
  }
639
1040
  catch (error) {
1041
+ this.operations.assertCurrent(token);
640
1042
  this.reconnectAttempts += 1;
641
1043
  const delayMs = Math.min(remote_access_tailscale_constants_1.TAILSCALE_RECONNECT_BASE_DELAY_MS * 2 ** (this.reconnectAttempts - 1), remote_access_tailscale_constants_1.TAILSCALE_RECONNECT_MAX_DELAY_MS);
642
1044
  this.nextReconnectAttemptAt = Date.now() + delayMs;
@@ -663,18 +1065,33 @@ let TailscaleNodeManagedService = class TailscaleNodeManagedService extends base
663
1065
  JSON.stringify(previous.proxyAddresses) !== JSON.stringify(next.proxyAddresses) ||
664
1066
  JSON.stringify(previous.advisories) !== JSON.stringify(next.advisories));
665
1067
  }
1068
+ async applyNodePreferences(config) {
1069
+ this.operations.assertCurrent();
1070
+ const tags = config.advertiseTags.join(',');
1071
+ this.pendingAdvertiseTags = tags;
1072
+ await this.cli.set(this.buildPreferenceFlags(config));
1073
+ this.operations.assertCurrent();
1074
+ await this.cli.up(this.buildUpFlags(config));
1075
+ this.operations.assertCurrent();
1076
+ if (this.pendingAdvertiseTags === tags) {
1077
+ this.pendingAdvertiseTags = null;
1078
+ }
1079
+ }
666
1080
  buildPreferenceFlags(config) {
667
1081
  return [
668
1082
  `--hostname=${config.hostname}`,
669
1083
  `--accept-dns=${config.acceptDns}`,
670
1084
  `--accept-routes=${config.acceptRoutes}`,
671
- `--advertise-tags=${config.advertiseTags.join(',')}`,
672
1085
  `--ssh=${config.ssh}`,
673
1086
  `--operator=${os_1.default.userInfo().username}`,
674
1087
  ];
675
1088
  }
676
1089
  buildUpFlags(config) {
677
- return [...this.buildPreferenceFlags(config), `--login-server=${config.loginServer}`];
1090
+ return [
1091
+ ...this.buildPreferenceFlags(config),
1092
+ `--advertise-tags=${config.advertiseTags.join(',')}`,
1093
+ `--login-server=${config.loginServer}`,
1094
+ ];
678
1095
  }
679
1096
  buildStatus(state, message, details = {}, proxyAddresses = [], endpoints = [], advisories = []) {
680
1097
  return {
@@ -730,12 +1147,14 @@ let TailscaleNodeManagedService = class TailscaleNodeManagedService extends base
730
1147
  exports.TailscaleNodeManagedService = TailscaleNodeManagedService;
731
1148
  exports.TailscaleNodeManagedService = TailscaleNodeManagedService = __decorate([
732
1149
  (0, common_1.Injectable)(),
1150
+ __param(7, (0, common_1.Optional)()),
733
1151
  __metadata("design:paramtypes", [tailscale_cli_service_1.TailscaleCliService,
734
1152
  tailscale_status_mapper_service_1.TailscaleStatusMapperService,
735
1153
  config_service_1.ConfigService,
736
1154
  config_1.ConfigService,
737
1155
  platform_service_1.PlatformService,
738
1156
  event_emitter_1.EventEmitter2,
739
- tailscale_serve_service_1.TailscaleServeService])
1157
+ tailscale_serve_service_1.TailscaleServeService,
1158
+ tailscale_operation_coordinator_service_1.TailscaleOperationCoordinatorService])
740
1159
  ], TailscaleNodeManagedService);
741
1160
  //# sourceMappingURL=tailscale-node-managed.service.js.map