@fastybird/smart-panel-backend 1.1.0-alpha.2 → 1.1.0-alpha.20
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.
- package/dist/app.module.js +8 -0
- package/dist/app.module.js.map +1 -1
- package/dist/common/filters/conflict-exception.filter.d.ts +6 -0
- package/dist/common/filters/conflict-exception.filter.js +59 -0
- package/dist/common/filters/conflict-exception.filter.js.map +1 -0
- package/dist/common/filters/global-error.filter.js +1 -4
- package/dist/common/filters/global-error.filter.js.map +1 -1
- package/dist/common/filters/global-filters.d.ts +3 -0
- package/dist/common/filters/global-filters.js +22 -0
- package/dist/common/filters/global-filters.js.map +1 -0
- package/dist/common/filters/unprocessable-entity-exception.filter.d.ts +1 -0
- package/dist/common/filters/unprocessable-entity-exception.filter.js +15 -3
- package/dist/common/filters/unprocessable-entity-exception.filter.js.map +1 -1
- package/dist/common/utils/transform.utils.js +3 -0
- package/dist/common/utils/transform.utils.js.map +1 -1
- package/dist/dataSource.js +1 -0
- package/dist/dataSource.js.map +1 -1
- package/dist/main.js +2 -7
- package/dist/main.js.map +1 -1
- package/dist/migrations/1000000000026-AddHardwareInputCategories.d.ts +7 -0
- package/dist/migrations/1000000000026-AddHardwareInputCategories.js +364 -0
- package/dist/migrations/1000000000026-AddHardwareInputCategories.js.map +1 -0
- package/dist/modules/devices/controllers/channels.controller.d.ts +5 -1
- package/dist/modules/devices/controllers/channels.controller.js +34 -2
- package/dist/modules/devices/controllers/channels.controller.js.map +1 -1
- package/dist/modules/devices/controllers/channels.properties.controller.js +21 -4
- package/dist/modules/devices/controllers/channels.properties.controller.js.map +1 -1
- package/dist/modules/devices/controllers/devices.channels.controller.d.ts +5 -1
- package/dist/modules/devices/controllers/devices.channels.controller.js +38 -2
- package/dist/modules/devices/controllers/devices.channels.controller.js.map +1 -1
- package/dist/modules/devices/controllers/devices.channels.properties.controller.js +21 -4
- package/dist/modules/devices/controllers/devices.channels.properties.controller.js.map +1 -1
- package/dist/modules/devices/devices.constants.d.ts +6 -0
- package/dist/modules/devices/devices.constants.js +6 -0
- package/dist/modules/devices/devices.constants.js.map +1 -1
- package/dist/modules/devices/devices.module.js +18 -0
- package/dist/modules/devices/devices.module.js.map +1 -1
- package/dist/modules/devices/devices.openapi.d.ts +3 -1
- package/dist/modules/devices/devices.openapi.js +7 -0
- package/dist/modules/devices/devices.openapi.js.map +1 -1
- package/dist/modules/devices/dto/channel-input-occurrence.dto.d.ts +10 -0
- package/dist/modules/devices/dto/channel-input-occurrence.dto.js +99 -0
- package/dist/modules/devices/dto/channel-input-occurrence.dto.js.map +1 -0
- package/dist/modules/devices/models/channel-input-capabilities.model.d.ts +20 -0
- package/dist/modules/devices/models/channel-input-capabilities.model.js +111 -0
- package/dist/modules/devices/models/channel-input-capabilities.model.js.map +1 -0
- package/dist/modules/devices/models/channel-input-occurrence.model.d.ts +22 -0
- package/dist/modules/devices/models/channel-input-occurrence.model.js +154 -0
- package/dist/modules/devices/models/channel-input-occurrence.model.js.map +1 -0
- package/dist/modules/devices/services/channel-input-deduplication.service.d.ts +17 -0
- package/dist/modules/devices/services/channel-input-deduplication.service.js +88 -0
- package/dist/modules/devices/services/channel-input-deduplication.service.js.map +1 -0
- package/dist/modules/devices/services/channel-input-occurrences.service.d.ts +21 -0
- package/dist/modules/devices/services/channel-input-occurrences.service.js +163 -0
- package/dist/modules/devices/services/channel-input-occurrences.service.js.map +1 -0
- package/dist/modules/devices/services/channels.properties.service.d.ts +27 -3
- package/dist/modules/devices/services/channels.properties.service.js +304 -28
- package/dist/modules/devices/services/channels.properties.service.js.map +1 -1
- package/dist/modules/devices/services/channels.service.js +42 -38
- package/dist/modules/devices/services/channels.service.js.map +1 -1
- package/dist/modules/devices/services/command-latency-trace-collector.service.d.ts +101 -0
- package/dist/modules/devices/services/command-latency-trace-collector.service.js +451 -0
- package/dist/modules/devices/services/command-latency-trace-collector.service.js.map +1 -0
- package/dist/modules/devices/services/device-structure-lock.service.d.ts +10 -2
- package/dist/modules/devices/services/device-structure-lock.service.js +86 -7
- package/dist/modules/devices/services/device-structure-lock.service.js.map +1 -1
- package/dist/modules/devices/services/devices.service.js +37 -33
- package/dist/modules/devices/services/devices.service.js.map +1 -1
- package/dist/modules/devices/services/module-reset.service.d.ts +3 -1
- package/dist/modules/devices/services/module-reset.service.js +21 -16
- package/dist/modules/devices/services/module-reset.service.js.map +1 -1
- package/dist/modules/devices/services/property-command-dispatch.service.d.ts +45 -0
- package/dist/modules/devices/services/property-command-dispatch.service.js +227 -0
- package/dist/modules/devices/services/property-command-dispatch.service.js.map +1 -0
- package/dist/modules/devices/services/property-command-window.service.d.ts +71 -0
- package/dist/modules/devices/services/property-command-window.service.js +204 -0
- package/dist/modules/devices/services/property-command-window.service.js.map +1 -0
- package/dist/modules/devices/services/property-command.service.d.ts +20 -3
- package/dist/modules/devices/services/property-command.service.js +56 -10
- package/dist/modules/devices/services/property-command.service.js.map +1 -1
- package/dist/modules/devices/services/property-state-coordinator.service.d.ts +4 -0
- package/dist/modules/devices/services/property-state-coordinator.service.js +35 -0
- package/dist/modules/devices/services/property-state-coordinator.service.js.map +1 -0
- package/dist/modules/devices/services/property-value.service.d.ts +1 -0
- package/dist/modules/devices/services/property-value.service.js +4 -0
- package/dist/modules/devices/services/property-value.service.js.map +1 -1
- package/dist/modules/devices/utils/schema.utils.js +1 -1
- package/dist/modules/devices/utils/schema.utils.js.map +1 -1
- package/dist/modules/platform/services/platform.service.d.ts +13 -4
- package/dist/modules/platform/services/platform.service.js +57 -35
- package/dist/modules/platform/services/platform.service.js.map +1 -1
- package/dist/modules/remote-access/dto/update-config.dto.js +5 -0
- package/dist/modules/remote-access/dto/update-config.dto.js.map +1 -1
- package/dist/modules/remote-access/validators/is-remote-access-url.validator.js +5 -2
- package/dist/modules/remote-access/validators/is-remote-access-url.validator.js.map +1 -1
- package/dist/modules/system/scripts/update-worker.sh +668 -59
- package/dist/modules/system/services/privileged-worker.service.d.ts +10 -0
- package/dist/modules/system/services/privileged-worker.service.js +137 -11
- package/dist/modules/system/services/privileged-worker.service.js.map +1 -1
- package/dist/modules/system/services/update-executor.service.d.ts +20 -2
- package/dist/modules/system/services/update-executor.service.js +256 -25
- package/dist/modules/system/services/update-executor.service.js.map +1 -1
- package/dist/modules/websocket/gateway/websocket.gateway.d.ts +4 -1
- package/dist/modules/websocket/gateway/websocket.gateway.js +28 -5
- package/dist/modules/websocket/gateway/websocket.gateway.js.map +1 -1
- package/dist/modules/websocket/services/command-acknowledgement-trace.service.d.ts +143 -0
- package/dist/modules/websocket/services/command-acknowledgement-trace.service.js +523 -0
- package/dist/modules/websocket/services/command-acknowledgement-trace.service.js.map +1 -0
- package/dist/modules/websocket/websocket.module.js +9 -1
- package/dist/modules/websocket/websocket.module.js.map +1 -1
- package/dist/plugins/devices-home-assistant/devices-home-assistant.openapi.d.ts +2 -2
- package/dist/plugins/devices-home-assistant/devices-home-assistant.plugin.d.ts +6 -1
- package/dist/plugins/devices-home-assistant/devices-home-assistant.plugin.js +16 -1
- package/dist/plugins/devices-home-assistant/devices-home-assistant.plugin.js.map +1 -1
- package/dist/plugins/devices-home-assistant/dto/mapping-preview.dto.d.ts +1 -0
- package/dist/plugins/devices-home-assistant/dto/mapping-preview.dto.js +11 -0
- package/dist/plugins/devices-home-assistant/dto/mapping-preview.dto.js.map +1 -1
- package/dist/plugins/devices-home-assistant/mappers/button.entity.mapper.service.d.ts +19 -0
- package/dist/plugins/devices-home-assistant/mappers/button.entity.mapper.service.js +51 -0
- package/dist/plugins/devices-home-assistant/mappers/button.entity.mapper.service.js.map +1 -0
- package/dist/plugins/devices-home-assistant/mappings/definitions/entity-mappings.yaml +56 -7
- package/dist/plugins/devices-home-assistant/models/mapping-preview.model.d.ts +1 -0
- package/dist/plugins/devices-home-assistant/models/mapping-preview.model.js +11 -0
- package/dist/plugins/devices-home-assistant/models/mapping-preview.model.js.map +1 -1
- package/dist/plugins/devices-home-assistant/services/device-adoption.service.js +17 -0
- package/dist/plugins/devices-home-assistant/services/device-adoption.service.js.map +1 -1
- package/dist/plugins/devices-home-assistant/services/home-assistant-raw-event.service.d.ts +27 -0
- package/dist/plugins/devices-home-assistant/services/home-assistant-raw-event.service.js +271 -0
- package/dist/plugins/devices-home-assistant/services/home-assistant-raw-event.service.js.map +1 -0
- package/dist/plugins/devices-home-assistant/services/home-assistant.ws.service.d.ts +2 -2
- package/dist/plugins/devices-home-assistant/services/home-assistant.ws.service.js +33 -14
- package/dist/plugins/devices-home-assistant/services/home-assistant.ws.service.js.map +1 -1
- package/dist/plugins/devices-home-assistant/services/mapping-preview.service.js +24 -4
- package/dist/plugins/devices-home-assistant/services/mapping-preview.service.js.map +1 -1
- package/dist/plugins/devices-home-assistant/services/state-changed.event.service.d.ts +4 -1
- package/dist/plugins/devices-home-assistant/services/state-changed.event.service.js +84 -5
- package/dist/plugins/devices-home-assistant/services/state-changed.event.service.js.map +1 -1
- package/dist/plugins/devices-home-assistant/services/wizard.service.js +1 -0
- package/dist/plugins/devices-home-assistant/services/wizard.service.js.map +1 -1
- package/dist/plugins/devices-home-assistant/utils/ha-event.utils.d.ts +2 -0
- package/dist/plugins/devices-home-assistant/utils/ha-event.utils.js +50 -0
- package/dist/plugins/devices-home-assistant/utils/ha-event.utils.js.map +1 -0
- package/dist/plugins/devices-homekit/listeners/homekit-event.listener.d.ts +2 -0
- package/dist/plugins/devices-homekit/listeners/homekit-event.listener.js +28 -1
- package/dist/plugins/devices-homekit/listeners/homekit-event.listener.js.map +1 -1
- package/dist/plugins/devices-homekit/mappers/base.mapper.js +27 -4
- package/dist/plugins/devices-homekit/mappers/base.mapper.js.map +1 -1
- package/dist/plugins/devices-homekit/mappers/button.mapper.d.ts +15 -0
- package/dist/plugins/devices-homekit/mappers/button.mapper.js +143 -0
- package/dist/plugins/devices-homekit/mappers/button.mapper.js.map +1 -0
- package/dist/plugins/devices-homekit/mappers/homekit-mapper.interface.d.ts +16 -0
- package/dist/plugins/devices-homekit/mappers/thermostat-coordinator.d.ts +7 -0
- package/dist/plugins/devices-homekit/mappers/thermostat-coordinator.js +84 -73
- package/dist/plugins/devices-homekit/mappers/thermostat-coordinator.js.map +1 -1
- package/dist/plugins/devices-homekit/services/homekit-mapper-registry.service.d.ts +5 -1
- package/dist/plugins/devices-homekit/services/homekit-mapper-registry.service.js +42 -0
- package/dist/plugins/devices-homekit/services/homekit-mapper-registry.service.js.map +1 -1
- package/dist/plugins/devices-homey/mappings/definitions/channels.yaml +50 -0
- package/dist/plugins/devices-homey/mappings/definitions/devices.yaml +18 -0
- package/dist/plugins/devices-homey/mappings/definitions/properties.yaml +55 -0
- package/dist/plugins/devices-homey/mappings/device-support.js +10 -0
- package/dist/plugins/devices-homey/mappings/device-support.js.map +1 -1
- package/dist/plugins/devices-homey/mappings/mapping-loader.service.d.ts +1 -0
- package/dist/plugins/devices-homey/mappings/mapping-loader.service.js +66 -8
- package/dist/plugins/devices-homey/mappings/mapping-loader.service.js.map +1 -1
- package/dist/plugins/devices-homey/models/inventory.model.d.ts +2 -1
- package/dist/plugins/devices-homey/models/inventory.model.js +1 -0
- package/dist/plugins/devices-homey/models/inventory.model.js.map +1 -1
- package/dist/plugins/devices-homey/models/mapping-preview.model.d.ts +1 -0
- package/dist/plugins/devices-homey/models/mapping-preview.model.js +1 -0
- package/dist/plugins/devices-homey/models/mapping-preview.model.js.map +1 -1
- package/dist/plugins/devices-homey/services/homey-mapping-preview.service.js +7 -0
- package/dist/plugins/devices-homey/services/homey-mapping-preview.service.js.map +1 -1
- package/dist/plugins/devices-homey/services/homey-synchronizer.service.d.ts +3 -1
- package/dist/plugins/devices-homey/services/homey-synchronizer.service.js +37 -6
- package/dist/plugins/devices-homey/services/homey-synchronizer.service.js.map +1 -1
- package/dist/plugins/devices-reterminal/services/reterminal-button.service.d.ts +7 -3
- package/dist/plugins/devices-reterminal/services/reterminal-button.service.js +63 -17
- package/dist/plugins/devices-reterminal/services/reterminal-button.service.js.map +1 -1
- package/dist/plugins/devices-shelly-ng/delegates/delegates-manager.service.d.ts +38 -3
- package/dist/plugins/devices-shelly-ng/delegates/delegates-manager.service.js +840 -134
- package/dist/plugins/devices-shelly-ng/delegates/delegates-manager.service.js.map +1 -1
- package/dist/plugins/devices-shelly-ng/delegates/shelly-device.delegate.d.ts +15 -1
- package/dist/plugins/devices-shelly-ng/delegates/shelly-device.delegate.js +117 -10
- package/dist/plugins/devices-shelly-ng/delegates/shelly-device.delegate.js.map +1 -1
- package/dist/plugins/devices-shelly-ng/devices-shelly-ng.constants.js +11 -13
- package/dist/plugins/devices-shelly-ng/devices-shelly-ng.constants.js.map +1 -1
- package/dist/plugins/devices-shelly-ng/devices-shelly-ng.plugin.js +2 -0
- package/dist/plugins/devices-shelly-ng/devices-shelly-ng.plugin.js.map +1 -1
- package/dist/plugins/devices-shelly-ng/mappings/definitions/inputs.yaml +80 -0
- package/dist/plugins/devices-shelly-ng/mappings/mapping-loader.service.js +11 -1
- package/dist/plugins/devices-shelly-ng/mappings/mapping-loader.service.js.map +1 -1
- package/dist/plugins/devices-shelly-ng/mappings/mapping.types.d.ts +6 -3
- package/dist/plugins/devices-shelly-ng/mappings/schema/mapping-schema.json +5 -0
- package/dist/plugins/devices-shelly-ng/services/device-manager.service.js +130 -7
- package/dist/plugins/devices-shelly-ng/services/device-manager.service.js.map +1 -1
- package/dist/plugins/devices-shelly-ng/services/poll-placement-diagnostics.service.d.ts +48 -0
- package/dist/plugins/devices-shelly-ng/services/poll-placement-diagnostics.service.js +457 -0
- package/dist/plugins/devices-shelly-ng/services/poll-placement-diagnostics.service.js.map +1 -0
- package/dist/plugins/devices-shelly-ng/services/shelly-ng.service.d.ts +12 -2
- package/dist/plugins/devices-shelly-ng/services/shelly-ng.service.js +86 -28
- package/dist/plugins/devices-shelly-ng/services/shelly-ng.service.js.map +1 -1
- package/dist/plugins/devices-shelly-ng/services/shelly-rpc-client.service.js +3 -0
- package/dist/plugins/devices-shelly-ng/services/shelly-rpc-client.service.js.map +1 -1
- package/dist/plugins/devices-shelly-ng/services/shelly-ws-server.service.d.ts +1 -1
- package/dist/plugins/devices-shelly-ng/services/shelly-ws-server.service.js +18 -13
- package/dist/plugins/devices-shelly-ng/services/shelly-ws-server.service.js.map +1 -1
- package/dist/plugins/devices-shelly-ng/utils/transform.utils.d.ts +2 -0
- package/dist/plugins/devices-shelly-ng/utils/transform.utils.js +14 -1
- package/dist/plugins/devices-shelly-ng/utils/transform.utils.js.map +1 -1
- package/dist/plugins/devices-shelly-v1/devices-shelly-v1.constants.d.ts +2 -0
- package/dist/plugins/devices-shelly-v1/devices-shelly-v1.constants.js +66 -4
- package/dist/plugins/devices-shelly-v1/devices-shelly-v1.constants.js.map +1 -1
- package/dist/plugins/devices-shelly-v1/devices-shelly-v1.plugin.js +2 -0
- package/dist/plugins/devices-shelly-v1/devices-shelly-v1.plugin.js.map +1 -1
- package/dist/plugins/devices-shelly-v1/platforms/shelly-v1.device.platform.js +7 -0
- package/dist/plugins/devices-shelly-v1/platforms/shelly-v1.device.platform.js.map +1 -1
- package/dist/plugins/devices-shelly-v1/services/device-mapper.service.d.ts +3 -1
- package/dist/plugins/devices-shelly-v1/services/device-mapper.service.js +20 -2
- package/dist/plugins/devices-shelly-v1/services/device-mapper.service.js.map +1 -1
- package/dist/plugins/devices-shelly-v1/services/shelly-v1-input-tracker.service.d.ts +16 -0
- package/dist/plugins/devices-shelly-v1/services/shelly-v1-input-tracker.service.js +107 -0
- package/dist/plugins/devices-shelly-v1/services/shelly-v1-input-tracker.service.js.map +1 -0
- package/dist/plugins/devices-shelly-v1/services/shelly-v1.service.d.ts +7 -1
- package/dist/plugins/devices-shelly-v1/services/shelly-v1.service.js +98 -3
- package/dist/plugins/devices-shelly-v1/services/shelly-v1.service.js.map +1 -1
- package/dist/plugins/devices-third-party/controllers/third-party-inputs.controller.d.ts +17 -0
- package/dist/plugins/devices-third-party/controllers/third-party-inputs.controller.js +205 -0
- package/dist/plugins/devices-third-party/controllers/third-party-inputs.controller.js.map +1 -0
- package/dist/plugins/devices-third-party/devices-third-party.openapi.d.ts +1 -1
- package/dist/plugins/devices-third-party/devices-third-party.plugin.js +2 -1
- package/dist/plugins/devices-third-party/devices-third-party.plugin.js.map +1 -1
- package/dist/plugins/devices-third-party/dto/report-input-occurrence-response.dto.d.ts +5 -0
- package/dist/plugins/devices-third-party/dto/report-input-occurrence-response.dto.js +50 -0
- package/dist/plugins/devices-third-party/dto/report-input-occurrence-response.dto.js.map +1 -0
- package/dist/plugins/devices-third-party/dto/report-input-occurrence.dto.d.ts +8 -0
- package/dist/plugins/devices-third-party/dto/report-input-occurrence.dto.js +81 -0
- package/dist/plugins/devices-third-party/dto/report-input-occurrence.dto.js.map +1 -0
- package/dist/plugins/devices-third-party/platforms/third-party-device.platform.js +19 -4
- package/dist/plugins/devices-third-party/platforms/third-party-device.platform.js.map +1 -1
- package/dist/plugins/devices-virtual/listeners/virtual-projection.listener.d.ts +2 -0
- package/dist/plugins/devices-virtual/listeners/virtual-projection.listener.js +57 -0
- package/dist/plugins/devices-virtual/listeners/virtual-projection.listener.js.map +1 -1
- package/dist/plugins/devices-zigbee2mqtt/devices-zigbee2mqtt.constants.d.ts +3 -0
- package/dist/plugins/devices-zigbee2mqtt/devices-zigbee2mqtt.constants.js +41 -5
- package/dist/plugins/devices-zigbee2mqtt/devices-zigbee2mqtt.constants.js.map +1 -1
- package/dist/plugins/devices-zigbee2mqtt/interfaces/zigbee2mqtt.interface.d.ts +7 -1
- package/dist/plugins/devices-zigbee2mqtt/mappings/config-driven.converter.js +16 -15
- package/dist/plugins/devices-zigbee2mqtt/mappings/config-driven.converter.js.map +1 -1
- package/dist/plugins/devices-zigbee2mqtt/mappings/definitions/remotes.yaml +505 -74
- package/dist/plugins/devices-zigbee2mqtt/mappings/schema/mapping-schema.json +3 -3
- package/dist/plugins/devices-zigbee2mqtt/mappings/transformers/transformer.types.d.ts +1 -1
- package/dist/plugins/devices-zigbee2mqtt/services/base-client-adapter.d.ts +8 -2
- package/dist/plugins/devices-zigbee2mqtt/services/base-client-adapter.js +6 -5
- package/dist/plugins/devices-zigbee2mqtt/services/base-client-adapter.js.map +1 -1
- package/dist/plugins/devices-zigbee2mqtt/services/device-adoption.service.js +18 -11
- package/dist/plugins/devices-zigbee2mqtt/services/device-adoption.service.js.map +1 -1
- package/dist/plugins/devices-zigbee2mqtt/services/device-mapper.service.d.ts +9 -3
- package/dist/plugins/devices-zigbee2mqtt/services/device-mapper.service.js +166 -3
- package/dist/plugins/devices-zigbee2mqtt/services/device-mapper.service.js.map +1 -1
- package/dist/plugins/devices-zigbee2mqtt/services/mqtt-client-adapter.service.js +5 -2
- package/dist/plugins/devices-zigbee2mqtt/services/mqtt-client-adapter.service.js.map +1 -1
- package/dist/plugins/devices-zigbee2mqtt/services/zigbee2mqtt.service.d.ts +1 -0
- package/dist/plugins/devices-zigbee2mqtt/services/zigbee2mqtt.service.js +44 -4
- package/dist/plugins/devices-zigbee2mqtt/services/zigbee2mqtt.service.js.map +1 -1
- package/dist/plugins/remote-access-cloudflare-tunnel/controllers/setup.controller.d.ts +17 -0
- package/dist/plugins/remote-access-cloudflare-tunnel/controllers/setup.controller.js +147 -0
- package/dist/plugins/remote-access-cloudflare-tunnel/controllers/setup.controller.js.map +1 -0
- package/dist/plugins/remote-access-cloudflare-tunnel/controllers/status.controller.d.ts +15 -0
- package/dist/plugins/remote-access-cloudflare-tunnel/controllers/status.controller.js +98 -0
- package/dist/plugins/remote-access-cloudflare-tunnel/controllers/status.controller.js.map +1 -0
- package/dist/plugins/remote-access-cloudflare-tunnel/dto/update-config.dto.d.ts +9 -0
- package/dist/plugins/remote-access-cloudflare-tunnel/dto/update-config.dto.js +94 -0
- package/dist/plugins/remote-access-cloudflare-tunnel/dto/update-config.dto.js.map +1 -0
- package/dist/plugins/remote-access-cloudflare-tunnel/models/config.model.d.ts +9 -0
- package/dist/plugins/remote-access-cloudflare-tunnel/models/config.model.js +92 -0
- package/dist/plugins/remote-access-cloudflare-tunnel/models/config.model.js.map +1 -0
- package/dist/plugins/remote-access-cloudflare-tunnel/models/install.model.d.ts +7 -0
- package/dist/plugins/remote-access-cloudflare-tunnel/models/install.model.js +48 -0
- package/dist/plugins/remote-access-cloudflare-tunnel/models/install.model.js.map +1 -0
- package/dist/plugins/remote-access-cloudflare-tunnel/models/status.model.d.ts +42 -0
- package/dist/plugins/remote-access-cloudflare-tunnel/models/status.model.js +352 -0
- package/dist/plugins/remote-access-cloudflare-tunnel/models/status.model.js.map +1 -0
- package/dist/plugins/remote-access-cloudflare-tunnel/remote-access-cloudflare-tunnel.constants.d.ts +24 -0
- package/dist/plugins/remote-access-cloudflare-tunnel/remote-access-cloudflare-tunnel.constants.js +27 -0
- package/dist/plugins/remote-access-cloudflare-tunnel/remote-access-cloudflare-tunnel.constants.js.map +1 -0
- package/dist/plugins/remote-access-cloudflare-tunnel/remote-access-cloudflare-tunnel.exceptions.d.ts +8 -0
- package/dist/plugins/remote-access-cloudflare-tunnel/remote-access-cloudflare-tunnel.exceptions.js +19 -0
- package/dist/plugins/remote-access-cloudflare-tunnel/remote-access-cloudflare-tunnel.exceptions.js.map +1 -0
- package/dist/plugins/remote-access-cloudflare-tunnel/remote-access-cloudflare-tunnel.openapi.d.ts +4 -0
- package/dist/plugins/remote-access-cloudflare-tunnel/remote-access-cloudflare-tunnel.openapi.js +20 -0
- package/dist/plugins/remote-access-cloudflare-tunnel/remote-access-cloudflare-tunnel.openapi.js.map +1 -0
- package/dist/plugins/remote-access-cloudflare-tunnel/remote-access-cloudflare-tunnel.plugin.d.ts +21 -0
- package/dist/plugins/remote-access-cloudflare-tunnel/remote-access-cloudflare-tunnel.plugin.js +135 -0
- package/dist/plugins/remote-access-cloudflare-tunnel/remote-access-cloudflare-tunnel.plugin.js.map +1 -0
- package/dist/plugins/remote-access-cloudflare-tunnel/scripts/cloudflared-setup.sh +185 -0
- package/dist/plugins/remote-access-cloudflare-tunnel/services/cloudflare-tunnel-managed.service.d.ts +82 -0
- package/dist/plugins/remote-access-cloudflare-tunnel/services/cloudflare-tunnel-managed.service.js +507 -0
- package/dist/plugins/remote-access-cloudflare-tunnel/services/cloudflare-tunnel-managed.service.js.map +1 -0
- package/dist/plugins/remote-access-cloudflare-tunnel/services/cloudflare-tunnel-provider.service.d.ts +10 -0
- package/dist/plugins/remote-access-cloudflare-tunnel/services/cloudflare-tunnel-provider.service.js +37 -0
- package/dist/plugins/remote-access-cloudflare-tunnel/services/cloudflare-tunnel-provider.service.js.map +1 -0
- package/dist/plugins/remote-access-cloudflare-tunnel/services/cloudflare-tunnel-setup.service.d.ts +38 -0
- package/dist/plugins/remote-access-cloudflare-tunnel/services/cloudflare-tunnel-setup.service.js +147 -0
- package/dist/plugins/remote-access-cloudflare-tunnel/services/cloudflare-tunnel-setup.service.js.map +1 -0
- package/dist/plugins/remote-access-cloudflare-tunnel/services/cloudflared-cli.service.d.ts +15 -0
- package/dist/plugins/remote-access-cloudflare-tunnel/services/cloudflared-cli.service.js +67 -0
- package/dist/plugins/remote-access-cloudflare-tunnel/services/cloudflared-cli.service.js.map +1 -0
- package/dist/plugins/remote-access-cloudflare-tunnel/services/cloudflared-metrics.service.d.ts +8 -0
- package/dist/plugins/remote-access-cloudflare-tunnel/services/cloudflared-metrics.service.js +46 -0
- package/dist/plugins/remote-access-cloudflare-tunnel/services/cloudflared-metrics.service.js.map +1 -0
- package/dist/plugins/remote-access-cloudflare-tunnel/services/cloudflared-process.service.d.ts +27 -0
- package/dist/plugins/remote-access-cloudflare-tunnel/services/cloudflared-process.service.js +139 -0
- package/dist/plugins/remote-access-cloudflare-tunnel/services/cloudflared-process.service.js.map +1 -0
- package/dist/plugins/remote-access-tailscale/controllers/setup.controller.d.ts +1 -0
- package/dist/plugins/remote-access-tailscale/controllers/setup.controller.js +26 -10
- package/dist/plugins/remote-access-tailscale/controllers/setup.controller.js.map +1 -1
- package/dist/plugins/remote-access-tailscale/controllers/status.controller.d.ts +6 -1
- package/dist/plugins/remote-access-tailscale/controllers/status.controller.js +28 -3
- package/dist/plugins/remote-access-tailscale/controllers/status.controller.js.map +1 -1
- package/dist/plugins/remote-access-tailscale/models/status.model.d.ts +19 -0
- package/dist/plugins/remote-access-tailscale/models/status.model.js +158 -1
- package/dist/plugins/remote-access-tailscale/models/status.model.js.map +1 -1
- package/dist/plugins/remote-access-tailscale/remote-access-tailscale.constants.d.ts +3 -0
- package/dist/plugins/remote-access-tailscale/remote-access-tailscale.constants.js +4 -1
- package/dist/plugins/remote-access-tailscale/remote-access-tailscale.constants.js.map +1 -1
- package/dist/plugins/remote-access-tailscale/remote-access-tailscale.exceptions.d.ts +13 -0
- package/dist/plugins/remote-access-tailscale/remote-access-tailscale.exceptions.js +27 -0
- package/dist/plugins/remote-access-tailscale/remote-access-tailscale.exceptions.js.map +1 -0
- package/dist/plugins/remote-access-tailscale/remote-access-tailscale.openapi.d.ts +2 -2
- package/dist/plugins/remote-access-tailscale/remote-access-tailscale.openapi.js +2 -0
- package/dist/plugins/remote-access-tailscale/remote-access-tailscale.openapi.js.map +1 -1
- package/dist/plugins/remote-access-tailscale/remote-access-tailscale.plugin.js +1 -1
- package/dist/plugins/remote-access-tailscale/scripts/tailscale-setup.sh +61 -0
- package/dist/plugins/remote-access-tailscale/services/tailscale-cli.service.d.ts +9 -0
- package/dist/plugins/remote-access-tailscale/services/tailscale-cli.service.js +12 -0
- package/dist/plugins/remote-access-tailscale/services/tailscale-cli.service.js.map +1 -1
- package/dist/plugins/remote-access-tailscale/services/tailscale-login.service.d.ts +1 -0
- package/dist/plugins/remote-access-tailscale/services/tailscale-login.service.js +27 -2
- package/dist/plugins/remote-access-tailscale/services/tailscale-login.service.js.map +1 -1
- package/dist/plugins/remote-access-tailscale/services/tailscale-node-managed.service.d.ts +31 -1
- package/dist/plugins/remote-access-tailscale/services/tailscale-node-managed.service.js +316 -30
- package/dist/plugins/remote-access-tailscale/services/tailscale-node-managed.service.js.map +1 -1
- package/dist/plugins/remote-access-tailscale/services/tailscale-serve.service.d.ts +8 -3
- package/dist/plugins/remote-access-tailscale/services/tailscale-serve.service.js +39 -12
- package/dist/plugins/remote-access-tailscale/services/tailscale-serve.service.js.map +1 -1
- package/dist/plugins/remote-access-tailscale/services/tailscale-setup.service.d.ts +14 -5
- package/dist/plugins/remote-access-tailscale/services/tailscale-setup.service.js +51 -16
- package/dist/plugins/remote-access-tailscale/services/tailscale-setup.service.js.map +1 -1
- package/dist/plugins/scenes-local/platforms/local-scene.platform.d.ts +3 -1
- package/dist/plugins/scenes-local/platforms/local-scene.platform.js +12 -7
- package/dist/plugins/scenes-local/platforms/local-scene.platform.js.map +1 -1
- package/dist/plugins/simulator/controllers/simulator.controller.d.ts +8 -2
- package/dist/plugins/simulator/controllers/simulator.controller.js +102 -2
- package/dist/plugins/simulator/controllers/simulator.controller.js.map +1 -1
- package/dist/plugins/simulator/dto/simulate-occurrence.dto.d.ts +12 -0
- package/dist/plugins/simulator/dto/simulate-occurrence.dto.js +122 -0
- package/dist/plugins/simulator/dto/simulate-occurrence.dto.js.map +1 -0
- package/dist/plugins/simulator/models/simulator-response.model.d.ts +12 -0
- package/dist/plugins/simulator/models/simulator-response.model.js +84 -1
- package/dist/plugins/simulator/models/simulator-response.model.js.map +1 -1
- package/dist/plugins/simulator/scenarios/definitions/small-apartment.yaml +78 -0
- package/dist/plugins/simulator/services/scenario-executor.service.js +3 -1
- package/dist/plugins/simulator/services/scenario-executor.service.js.map +1 -1
- package/dist/plugins/simulator/services/simulation.service.js +10 -1
- package/dist/plugins/simulator/services/simulation.service.js.map +1 -1
- package/dist/plugins/simulator/simulator.openapi.d.ts +3 -2
- package/dist/plugins/simulator/simulator.openapi.js +5 -0
- package/dist/plugins/simulator/simulator.openapi.js.map +1 -1
- package/dist/plugins/simulator/simulators/device-simulator.interface.d.ts +2 -0
- package/dist/plugins/simulator/simulators/device-simulator.interface.js +83 -0
- package/dist/plugins/simulator/simulators/device-simulator.interface.js.map +1 -1
- package/dist/plugins/simulator/simulators/index.d.ts +1 -0
- package/dist/plugins/simulator/simulators/index.js +1 -0
- package/dist/plugins/simulator/simulators/index.js.map +1 -1
- package/dist/plugins/simulator/simulators/input-controller.simulator.d.ts +10 -0
- package/dist/plugins/simulator/simulators/input-controller.simulator.js +57 -0
- package/dist/plugins/simulator/simulators/input-controller.simulator.js.map +1 -0
- package/dist/plugins/simulator/simulators/lighting.simulator.js +1 -0
- package/dist/plugins/simulator/simulators/lighting.simulator.js.map +1 -1
- package/dist/plugins/spaces-home-control/services/climate-intent.service.d.ts +3 -1
- package/dist/plugins/spaces-home-control/services/climate-intent.service.js +6 -3
- package/dist/plugins/spaces-home-control/services/climate-intent.service.js.map +1 -1
- package/dist/plugins/spaces-home-control/services/covers-intent.service.d.ts +3 -1
- package/dist/plugins/spaces-home-control/services/covers-intent.service.js +6 -3
- package/dist/plugins/spaces-home-control/services/covers-intent.service.js.map +1 -1
- package/dist/plugins/spaces-home-control/services/lighting-intent.service.d.ts +3 -1
- package/dist/plugins/spaces-home-control/services/lighting-intent.service.js +7 -4
- package/dist/plugins/spaces-home-control/services/lighting-intent.service.js.map +1 -1
- package/dist/plugins/spaces-home-control/services/space-media-activity.service.d.ts +3 -1
- package/dist/plugins/spaces-home-control/services/space-media-activity.service.js +11 -5
- package/dist/plugins/spaces-home-control/services/space-media-activity.service.js.map +1 -1
- package/dist/plugins/spaces-home-control/services/space-undo-history.service.d.ts +3 -1
- package/dist/plugins/spaces-home-control/services/space-undo-history.service.js +8 -5
- package/dist/plugins/spaces-home-control/services/space-undo-history.service.js.map +1 -1
- package/dist/spec/channels.d.ts +51 -1
- package/dist/spec/channels.js +64 -1
- package/dist/spec/channels.js.map +1 -1
- package/dist/spec/devices.d.ts +155 -2
- package/dist/spec/devices.js +161 -2
- package/dist/spec/devices.js.map +1 -1
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/package.json +2 -2
|
@@ -0,0 +1,227 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
+
};
|
|
11
|
+
var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
12
|
+
return function (target, key) { decorator(target, key, paramIndex); }
|
|
13
|
+
};
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.PropertyCommandDispatchService = void 0;
|
|
16
|
+
const common_1 = require("@nestjs/common");
|
|
17
|
+
const devices_constants_1 = require("../devices.constants");
|
|
18
|
+
const property_value_state_model_1 = require("../models/property-value-state.model");
|
|
19
|
+
const property_command_value_utils_1 = require("../utils/property-command-value.utils");
|
|
20
|
+
const channels_properties_service_1 = require("./channels.properties.service");
|
|
21
|
+
const channels_service_1 = require("./channels.service");
|
|
22
|
+
const command_latency_trace_collector_service_1 = require("./command-latency-trace-collector.service");
|
|
23
|
+
const device_structure_lock_service_1 = require("./device-structure-lock.service");
|
|
24
|
+
const devices_service_1 = require("./devices.service");
|
|
25
|
+
const platform_registry_service_1 = require("./platform.registry.service");
|
|
26
|
+
const property_command_window_service_1 = require("./property-command-window.service");
|
|
27
|
+
const property_state_coordinator_service_1 = require("./property-state-coordinator.service");
|
|
28
|
+
const property_value_source_registry_service_1 = require("./property-value-source.registry.service");
|
|
29
|
+
let PropertyCommandDispatchService = class PropertyCommandDispatchService {
|
|
30
|
+
constructor(channelsPropertiesService, channelsService, devicesService, platformRegistryService, valueSourceRegistry, structureLock, propertyStateCoordinator, commandWindowService, commandLatencyTraceCollector = new command_latency_trace_collector_service_1.CommandLatencyTraceCollectorService()) {
|
|
31
|
+
this.channelsPropertiesService = channelsPropertiesService;
|
|
32
|
+
this.channelsService = channelsService;
|
|
33
|
+
this.devicesService = devicesService;
|
|
34
|
+
this.platformRegistryService = platformRegistryService;
|
|
35
|
+
this.valueSourceRegistry = valueSourceRegistry;
|
|
36
|
+
this.structureLock = structureLock;
|
|
37
|
+
this.propertyStateCoordinator = propertyStateCoordinator;
|
|
38
|
+
this.commandWindowService = commandWindowService;
|
|
39
|
+
this.commandLatencyTraceCollector = commandLatencyTraceCollector;
|
|
40
|
+
}
|
|
41
|
+
async dispatchBatch(updates, options = {}) {
|
|
42
|
+
if (updates.length === 0) {
|
|
43
|
+
return { success: true };
|
|
44
|
+
}
|
|
45
|
+
const platform = this.platformRegistryService.get(updates[0].device);
|
|
46
|
+
if (platform === null) {
|
|
47
|
+
return { success: false, reason: 'Unsupported device type' };
|
|
48
|
+
}
|
|
49
|
+
const handles = options.windowHandles ?? (await this.admitWindows(updates, options))?.map(({ handle }) => handle);
|
|
50
|
+
if (handles === undefined) {
|
|
51
|
+
return { success: false, reason: 'Canonical property target is invalid or conflicts within the batch' };
|
|
52
|
+
}
|
|
53
|
+
if (options.windowHandles !== undefined && !(await this.verifyPreopenedWindows(updates, handles))) {
|
|
54
|
+
this.failOwned(handles);
|
|
55
|
+
return { success: false, reason: 'Canonical property target changed before dispatch' };
|
|
56
|
+
}
|
|
57
|
+
try {
|
|
58
|
+
const success = await platform.processBatch([...updates]);
|
|
59
|
+
if (!success) {
|
|
60
|
+
this.failOwned(handles);
|
|
61
|
+
return { success: false, reason: 'Execution failed' };
|
|
62
|
+
}
|
|
63
|
+
return { success: true };
|
|
64
|
+
}
|
|
65
|
+
catch (error) {
|
|
66
|
+
this.failOwned(handles);
|
|
67
|
+
throw error;
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
async prepareApiCommand(update, ttlMs) {
|
|
71
|
+
const admitted = await this.admitWindows([update], { ttlMs });
|
|
72
|
+
const first = admitted?.[0];
|
|
73
|
+
if (first === undefined) {
|
|
74
|
+
return null;
|
|
75
|
+
}
|
|
76
|
+
return {
|
|
77
|
+
handle: first.handle,
|
|
78
|
+
canonicalPropertyId: first.admission.canonicalPropertyId,
|
|
79
|
+
baseline: first.admission.baseline,
|
|
80
|
+
optimisticEligible: first.admission.canonicalPropertyId === update.property.id && first.admission.baseline !== null,
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
async admitWindows(updates, options) {
|
|
84
|
+
return this.structureLock.runShared(async () => {
|
|
85
|
+
const requestedByCanonical = new Map();
|
|
86
|
+
for (const update of updates) {
|
|
87
|
+
const canonicalPropertyId = this.valueSourceRegistry.resolve(update.property);
|
|
88
|
+
const requested = requestedByCanonical.get(canonicalPropertyId) ?? [];
|
|
89
|
+
requested.push(update);
|
|
90
|
+
requestedByCanonical.set(canonicalPropertyId, requested);
|
|
91
|
+
}
|
|
92
|
+
const admitted = [];
|
|
93
|
+
for (const [canonicalPropertyId, requestedUpdates] of requestedByCanonical) {
|
|
94
|
+
const admission = await this.propertyStateCoordinator.run(canonicalPropertyId, async () => this.createAdmission(canonicalPropertyId, requestedUpdates));
|
|
95
|
+
if (admission === null) {
|
|
96
|
+
this.failOwned(admitted.map(({ handle }) => handle));
|
|
97
|
+
return null;
|
|
98
|
+
}
|
|
99
|
+
if (!admission.eligible) {
|
|
100
|
+
continue;
|
|
101
|
+
}
|
|
102
|
+
const handle = this.commandWindowService.open({
|
|
103
|
+
canonicalTarget: admission.canonicalTarget,
|
|
104
|
+
requestedTargets: admission.requestedTargets,
|
|
105
|
+
intentId: options.intentId,
|
|
106
|
+
commandedValue: admission.commandedValue,
|
|
107
|
+
previousValue: admission.previousValue,
|
|
108
|
+
ttlMs: options.ttlMs ?? 3_000,
|
|
109
|
+
});
|
|
110
|
+
this.commandLatencyTraceCollector.bindWindow(options.intentId, admission.canonicalPropertyId, handle.generation);
|
|
111
|
+
admitted.push({
|
|
112
|
+
handle,
|
|
113
|
+
admission,
|
|
114
|
+
});
|
|
115
|
+
}
|
|
116
|
+
return admitted;
|
|
117
|
+
});
|
|
118
|
+
}
|
|
119
|
+
async createAdmission(canonicalPropertyId, requestedUpdates) {
|
|
120
|
+
const first = requestedUpdates[0];
|
|
121
|
+
if (first === undefined) {
|
|
122
|
+
return null;
|
|
123
|
+
}
|
|
124
|
+
for (const requested of requestedUpdates) {
|
|
125
|
+
const currentRequested = await this.channelsPropertiesService.findOne(requested.property.id);
|
|
126
|
+
if (currentRequested === null || this.valueSourceRegistry.resolve(currentRequested) !== canonicalPropertyId) {
|
|
127
|
+
return null;
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
const sourceProperty = await this.channelsPropertiesService.findOne(canonicalPropertyId);
|
|
131
|
+
if (sourceProperty === null || this.valueSourceRegistry.resolve(sourceProperty) !== sourceProperty.id) {
|
|
132
|
+
return null;
|
|
133
|
+
}
|
|
134
|
+
const sourceChannelId = getEntityId(sourceProperty.channel);
|
|
135
|
+
const sourceChannel = sourceChannelId === null ? null : await this.channelsService.findOne(sourceChannelId);
|
|
136
|
+
const sourceDeviceId = sourceChannel === null ? null : getEntityId(sourceChannel.device);
|
|
137
|
+
const sourceDevice = sourceDeviceId === null ? null : await this.devicesService.findOne(sourceDeviceId);
|
|
138
|
+
if (sourceChannel === null || sourceDevice === null) {
|
|
139
|
+
return null;
|
|
140
|
+
}
|
|
141
|
+
let commandedValue;
|
|
142
|
+
for (const requested of requestedUpdates) {
|
|
143
|
+
const validation = (0, property_command_value_utils_1.validatePropertyCommandValue)(sourceProperty, requested.value);
|
|
144
|
+
if (!validation.valid || validation.value === undefined) {
|
|
145
|
+
return null;
|
|
146
|
+
}
|
|
147
|
+
if (commandedValue !== undefined && commandedValue !== validation.value) {
|
|
148
|
+
return null;
|
|
149
|
+
}
|
|
150
|
+
commandedValue = validation.value;
|
|
151
|
+
}
|
|
152
|
+
if (commandedValue === undefined) {
|
|
153
|
+
return null;
|
|
154
|
+
}
|
|
155
|
+
const requestedTargets = requestedUpdates.map(toTarget);
|
|
156
|
+
const canonicalTarget = toTarget({ device: sourceDevice, channel: sourceChannel, property: sourceProperty });
|
|
157
|
+
const writable = sourceProperty.permissions.includes(devices_constants_1.PermissionType.READ_WRITE);
|
|
158
|
+
const authoritative = this.platformRegistryService.usesAuthoritativePropertyReadback(sourceDevice, sourceProperty);
|
|
159
|
+
return {
|
|
160
|
+
canonicalPropertyId,
|
|
161
|
+
canonicalTarget,
|
|
162
|
+
requestedTargets,
|
|
163
|
+
commandedValue,
|
|
164
|
+
previousValue: sourceProperty.value?.value ?? null,
|
|
165
|
+
baseline: sourceProperty.value === null
|
|
166
|
+
? null
|
|
167
|
+
: new property_value_state_model_1.PropertyValueState(sourceProperty.value.value, sourceProperty.value.lastUpdated, sourceProperty.value.trend),
|
|
168
|
+
eligible: writable && !authoritative,
|
|
169
|
+
};
|
|
170
|
+
}
|
|
171
|
+
async verifyPreopenedWindows(updates, handles) {
|
|
172
|
+
return this.structureLock.runShared(async () => {
|
|
173
|
+
const requestedByCanonical = new Map();
|
|
174
|
+
for (const update of updates) {
|
|
175
|
+
const current = await this.channelsPropertiesService.findOne(update.property.id);
|
|
176
|
+
if (current === null) {
|
|
177
|
+
return false;
|
|
178
|
+
}
|
|
179
|
+
const canonicalPropertyId = this.valueSourceRegistry.resolve(current);
|
|
180
|
+
const requested = requestedByCanonical.get(canonicalPropertyId) ?? [];
|
|
181
|
+
requested.push({ ...update, property: current });
|
|
182
|
+
requestedByCanonical.set(canonicalPropertyId, requested);
|
|
183
|
+
}
|
|
184
|
+
if (requestedByCanonical.size !== handles.length) {
|
|
185
|
+
return false;
|
|
186
|
+
}
|
|
187
|
+
for (const [canonicalPropertyId, requestedUpdates] of requestedByCanonical) {
|
|
188
|
+
const handle = handles.find((candidate) => candidate.canonicalPropertyId === canonicalPropertyId);
|
|
189
|
+
if (handle === undefined) {
|
|
190
|
+
return false;
|
|
191
|
+
}
|
|
192
|
+
const admission = await this.propertyStateCoordinator.run(canonicalPropertyId, async () => this.createAdmission(canonicalPropertyId, requestedUpdates));
|
|
193
|
+
const window = this.commandWindowService.get(canonicalPropertyId);
|
|
194
|
+
if (admission === null || !admission.eligible || window === null || window.generation !== handle.generation) {
|
|
195
|
+
return false;
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
return true;
|
|
199
|
+
});
|
|
200
|
+
}
|
|
201
|
+
failOwned(handles) {
|
|
202
|
+
for (const handle of handles) {
|
|
203
|
+
this.commandWindowService.fail(handle);
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
};
|
|
207
|
+
exports.PropertyCommandDispatchService = PropertyCommandDispatchService;
|
|
208
|
+
exports.PropertyCommandDispatchService = PropertyCommandDispatchService = __decorate([
|
|
209
|
+
(0, common_1.Injectable)(),
|
|
210
|
+
__param(8, (0, common_1.Optional)()),
|
|
211
|
+
__metadata("design:paramtypes", [channels_properties_service_1.ChannelsPropertiesService,
|
|
212
|
+
channels_service_1.ChannelsService,
|
|
213
|
+
devices_service_1.DevicesService,
|
|
214
|
+
platform_registry_service_1.PlatformRegistryService,
|
|
215
|
+
property_value_source_registry_service_1.PropertyValueSourceRegistryService,
|
|
216
|
+
device_structure_lock_service_1.DeviceStructureLockService,
|
|
217
|
+
property_state_coordinator_service_1.PropertyStateCoordinatorService,
|
|
218
|
+
property_command_window_service_1.PropertyCommandWindowService,
|
|
219
|
+
command_latency_trace_collector_service_1.CommandLatencyTraceCollectorService])
|
|
220
|
+
], PropertyCommandDispatchService);
|
|
221
|
+
const getEntityId = (entity) => typeof entity === 'string' ? entity : (entity?.id ?? null);
|
|
222
|
+
const toTarget = ({ device, channel, property, }) => ({
|
|
223
|
+
deviceId: device.id,
|
|
224
|
+
channelId: channel.id,
|
|
225
|
+
propertyId: property.id,
|
|
226
|
+
});
|
|
227
|
+
//# sourceMappingURL=property-command-dispatch.service.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"property-command-dispatch.service.js","sourceRoot":"","sources":["../../../../src/modules/devices/services/property-command-dispatch.service.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,2CAAsD;AAEtD,4DAAsD;AACtD,qFAA0E;AAE1E,wFAA2G;AAE3G,+EAA0E;AAC1E,yDAAqD;AACrD,uGAAgG;AAChG,mFAA6E;AAC7E,uDAAmD;AACnD,2EAAsE;AACtE,uFAI2C;AAC3C,6FAAuF;AACvF,qGAA8F;AA6CvF,IAAM,8BAA8B,GAApC,MAAM,8BAA8B;IAC1C,YACkB,yBAAoD,EACpD,eAAgC,EAChC,cAA8B,EAC9B,uBAAgD,EAChD,mBAAuD,EACvD,aAAyC,EACzC,wBAAyD,EACzD,oBAAkD,EAElD,+BAAoE,IAAI,6EAAmC,EAAE;QAT7G,8BAAyB,GAAzB,yBAAyB,CAA2B;QACpD,oBAAe,GAAf,eAAe,CAAiB;QAChC,mBAAc,GAAd,cAAc,CAAgB;QAC9B,4BAAuB,GAAvB,uBAAuB,CAAyB;QAChD,wBAAmB,GAAnB,mBAAmB,CAAoC;QACvD,kBAAa,GAAb,aAAa,CAA4B;QACzC,6BAAwB,GAAxB,wBAAwB,CAAiC;QACzD,yBAAoB,GAApB,oBAAoB,CAA8B;QAElD,iCAA4B,GAA5B,4BAA4B,CAAiF;IAC5H,CAAC;IAEJ,KAAK,CAAC,aAAa,CAClB,OAAuC,EACvC,UAA0C,EAAE;QAE5C,IAAI,OAAO,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YAC1B,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;QAC1B,CAAC;QAED,MAAM,QAAQ,GAAG,IAAI,CAAC,uBAAuB,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC;QAErE,IAAI,QAAQ,KAAK,IAAI,EAAE,CAAC;YACvB,OAAO,EA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-0,0 +1,71 @@
|
|
|
1
|
+
import { PropertyValueState } from '../models/property-value-state.model';
|
|
2
|
+
import { PropertyCommandValue } from '../utils/property-command-value.utils';
|
|
3
|
+
export declare const PROPERTY_COMMAND_CONFIRMATION_GRACE_MS = 1500;
|
|
4
|
+
export type PropertyCommandWindowState = 'pending' | 'confirmed_grace';
|
|
5
|
+
export interface PropertyCommandWindowTarget {
|
|
6
|
+
readonly deviceId: string;
|
|
7
|
+
readonly channelId: string;
|
|
8
|
+
readonly propertyId: string;
|
|
9
|
+
}
|
|
10
|
+
export interface PropertyCommandWindowHandle {
|
|
11
|
+
readonly canonicalPropertyId: string;
|
|
12
|
+
readonly generation: string;
|
|
13
|
+
}
|
|
14
|
+
export interface PropertyCommandReceipt {
|
|
15
|
+
readonly value: PropertyCommandValue;
|
|
16
|
+
readonly receivedAt: number;
|
|
17
|
+
}
|
|
18
|
+
export interface PropertyCommandPatchReceipt {
|
|
19
|
+
readonly baseline: PropertyValueState;
|
|
20
|
+
readonly optimisticState: PropertyValueState;
|
|
21
|
+
}
|
|
22
|
+
export interface PropertyCommandWindow {
|
|
23
|
+
readonly canonicalTarget: PropertyCommandWindowTarget;
|
|
24
|
+
readonly requestedTargets: readonly PropertyCommandWindowTarget[];
|
|
25
|
+
readonly generation: string;
|
|
26
|
+
readonly intentId: string | null;
|
|
27
|
+
readonly commandedValue: PropertyCommandValue;
|
|
28
|
+
readonly previousValue: PropertyCommandValue | null;
|
|
29
|
+
readonly lastReceipt: PropertyCommandReceipt | null;
|
|
30
|
+
readonly heldReceipt: PropertyCommandReceipt | null;
|
|
31
|
+
readonly recoveryReceipt: PropertyCommandReceipt | null;
|
|
32
|
+
readonly rollbackBaseline: PropertyValueState | null;
|
|
33
|
+
readonly patchReceipt: PropertyCommandPatchReceipt | null;
|
|
34
|
+
readonly openedAt: number;
|
|
35
|
+
readonly expiresAt: number;
|
|
36
|
+
readonly state: PropertyCommandWindowState;
|
|
37
|
+
readonly confirmedAt: number | null;
|
|
38
|
+
readonly confirmationExpiresAt: number | null;
|
|
39
|
+
}
|
|
40
|
+
export interface OpenPropertyCommandWindowInput {
|
|
41
|
+
readonly canonicalTarget: PropertyCommandWindowTarget;
|
|
42
|
+
readonly requestedTargets: readonly PropertyCommandWindowTarget[];
|
|
43
|
+
readonly intentId?: string;
|
|
44
|
+
readonly commandedValue: PropertyCommandValue;
|
|
45
|
+
readonly previousValue: PropertyCommandValue | null;
|
|
46
|
+
readonly ttlMs: number;
|
|
47
|
+
}
|
|
48
|
+
export declare class PropertyCommandWindowService {
|
|
49
|
+
private readonly windows;
|
|
50
|
+
private readonly recoveries;
|
|
51
|
+
open(input: OpenPropertyCommandWindowInput): PropertyCommandWindowHandle;
|
|
52
|
+
get(canonicalPropertyId: string): PropertyCommandWindow | null;
|
|
53
|
+
peekGeneration(canonicalPropertyId: string): string | undefined;
|
|
54
|
+
confirm(handle: PropertyCommandWindowHandle, receipt: PropertyCommandReceipt): PropertyCommandWindow | null;
|
|
55
|
+
attachPatchReceipt(handle: PropertyCommandWindowHandle, receipt: PropertyCommandPatchReceipt): boolean;
|
|
56
|
+
hold(handle: PropertyCommandWindowHandle, receipt: PropertyCommandReceipt): PropertyCommandWindow | null;
|
|
57
|
+
close(handle: PropertyCommandWindowHandle): boolean;
|
|
58
|
+
fail(handle: PropertyCommandWindowHandle): boolean;
|
|
59
|
+
sweep(): readonly PropertyCommandWindowHandle[];
|
|
60
|
+
expire(canonicalPropertyId: string): PropertyCommandWindowHandle | null;
|
|
61
|
+
getRecovery(handle: PropertyCommandWindowHandle): PropertyCommandWindow | null;
|
|
62
|
+
completeRecovery(handle: PropertyCommandWindowHandle): boolean;
|
|
63
|
+
cancelRecovery(canonicalPropertyId: string): void;
|
|
64
|
+
cancel(canonicalPropertyId: string): void;
|
|
65
|
+
clear(): void;
|
|
66
|
+
private getCurrent;
|
|
67
|
+
private isExpired;
|
|
68
|
+
private detach;
|
|
69
|
+
private pruneRecoveries;
|
|
70
|
+
private toSnapshot;
|
|
71
|
+
}
|
|
@@ -0,0 +1,204 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
exports.PropertyCommandWindowService = exports.PROPERTY_COMMAND_CONFIRMATION_GRACE_MS = void 0;
|
|
10
|
+
const node_crypto_1 = require("node:crypto");
|
|
11
|
+
const common_1 = require("@nestjs/common");
|
|
12
|
+
const property_value_state_model_1 = require("../models/property-value-state.model");
|
|
13
|
+
exports.PROPERTY_COMMAND_CONFIRMATION_GRACE_MS = 1_500;
|
|
14
|
+
let PropertyCommandWindowService = class PropertyCommandWindowService {
|
|
15
|
+
constructor() {
|
|
16
|
+
this.windows = new Map();
|
|
17
|
+
this.recoveries = new Map();
|
|
18
|
+
}
|
|
19
|
+
open(input) {
|
|
20
|
+
const now = Date.now();
|
|
21
|
+
const canonicalPropertyId = input.canonicalTarget.propertyId;
|
|
22
|
+
const current = this.getCurrent(canonicalPropertyId, now);
|
|
23
|
+
const ttlMs = Number.isFinite(input.ttlMs) && input.ttlMs > 0 ? input.ttlMs : 3_000;
|
|
24
|
+
const generation = (0, node_crypto_1.randomUUID)();
|
|
25
|
+
const previousValue = current?.commandedValue ?? input.previousValue;
|
|
26
|
+
this.recoveries.delete(canonicalPropertyId);
|
|
27
|
+
this.windows.set(canonicalPropertyId, {
|
|
28
|
+
canonicalTarget: freezeTarget(input.canonicalTarget),
|
|
29
|
+
requestedTargets: input.requestedTargets.map(freezeTarget),
|
|
30
|
+
generation,
|
|
31
|
+
intentId: input.intentId ?? null,
|
|
32
|
+
commandedValue: input.commandedValue,
|
|
33
|
+
previousValue,
|
|
34
|
+
lastReceipt: null,
|
|
35
|
+
heldReceipt: null,
|
|
36
|
+
recoveryReceipt: null,
|
|
37
|
+
rollbackBaseline: current?.rollbackBaseline ?? current?.patchReceipt?.baseline ?? null,
|
|
38
|
+
patchReceipt: null,
|
|
39
|
+
openedAt: now,
|
|
40
|
+
expiresAt: now + ttlMs,
|
|
41
|
+
state: 'pending',
|
|
42
|
+
confirmedAt: null,
|
|
43
|
+
confirmationExpiresAt: null,
|
|
44
|
+
});
|
|
45
|
+
return Object.freeze({ canonicalPropertyId, generation });
|
|
46
|
+
}
|
|
47
|
+
get(canonicalPropertyId) {
|
|
48
|
+
return this.toSnapshot(this.getCurrent(canonicalPropertyId, Date.now()));
|
|
49
|
+
}
|
|
50
|
+
peekGeneration(canonicalPropertyId) {
|
|
51
|
+
const current = this.windows.get(canonicalPropertyId);
|
|
52
|
+
return current !== undefined && current.expiresAt > Date.now() ? current.generation : undefined;
|
|
53
|
+
}
|
|
54
|
+
confirm(handle, receipt) {
|
|
55
|
+
const current = this.getCurrent(handle.canonicalPropertyId, Date.now());
|
|
56
|
+
if (current === undefined || current.generation !== handle.generation) {
|
|
57
|
+
return null;
|
|
58
|
+
}
|
|
59
|
+
if (current.state === 'pending') {
|
|
60
|
+
current.state = 'confirmed_grace';
|
|
61
|
+
current.confirmedAt = receipt.receivedAt;
|
|
62
|
+
current.confirmationExpiresAt = receipt.receivedAt + exports.PROPERTY_COMMAND_CONFIRMATION_GRACE_MS;
|
|
63
|
+
current.lastReceipt = freezeReceipt(receipt);
|
|
64
|
+
current.heldReceipt = null;
|
|
65
|
+
current.rollbackBaseline = null;
|
|
66
|
+
current.patchReceipt = null;
|
|
67
|
+
}
|
|
68
|
+
return this.toSnapshot(current);
|
|
69
|
+
}
|
|
70
|
+
attachPatchReceipt(handle, receipt) {
|
|
71
|
+
const current = this.getCurrent(handle.canonicalPropertyId, Date.now());
|
|
72
|
+
if (current === undefined || current.generation !== handle.generation || current.state !== 'pending') {
|
|
73
|
+
return false;
|
|
74
|
+
}
|
|
75
|
+
const baseline = current.rollbackBaseline ?? receipt.baseline;
|
|
76
|
+
current.rollbackBaseline = freezeValueState(baseline);
|
|
77
|
+
current.patchReceipt = freezePatchReceipt({
|
|
78
|
+
baseline,
|
|
79
|
+
optimisticState: receipt.optimisticState,
|
|
80
|
+
});
|
|
81
|
+
return true;
|
|
82
|
+
}
|
|
83
|
+
hold(handle, receipt) {
|
|
84
|
+
const current = this.getCurrent(handle.canonicalPropertyId, Date.now());
|
|
85
|
+
if (current === undefined || current.generation !== handle.generation || current.state !== 'pending') {
|
|
86
|
+
return null;
|
|
87
|
+
}
|
|
88
|
+
current.heldReceipt = freezeReceipt(receipt);
|
|
89
|
+
return this.toSnapshot(current);
|
|
90
|
+
}
|
|
91
|
+
close(handle) {
|
|
92
|
+
const current = this.windows.get(handle.canonicalPropertyId);
|
|
93
|
+
if (current !== undefined && current.generation === handle.generation) {
|
|
94
|
+
this.windows.delete(handle.canonicalPropertyId);
|
|
95
|
+
return true;
|
|
96
|
+
}
|
|
97
|
+
return false;
|
|
98
|
+
}
|
|
99
|
+
fail(handle) {
|
|
100
|
+
const current = this.getCurrent(handle.canonicalPropertyId, Date.now());
|
|
101
|
+
if (current === undefined || current.generation !== handle.generation || current.state !== 'pending') {
|
|
102
|
+
return false;
|
|
103
|
+
}
|
|
104
|
+
this.detach(handle.canonicalPropertyId, current);
|
|
105
|
+
return true;
|
|
106
|
+
}
|
|
107
|
+
sweep() {
|
|
108
|
+
const now = Date.now();
|
|
109
|
+
for (const [canonicalPropertyId, window] of this.windows) {
|
|
110
|
+
if (!this.isExpired(window, now)) {
|
|
111
|
+
continue;
|
|
112
|
+
}
|
|
113
|
+
this.detach(canonicalPropertyId, window);
|
|
114
|
+
}
|
|
115
|
+
this.pruneRecoveries(now);
|
|
116
|
+
return Object.freeze([...this.recoveries.entries()].map(([canonicalPropertyId, recovery]) => Object.freeze({ canonicalPropertyId, generation: recovery.window.generation })));
|
|
117
|
+
}
|
|
118
|
+
expire(canonicalPropertyId) {
|
|
119
|
+
const current = this.windows.get(canonicalPropertyId);
|
|
120
|
+
if (current === undefined || !this.isExpired(current, Date.now())) {
|
|
121
|
+
return null;
|
|
122
|
+
}
|
|
123
|
+
this.detach(canonicalPropertyId, current);
|
|
124
|
+
return Object.freeze({ canonicalPropertyId, generation: current.generation });
|
|
125
|
+
}
|
|
126
|
+
getRecovery(handle) {
|
|
127
|
+
this.pruneRecoveries(Date.now());
|
|
128
|
+
const recovery = this.recoveries.get(handle.canonicalPropertyId);
|
|
129
|
+
return recovery?.window.generation === handle.generation ? this.toSnapshot(recovery.window) : null;
|
|
130
|
+
}
|
|
131
|
+
completeRecovery(handle) {
|
|
132
|
+
const recovery = this.recoveries.get(handle.canonicalPropertyId);
|
|
133
|
+
if (recovery === undefined || recovery.window.generation !== handle.generation) {
|
|
134
|
+
return false;
|
|
135
|
+
}
|
|
136
|
+
this.recoveries.delete(handle.canonicalPropertyId);
|
|
137
|
+
return true;
|
|
138
|
+
}
|
|
139
|
+
cancelRecovery(canonicalPropertyId) {
|
|
140
|
+
this.recoveries.delete(canonicalPropertyId);
|
|
141
|
+
}
|
|
142
|
+
cancel(canonicalPropertyId) {
|
|
143
|
+
this.windows.delete(canonicalPropertyId);
|
|
144
|
+
this.recoveries.delete(canonicalPropertyId);
|
|
145
|
+
}
|
|
146
|
+
clear() {
|
|
147
|
+
this.windows.clear();
|
|
148
|
+
this.recoveries.clear();
|
|
149
|
+
}
|
|
150
|
+
getCurrent(canonicalPropertyId, now) {
|
|
151
|
+
const current = this.windows.get(canonicalPropertyId);
|
|
152
|
+
if (current !== undefined && this.isExpired(current, now)) {
|
|
153
|
+
this.detach(canonicalPropertyId, current);
|
|
154
|
+
return undefined;
|
|
155
|
+
}
|
|
156
|
+
return current;
|
|
157
|
+
}
|
|
158
|
+
isExpired(window, now) {
|
|
159
|
+
return now >= (window.confirmationExpiresAt ?? window.expiresAt);
|
|
160
|
+
}
|
|
161
|
+
detach(canonicalPropertyId, window, now = Date.now()) {
|
|
162
|
+
this.windows.delete(canonicalPropertyId);
|
|
163
|
+
if (window.state === 'pending' && (window.heldReceipt !== null || window.patchReceipt !== null)) {
|
|
164
|
+
this.recoveries.set(canonicalPropertyId, {
|
|
165
|
+
window,
|
|
166
|
+
deadlineAt: now + (window.expiresAt - window.openedAt),
|
|
167
|
+
});
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
pruneRecoveries(now) {
|
|
171
|
+
for (const [canonicalPropertyId, recovery] of this.recoveries) {
|
|
172
|
+
if (now >= recovery.deadlineAt) {
|
|
173
|
+
this.recoveries.delete(canonicalPropertyId);
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
toSnapshot(window) {
|
|
178
|
+
if (window === undefined) {
|
|
179
|
+
return null;
|
|
180
|
+
}
|
|
181
|
+
return Object.freeze({
|
|
182
|
+
...window,
|
|
183
|
+
canonicalTarget: freezeTarget(window.canonicalTarget),
|
|
184
|
+
requestedTargets: Object.freeze(window.requestedTargets.map(freezeTarget)),
|
|
185
|
+
lastReceipt: window.lastReceipt === null ? null : freezeReceipt(window.lastReceipt),
|
|
186
|
+
heldReceipt: window.heldReceipt === null ? null : freezeReceipt(window.heldReceipt),
|
|
187
|
+
recoveryReceipt: window.recoveryReceipt === null ? null : freezeReceipt(window.recoveryReceipt),
|
|
188
|
+
rollbackBaseline: window.rollbackBaseline === null ? null : freezeValueState(window.rollbackBaseline),
|
|
189
|
+
patchReceipt: window.patchReceipt === null ? null : freezePatchReceipt(window.patchReceipt),
|
|
190
|
+
});
|
|
191
|
+
}
|
|
192
|
+
};
|
|
193
|
+
exports.PropertyCommandWindowService = PropertyCommandWindowService;
|
|
194
|
+
exports.PropertyCommandWindowService = PropertyCommandWindowService = __decorate([
|
|
195
|
+
(0, common_1.Injectable)()
|
|
196
|
+
], PropertyCommandWindowService);
|
|
197
|
+
const freezeTarget = (target) => Object.freeze({ ...target });
|
|
198
|
+
const freezeReceipt = (receipt) => Object.freeze({ ...receipt });
|
|
199
|
+
const freezePatchReceipt = (receipt) => Object.freeze({
|
|
200
|
+
baseline: freezeValueState(receipt.baseline),
|
|
201
|
+
optimisticState: freezeValueState(receipt.optimisticState),
|
|
202
|
+
});
|
|
203
|
+
const freezeValueState = (state) => Object.freeze(new property_value_state_model_1.PropertyValueState(state.value, state.lastUpdated, state.trend));
|
|
204
|
+
//# sourceMappingURL=property-command-window.service.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"property-command-window.service.js","sourceRoot":"","sources":["../../../../src/modules/devices/services/property-command-window.service.ts"],"names":[],"mappings":";;;;;;;;;AAAA,6CAAyC;AAEzC,2CAA4C;AAE5C,qFAA0E;AAG7D,QAAA,sCAAsC,GAAG,KAAK,CAAC;AA6ErD,IAAM,4BAA4B,GAAlC,MAAM,4BAA4B;IAAlC;QACW,YAAO,GAAG,IAAI,GAAG,EAAwC,CAAC;QAC1D,eAAU,GAAG,IAAI,GAAG,EAA0B,CAAC;IAqPjE,CAAC;IAnPA,IAAI,CAAC,KAAqC;QACzC,MAAM,GAAG,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC;QACvB,MAAM,mBAAmB,GAAG,KAAK,CAAC,eAAe,CAAC,UAAU,CAAC;QAC7D,MAAM,OAAO,GAAG,IAAI,CAAC,UAAU,CAAC,mBAAmB,EAAE,GAAG,CAAC,CAAC;QAC1D,MAAM,KAAK,GAAG,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC,KAAK,CAAC,IAAI,KAAK,CAAC,KAAK,GAAG,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC;QACpF,MAAM,UAAU,GAAG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CAAC,EAAE,GAAG,OAAO,EAAE,CAAC,CAAC;AAEjH,MAAM,kBAAkB,GAAG,CAAC,OAAoC,EAA+B,EAAE,CAChG,MAAM,CAAC,MAAM,CAAC;IACb,QAAQ,EAAE,gBAAgB,CAAC,OAAO,CAAC,QAAQ,CAAC;IAC5C,eAAe,EAAE,gBAAgB,CAAC,OAAO,CAAC,eAAe,CAAC;CAC1D,CAAC,CAAC;AAEJ,MAAM,gBAAgB,GAAG,CAAC,KAAyB,EAAsB,EAAE,CAC1E,MAAM,CAAC,MAAM,CAAC,IAAI,+CAAkB,CAAC,KAAK,CAAC,KAAK,EAAE,KAAK,CAAC,WAAW,EAAE,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC"}
|
|
@@ -2,15 +2,27 @@ import { IntentContext } from '../../intents/models/intent.model';
|
|
|
2
2
|
import { IntentsService } from '../../intents/services/intents.service';
|
|
3
3
|
import { ClientUserDto } from '../../websocket/dto/client-user.dto';
|
|
4
4
|
import { UpdateChannelPropertyDto } from '../dto/update-channel-property.dto';
|
|
5
|
-
import { ChannelPropertyEntity, DeviceEntity } from '../entities/devices.entity';
|
|
5
|
+
import { ChannelEntity, ChannelPropertyEntity, DeviceEntity } from '../entities/devices.entity';
|
|
6
|
+
import { PropertyValueState } from '../models/property-value-state.model';
|
|
6
7
|
import { PropertyCommandValue } from '../utils/property-command-value.utils';
|
|
7
8
|
import { ChannelsPropertiesService } from './channels.properties.service';
|
|
8
9
|
import { ChannelsService } from './channels.service';
|
|
10
|
+
import { CommandLatencyTraceCollectorService } from './command-latency-trace-collector.service';
|
|
9
11
|
import { DevicesService } from './devices.service';
|
|
10
12
|
import { PlatformRegistryService } from './platform.registry.service';
|
|
13
|
+
import { PropertyCommandDispatchService } from './property-command-dispatch.service';
|
|
14
|
+
import { PropertyCommandWindowHandle, PropertyCommandWindowService } from './property-command-window.service';
|
|
11
15
|
export interface PropertyCommandExecutionOptions {
|
|
12
16
|
requestId?: string;
|
|
13
17
|
context?: IntentContext;
|
|
18
|
+
apiReceipt?: ApiPropertyCommandReceipt;
|
|
19
|
+
}
|
|
20
|
+
export interface ApiPropertyCommandReceipt {
|
|
21
|
+
readonly handle: PropertyCommandWindowHandle;
|
|
22
|
+
readonly canonicalPropertyId: string;
|
|
23
|
+
readonly baseline: PropertyValueState | null;
|
|
24
|
+
readonly optimisticEligible: boolean;
|
|
25
|
+
readonly ttlMs: number;
|
|
14
26
|
}
|
|
15
27
|
export interface DevicePropertyCommandResult {
|
|
16
28
|
device: string;
|
|
@@ -33,8 +45,11 @@ export declare class PropertyCommandService {
|
|
|
33
45
|
private readonly channelsPropertiesService;
|
|
34
46
|
private readonly platformRegistryService;
|
|
35
47
|
private readonly intentsService;
|
|
48
|
+
private readonly propertyCommandDispatchService;
|
|
49
|
+
private readonly propertyCommandWindowService;
|
|
50
|
+
private readonly commandLatencyTraceCollector;
|
|
36
51
|
private readonly logger;
|
|
37
|
-
constructor(devicesService: DevicesService, channelsService: ChannelsService, channelsPropertiesService: ChannelsPropertiesService, platformRegistryService: PlatformRegistryService, intentsService: IntentsService);
|
|
52
|
+
constructor(devicesService: DevicesService, channelsService: ChannelsService, channelsPropertiesService: ChannelsPropertiesService, platformRegistryService: PlatformRegistryService, intentsService: IntentsService, propertyCommandDispatchService: PropertyCommandDispatchService, propertyCommandWindowService: PropertyCommandWindowService, commandLatencyTraceCollector?: CommandLatencyTraceCollectorService);
|
|
38
53
|
handleInternal(user: ClientUserDto, payload?: object): Promise<{
|
|
39
54
|
success: boolean;
|
|
40
55
|
results: Array<{
|
|
@@ -51,6 +66,8 @@ export declare class PropertyCommandService {
|
|
|
51
66
|
private executeCommands;
|
|
52
67
|
private resolveCommandIntentTtlMs;
|
|
53
68
|
private processDeviceCommands;
|
|
54
|
-
processApiPropertyCommand(deviceId: string, channelId: string, propertyId: string, value: string | number | boolean): Promise<void>;
|
|
69
|
+
processApiPropertyCommand(deviceId: string, channelId: string, propertyId: string, value: string | number | boolean, receipt?: ApiPropertyCommandReceipt): Promise<void>;
|
|
70
|
+
prepareApiPropertyCommand(device: DeviceEntity | string, channel: ChannelEntity, property: ChannelPropertyEntity, value: string | number | boolean): Promise<ApiPropertyCommandReceipt | null>;
|
|
71
|
+
failApiPropertyCommandReceipt(receipt: ApiPropertyCommandReceipt): void;
|
|
55
72
|
usesAuthoritativePropertyReadback(device: DeviceEntity | string, property: ChannelPropertyEntity, update?: UpdateChannelPropertyDto): Promise<boolean>;
|
|
56
73
|
}
|