@fastybird/smart-panel-backend 1.1.0-alpha.3 → 1.1.0-alpha.30
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- 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/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 +20 -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 +31 -3
- package/dist/modules/devices/services/channels.properties.service.js +346 -51
- 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 +206 -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-metadata.service.d.ts +31 -0
- package/dist/modules/devices/services/property-metadata.service.js +160 -0
- package/dist/modules/devices/services/property-metadata.service.js.map +1 -0
- 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-lock.service.d.ts +3 -1
- package/dist/modules/devices/services/property-value-lock.service.js +13 -2
- package/dist/modules/devices/services/property-value-lock.service.js.map +1 -1
- 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/platforms/raspberry.platform.js +5 -10
- package/dist/modules/platform/platforms/raspberry.platform.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 +1168 -61
- package/dist/modules/system/services/privileged-worker.service.d.ts +13 -0
- package/dist/modules/system/services/privileged-worker.service.js +192 -31
- package/dist/modules/system/services/privileged-worker.service.js.map +1 -1
- package/dist/modules/system/services/system.service.d.ts +2 -0
- package/dist/modules/system/services/system.service.js +22 -1
- package/dist/modules/system/services/system.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 +272 -26
- 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 +4 -1
- package/dist/plugins/devices-homekit/listeners/homekit-event.listener.js +39 -4
- package/dist/plugins/devices-homekit/listeners/homekit-event.listener.js.map +1 -1
- package/dist/plugins/devices-homekit/mappers/base.mapper.js +30 -6
- 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/characteristic-write.d.ts +2 -0
- package/dist/plugins/devices-homekit/mappers/characteristic-write.js +17 -0
- package/dist/plugins/devices-homekit/mappers/characteristic-write.js.map +1 -0
- package/dist/plugins/devices-homekit/mappers/homekit-mapper.interface.d.ts +17 -1
- package/dist/plugins/devices-homekit/mappers/thermostat-coordinator.d.ts +7 -0
- package/dist/plugins/devices-homekit/mappers/thermostat-coordinator.js +96 -84
- 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 +36 -3
- package/dist/plugins/devices-shelly-ng/delegates/delegates-manager.service.js +707 -42
- 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 +11 -1
- package/dist/plugins/devices-shelly-ng/delegates/shelly-device.delegate.js +100 -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 +9 -11
- 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 +7 -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 +153 -8
- 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 +51 -0
- package/dist/plugins/devices-shelly-ng/services/poll-placement-diagnostics.service.js +549 -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 +14 -2
- package/dist/plugins/devices-shelly-ng/services/shelly-ng.service.js +134 -35
- 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 -0
- package/dist/plugins/devices-shelly-ng/services/shelly-ws-server.service.js +14 -4
- package/dist/plugins/devices-shelly-ng/services/shelly-ws-server.service.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 +3 -3
|
@@ -0,0 +1,451 @@
|
|
|
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
|
+
var CommandLatencyTraceCollectorService_1;
|
|
15
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
16
|
+
exports.CommandLatencyTraceCollectorService = exports.COMMAND_LATENCY_TRACE_OPTIONS = void 0;
|
|
17
|
+
const node_async_hooks_1 = require("node:async_hooks");
|
|
18
|
+
const node_crypto_1 = require("node:crypto");
|
|
19
|
+
const node_fs_1 = require("node:fs");
|
|
20
|
+
const promises_1 = require("node:fs/promises");
|
|
21
|
+
const node_perf_hooks_1 = require("node:perf_hooks");
|
|
22
|
+
const common_1 = require("@nestjs/common");
|
|
23
|
+
exports.COMMAND_LATENCY_TRACE_OPTIONS = Symbol('COMMAND_LATENCY_TRACE_OPTIONS');
|
|
24
|
+
const MAX_CAPTURE_DURATION_MS = 30_000;
|
|
25
|
+
const MAX_CAPTURE_RECORDS = 4_096;
|
|
26
|
+
let CommandLatencyTraceCollectorService = CommandLatencyTraceCollectorService_1 = class CommandLatencyTraceCollectorService {
|
|
27
|
+
constructor(options) {
|
|
28
|
+
this.context = new node_async_hooks_1.AsyncLocalStorage();
|
|
29
|
+
this.trialsByIntent = new Map();
|
|
30
|
+
this.trialsByGeneration = new Map();
|
|
31
|
+
this.captures = [];
|
|
32
|
+
this.pendingExports = new Set();
|
|
33
|
+
this.exportTasks = new Set();
|
|
34
|
+
this.recordCount = 0;
|
|
35
|
+
this.overflowed = false;
|
|
36
|
+
this.config = normalizeConfig(options ?? parseEnvironmentConfig());
|
|
37
|
+
this.collectorHash = CommandLatencyTraceCollectorService_1.getSourceHash();
|
|
38
|
+
}
|
|
39
|
+
static getSourceHash() {
|
|
40
|
+
try {
|
|
41
|
+
return (0, node_crypto_1.createHash)('sha256').update((0, node_fs_1.readFileSync)(__filename, 'utf8')).digest('hex');
|
|
42
|
+
}
|
|
43
|
+
catch {
|
|
44
|
+
return (0, node_crypto_1.createHash)('sha256').update(CommandLatencyTraceCollectorService_1.toString()).digest('hex');
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
isEnabled() {
|
|
48
|
+
return this.config !== null && !this.overflowed;
|
|
49
|
+
}
|
|
50
|
+
observeCommand(command) {
|
|
51
|
+
if (!this.isEnabled() || !command.requestId || this.config === null) {
|
|
52
|
+
return;
|
|
53
|
+
}
|
|
54
|
+
this.expireDueTrials();
|
|
55
|
+
const matching = command.properties.filter((property) => property.property === this.config.sourcePropertyId || property.property === this.config.projectionPropertyId);
|
|
56
|
+
if (matching.length !== 1) {
|
|
57
|
+
return;
|
|
58
|
+
}
|
|
59
|
+
const selected = matching[0];
|
|
60
|
+
if (selected === undefined || this.trialsByIntent.has(command.intentId)) {
|
|
61
|
+
return;
|
|
62
|
+
}
|
|
63
|
+
const startedAtMs = this.now();
|
|
64
|
+
const expiryTimer = setTimeout(() => this.expireTrial(command.intentId), this.config.captureDurationMs);
|
|
65
|
+
expiryTimer.unref();
|
|
66
|
+
const trial = {
|
|
67
|
+
trialId: command.requestId,
|
|
68
|
+
intentId: command.intentId,
|
|
69
|
+
requestedPropertyId: selected.property,
|
|
70
|
+
commandValue: selected.value,
|
|
71
|
+
startedAtMs,
|
|
72
|
+
expiryTimer,
|
|
73
|
+
pendingRecords: [],
|
|
74
|
+
completed: false,
|
|
75
|
+
activeInvocationCount: 0,
|
|
76
|
+
};
|
|
77
|
+
this.trialsByIntent.set(trial.intentId, trial);
|
|
78
|
+
this.recordTrial(trial, 'command-received', undefined, { requestedPropertyId: selected.property });
|
|
79
|
+
}
|
|
80
|
+
bindWindow(intentId, sourcePropertyId, windowGeneration) {
|
|
81
|
+
if (!this.isEnabled() || !intentId || this.config === null || sourcePropertyId !== this.config.sourcePropertyId) {
|
|
82
|
+
return;
|
|
83
|
+
}
|
|
84
|
+
this.expireDueTrials();
|
|
85
|
+
const trial = this.trialsByIntent.get(intentId);
|
|
86
|
+
if (trial === undefined || trial.completed) {
|
|
87
|
+
return;
|
|
88
|
+
}
|
|
89
|
+
if (trial.windowGeneration !== undefined && trial.windowGeneration !== windowGeneration) {
|
|
90
|
+
this.finishTrial(trial, 'error', 'A validation trial was bound to more than one command-window generation.');
|
|
91
|
+
return;
|
|
92
|
+
}
|
|
93
|
+
const colliding = this.trialsByGeneration.get(windowGeneration);
|
|
94
|
+
if (colliding !== undefined && colliding !== trial) {
|
|
95
|
+
this.finishTrial(colliding, 'error', 'A command-window generation was correlated to multiple validation trials.');
|
|
96
|
+
this.finishTrial(trial, 'error', 'A command-window generation was correlated to multiple validation trials.');
|
|
97
|
+
return;
|
|
98
|
+
}
|
|
99
|
+
trial.windowGeneration = windowGeneration;
|
|
100
|
+
this.trialsByGeneration.set(windowGeneration, trial);
|
|
101
|
+
this.recordTrial(trial, 'window-bound');
|
|
102
|
+
}
|
|
103
|
+
recordProviderReceipt(propertyId, value, origin, metadata) {
|
|
104
|
+
const trial = this.getBoundTrial(propertyId);
|
|
105
|
+
if (trial === null) {
|
|
106
|
+
return;
|
|
107
|
+
}
|
|
108
|
+
this.recordTrial(trial, 'provider-receipt', undefined, { origin, receivedValue: value, ...metadata });
|
|
109
|
+
}
|
|
110
|
+
recordPollActivity(propertyId, stage, metadata) {
|
|
111
|
+
const trial = this.getBoundTrial(propertyId);
|
|
112
|
+
if (trial !== null) {
|
|
113
|
+
this.recordTrial(trial, stage, undefined, metadata);
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
recordPollRpc(deviceId, stage, metadata) {
|
|
117
|
+
if (!this.isEnabled() || this.config?.sourceDeviceId !== deviceId) {
|
|
118
|
+
return;
|
|
119
|
+
}
|
|
120
|
+
for (const trial of this.trialsByGeneration.values()) {
|
|
121
|
+
if (!trial.completed) {
|
|
122
|
+
this.recordTrial(trial, stage, undefined, { deviceId, ...metadata });
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
async traceUpdate(input, callback) {
|
|
127
|
+
const invocation = this.beginInvocation(input);
|
|
128
|
+
if (invocation === null) {
|
|
129
|
+
return callback();
|
|
130
|
+
}
|
|
131
|
+
return this.context.run(invocation, async () => {
|
|
132
|
+
try {
|
|
133
|
+
const result = await callback();
|
|
134
|
+
this.finishInvocation(invocation);
|
|
135
|
+
return result;
|
|
136
|
+
}
|
|
137
|
+
catch (error) {
|
|
138
|
+
invocation.status = 'error';
|
|
139
|
+
invocation.failureReason = error instanceof Error ? error.message : 'Unknown update failure';
|
|
140
|
+
this.recordInvocation(invocation, 'update-error', { reason: invocation.failureReason });
|
|
141
|
+
this.finishInvocation(invocation);
|
|
142
|
+
throw error;
|
|
143
|
+
}
|
|
144
|
+
});
|
|
145
|
+
}
|
|
146
|
+
recordWriteComplete(property, metadata) {
|
|
147
|
+
this.recordCurrentInvocation('write-complete', property.id, metadata);
|
|
148
|
+
}
|
|
149
|
+
recordSuppressed(property, reason) {
|
|
150
|
+
const invocation = this.context.getStore();
|
|
151
|
+
if (invocation === undefined || property.id !== this.config?.sourcePropertyId) {
|
|
152
|
+
return;
|
|
153
|
+
}
|
|
154
|
+
invocation.status = 'suppressed';
|
|
155
|
+
this.recordInvocation(invocation, 'suppressed', { reason });
|
|
156
|
+
}
|
|
157
|
+
recordSourcePublication(property) {
|
|
158
|
+
const invocation = this.context.getStore() ?? this.getActiveInvocation(property.id);
|
|
159
|
+
if (invocation === undefined || property.id !== this.config?.sourcePropertyId) {
|
|
160
|
+
return;
|
|
161
|
+
}
|
|
162
|
+
const publishedValue = property.value?.value;
|
|
163
|
+
if (publishedValue !== invocation.trial.commandValue) {
|
|
164
|
+
invocation.status = 'error';
|
|
165
|
+
invocation.failureReason = 'Canonical source publication did not match the commanded value.';
|
|
166
|
+
this.recordInvocation(invocation, 'update-error', { reason: invocation.failureReason, publishedValue });
|
|
167
|
+
return;
|
|
168
|
+
}
|
|
169
|
+
this.recordInvocation(invocation, 'source-publication');
|
|
170
|
+
this.recordInvocation(invocation, 'update-complete');
|
|
171
|
+
this.finishTrial(invocation.trial, 'complete', undefined, invocation);
|
|
172
|
+
}
|
|
173
|
+
getCaptures() {
|
|
174
|
+
this.expireDueTrials();
|
|
175
|
+
return this.captures.map((capture) => ({ ...capture, records: [...capture.records] }));
|
|
176
|
+
}
|
|
177
|
+
async waitForExports() {
|
|
178
|
+
await Promise.all([...this.exportTasks]);
|
|
179
|
+
}
|
|
180
|
+
onModuleDestroy() {
|
|
181
|
+
for (const trial of [...this.trialsByIntent.values()]) {
|
|
182
|
+
this.finishTrial(trial, 'shutdown', 'The backend stopped before the validation capture completed.');
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
beginInvocation(input) {
|
|
186
|
+
const trial = this.getBoundTrial(input.propertyId, input.windowGeneration);
|
|
187
|
+
if (trial === null || input.value === undefined) {
|
|
188
|
+
return null;
|
|
189
|
+
}
|
|
190
|
+
if (trial.activeInvocationCount > 0) {
|
|
191
|
+
this.finishTrial(trial, 'error', 'Concurrent provider updates share one command-window generation; server evidence is ambiguous.');
|
|
192
|
+
return null;
|
|
193
|
+
}
|
|
194
|
+
const invocation = {
|
|
195
|
+
invocationId: (0, node_crypto_1.randomUUID)(),
|
|
196
|
+
trial,
|
|
197
|
+
records: trial.pendingRecords.splice(0),
|
|
198
|
+
status: 'pending',
|
|
199
|
+
};
|
|
200
|
+
trial.activeInvocationCount++;
|
|
201
|
+
trial.activeInvocation = invocation;
|
|
202
|
+
this.recordInvocation(invocation, 'update-entry', { receivedValue: input.value });
|
|
203
|
+
return invocation;
|
|
204
|
+
}
|
|
205
|
+
finishInvocation(invocation) {
|
|
206
|
+
invocation.trial.activeInvocationCount = Math.max(0, invocation.trial.activeInvocationCount - 1);
|
|
207
|
+
if (invocation.trial.activeInvocation === invocation) {
|
|
208
|
+
invocation.trial.activeInvocation = undefined;
|
|
209
|
+
}
|
|
210
|
+
if (invocation.trial.completed) {
|
|
211
|
+
return;
|
|
212
|
+
}
|
|
213
|
+
const published = invocation.records.some((record) => record.stage === 'source-publication');
|
|
214
|
+
if (invocation.status === 'pending' && published) {
|
|
215
|
+
this.recordInvocation(invocation, 'update-complete');
|
|
216
|
+
this.finishTrial(invocation.trial, 'complete', undefined, invocation);
|
|
217
|
+
return;
|
|
218
|
+
}
|
|
219
|
+
if (invocation.status === 'suppressed') {
|
|
220
|
+
this.finishTrial(invocation.trial, 'suppressed', undefined, invocation, false);
|
|
221
|
+
return;
|
|
222
|
+
}
|
|
223
|
+
if (invocation.status === 'error') {
|
|
224
|
+
this.finishTrial(invocation.trial, 'error', invocation.failureReason, invocation);
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
getActiveInvocation(propertyId) {
|
|
228
|
+
if (!this.isEnabled() || propertyId !== this.config?.sourcePropertyId) {
|
|
229
|
+
return undefined;
|
|
230
|
+
}
|
|
231
|
+
const candidates = [...this.trialsByGeneration.values()]
|
|
232
|
+
.filter((trial) => !trial.completed && trial.activeInvocation !== undefined)
|
|
233
|
+
.map((trial) => trial.activeInvocation)
|
|
234
|
+
.filter((invocation) => invocation !== undefined);
|
|
235
|
+
return candidates.length === 1 ? candidates[0] : undefined;
|
|
236
|
+
}
|
|
237
|
+
recordCurrentInvocation(stage, propertyId, metadata) {
|
|
238
|
+
const invocation = this.context.getStore();
|
|
239
|
+
if (invocation !== undefined && propertyId === this.config?.sourcePropertyId) {
|
|
240
|
+
this.recordInvocation(invocation, stage, metadata);
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
getBoundTrial(propertyId, windowGeneration) {
|
|
244
|
+
if (!this.isEnabled() || this.config === null || propertyId !== this.config.sourcePropertyId) {
|
|
245
|
+
return null;
|
|
246
|
+
}
|
|
247
|
+
this.expireDueTrials();
|
|
248
|
+
if (windowGeneration !== undefined) {
|
|
249
|
+
return this.trialsByGeneration.get(windowGeneration) ?? null;
|
|
250
|
+
}
|
|
251
|
+
const candidates = [...this.trialsByGeneration.values()].filter((trial) => !trial.completed);
|
|
252
|
+
return candidates.length === 1 ? (candidates[0] ?? null) : null;
|
|
253
|
+
}
|
|
254
|
+
recordTrial(trial, stage, invocationId, metadata) {
|
|
255
|
+
const record = this.createRecord(trial, stage, invocationId, metadata);
|
|
256
|
+
if (!this.acceptRecord(record)) {
|
|
257
|
+
return null;
|
|
258
|
+
}
|
|
259
|
+
if (invocationId === undefined) {
|
|
260
|
+
const activeInvocation = trial.activeInvocation;
|
|
261
|
+
if (activeInvocation !== undefined && !trial.completed && trial.activeInvocationCount === 1) {
|
|
262
|
+
this.appendRecord(activeInvocation.records, record);
|
|
263
|
+
}
|
|
264
|
+
else {
|
|
265
|
+
this.appendRecord(trial.pendingRecords, record);
|
|
266
|
+
}
|
|
267
|
+
}
|
|
268
|
+
return record;
|
|
269
|
+
}
|
|
270
|
+
appendRecord(records, record) {
|
|
271
|
+
let index = records.length;
|
|
272
|
+
while (index > 0 && records[index - 1].timestampMs > record.timestampMs) {
|
|
273
|
+
index--;
|
|
274
|
+
}
|
|
275
|
+
records.splice(index, 0, record);
|
|
276
|
+
}
|
|
277
|
+
recordInvocation(invocation, stage, metadata) {
|
|
278
|
+
if (invocation.trial.completed) {
|
|
279
|
+
return;
|
|
280
|
+
}
|
|
281
|
+
const record = this.recordTrial(invocation.trial, stage, invocation.invocationId, metadata);
|
|
282
|
+
if (record !== null) {
|
|
283
|
+
invocation.records.push(record);
|
|
284
|
+
}
|
|
285
|
+
}
|
|
286
|
+
createRecord(trial, stage, invocationId, metadata) {
|
|
287
|
+
if (this.config === null) {
|
|
288
|
+
throw new Error('Cannot create a command latency trace record while capture is disabled.');
|
|
289
|
+
}
|
|
290
|
+
return Object.freeze({
|
|
291
|
+
stage,
|
|
292
|
+
timestampMs: this.now(),
|
|
293
|
+
processId: process.pid,
|
|
294
|
+
runId: this.config.runId,
|
|
295
|
+
trialId: trial.trialId,
|
|
296
|
+
invocationId,
|
|
297
|
+
sourcePropertyId: this.config.sourcePropertyId,
|
|
298
|
+
projectionPropertyId: this.config.projectionPropertyId,
|
|
299
|
+
commandValue: trial.commandValue,
|
|
300
|
+
intentId: trial.intentId,
|
|
301
|
+
windowGeneration: trial.windowGeneration,
|
|
302
|
+
metadata: metadata === undefined ? undefined : Object.freeze({ ...metadata }),
|
|
303
|
+
});
|
|
304
|
+
}
|
|
305
|
+
acceptRecord(_record) {
|
|
306
|
+
if (this.overflowed) {
|
|
307
|
+
return false;
|
|
308
|
+
}
|
|
309
|
+
if (this.recordCount >= (this.config?.maxRecords ?? 0)) {
|
|
310
|
+
this.overflowed = true;
|
|
311
|
+
for (const trial of [...this.trialsByIntent.values()]) {
|
|
312
|
+
this.finishTrial(trial, 'overflow', 'The bounded command latency capture exceeded its record limit.');
|
|
313
|
+
}
|
|
314
|
+
return false;
|
|
315
|
+
}
|
|
316
|
+
this.recordCount++;
|
|
317
|
+
return true;
|
|
318
|
+
}
|
|
319
|
+
finishTrial(trial, status, failureReason, invocation, finalize = true) {
|
|
320
|
+
if (trial.completed && finalize) {
|
|
321
|
+
return;
|
|
322
|
+
}
|
|
323
|
+
const records = invocation?.records ?? trial.pendingRecords;
|
|
324
|
+
const capture = Object.freeze({
|
|
325
|
+
schemaVersion: 1,
|
|
326
|
+
clock: 'backend-performance-now-v1',
|
|
327
|
+
collectorHash: this.collectorHash,
|
|
328
|
+
processId: process.pid,
|
|
329
|
+
runId: this.config?.runId ?? 'disabled',
|
|
330
|
+
trialId: trial.trialId,
|
|
331
|
+
invocationId: invocation?.invocationId,
|
|
332
|
+
sourcePropertyId: this.config?.sourcePropertyId ?? '',
|
|
333
|
+
projectionPropertyId: this.config?.projectionPropertyId,
|
|
334
|
+
commandValue: trial.commandValue,
|
|
335
|
+
intentId: trial.intentId,
|
|
336
|
+
windowGeneration: trial.windowGeneration,
|
|
337
|
+
status,
|
|
338
|
+
failureReason,
|
|
339
|
+
records: Object.freeze([...records]),
|
|
340
|
+
});
|
|
341
|
+
this.captures.push(capture);
|
|
342
|
+
this.scheduleExport(capture);
|
|
343
|
+
if (!finalize) {
|
|
344
|
+
return;
|
|
345
|
+
}
|
|
346
|
+
trial.completed = true;
|
|
347
|
+
trial.activeInvocation = undefined;
|
|
348
|
+
clearTimeout(trial.expiryTimer);
|
|
349
|
+
this.trialsByIntent.delete(trial.intentId);
|
|
350
|
+
if (trial.windowGeneration !== undefined && this.trialsByGeneration.get(trial.windowGeneration) === trial) {
|
|
351
|
+
this.trialsByGeneration.delete(trial.windowGeneration);
|
|
352
|
+
}
|
|
353
|
+
}
|
|
354
|
+
expireDueTrials() {
|
|
355
|
+
const captureDurationMs = this.config?.captureDurationMs;
|
|
356
|
+
if (captureDurationMs === undefined) {
|
|
357
|
+
return;
|
|
358
|
+
}
|
|
359
|
+
const now = this.now();
|
|
360
|
+
for (const trial of [...this.trialsByIntent.values()]) {
|
|
361
|
+
if (now - trial.startedAtMs >= captureDurationMs) {
|
|
362
|
+
this.finishTrial(trial, 'expired', `The ${captureDurationMs}ms validation capture window elapsed before source publication.`);
|
|
363
|
+
}
|
|
364
|
+
}
|
|
365
|
+
}
|
|
366
|
+
expireTrial(intentId) {
|
|
367
|
+
const captureDurationMs = this.config?.captureDurationMs;
|
|
368
|
+
const trial = this.trialsByIntent.get(intentId);
|
|
369
|
+
if (trial !== undefined && captureDurationMs !== undefined) {
|
|
370
|
+
this.finishTrial(trial, 'expired', `The ${captureDurationMs}ms validation capture window elapsed before source publication.`);
|
|
371
|
+
}
|
|
372
|
+
}
|
|
373
|
+
now() {
|
|
374
|
+
return node_perf_hooks_1.performance.now();
|
|
375
|
+
}
|
|
376
|
+
scheduleExport(capture) {
|
|
377
|
+
if (!this.config?.exportPath) {
|
|
378
|
+
return;
|
|
379
|
+
}
|
|
380
|
+
this.pendingExports.add(capture);
|
|
381
|
+
const task = new Promise((resolve) => {
|
|
382
|
+
setImmediate(() => {
|
|
383
|
+
void (0, promises_1.appendFile)(this.config?.exportPath ?? '', `${JSON.stringify(capture)}\n`, 'utf8')
|
|
384
|
+
.catch(() => {
|
|
385
|
+
this.replaceCaptureAfterSinkFailure(capture);
|
|
386
|
+
})
|
|
387
|
+
.finally(() => {
|
|
388
|
+
this.pendingExports.delete(capture);
|
|
389
|
+
this.exportTasks.delete(task);
|
|
390
|
+
resolve();
|
|
391
|
+
});
|
|
392
|
+
});
|
|
393
|
+
});
|
|
394
|
+
this.exportTasks.add(task);
|
|
395
|
+
}
|
|
396
|
+
replaceCaptureAfterSinkFailure(capture) {
|
|
397
|
+
const index = this.captures.indexOf(capture);
|
|
398
|
+
if (index === -1) {
|
|
399
|
+
return;
|
|
400
|
+
}
|
|
401
|
+
this.captures[index] = Object.freeze({
|
|
402
|
+
...capture,
|
|
403
|
+
status: 'error',
|
|
404
|
+
failureReason: 'The private command latency capture sink failed to export this report.',
|
|
405
|
+
});
|
|
406
|
+
}
|
|
407
|
+
};
|
|
408
|
+
exports.CommandLatencyTraceCollectorService = CommandLatencyTraceCollectorService;
|
|
409
|
+
exports.CommandLatencyTraceCollectorService = CommandLatencyTraceCollectorService = CommandLatencyTraceCollectorService_1 = __decorate([
|
|
410
|
+
(0, common_1.Injectable)(),
|
|
411
|
+
__param(0, (0, common_1.Optional)()),
|
|
412
|
+
__param(0, (0, common_1.Inject)(exports.COMMAND_LATENCY_TRACE_OPTIONS)),
|
|
413
|
+
__metadata("design:paramtypes", [Object])
|
|
414
|
+
], CommandLatencyTraceCollectorService);
|
|
415
|
+
function parseEnvironmentConfig() {
|
|
416
|
+
const raw = process.env.FB_COMMAND_LATENCY_CAPTURE;
|
|
417
|
+
if (!raw) {
|
|
418
|
+
return null;
|
|
419
|
+
}
|
|
420
|
+
try {
|
|
421
|
+
return JSON.parse(raw);
|
|
422
|
+
}
|
|
423
|
+
catch {
|
|
424
|
+
return null;
|
|
425
|
+
}
|
|
426
|
+
}
|
|
427
|
+
function normalizeConfig(config) {
|
|
428
|
+
if (config === null ||
|
|
429
|
+
!isNonEmptyString(config.runId) ||
|
|
430
|
+
!isNonEmptyString(config.sourcePropertyId) ||
|
|
431
|
+
(config.projectionPropertyId !== undefined && !isNonEmptyString(config.projectionPropertyId)) ||
|
|
432
|
+
(config.sourceDeviceId !== undefined && !isNonEmptyString(config.sourceDeviceId)) ||
|
|
433
|
+
(config.exportPath !== undefined && !isNonEmptyString(config.exportPath))) {
|
|
434
|
+
return null;
|
|
435
|
+
}
|
|
436
|
+
const captureDurationMs = config.captureDurationMs ?? MAX_CAPTURE_DURATION_MS;
|
|
437
|
+
const maxRecords = config.maxRecords ?? MAX_CAPTURE_RECORDS;
|
|
438
|
+
if (!Number.isInteger(captureDurationMs) ||
|
|
439
|
+
captureDurationMs <= 0 ||
|
|
440
|
+
captureDurationMs > MAX_CAPTURE_DURATION_MS ||
|
|
441
|
+
!Number.isInteger(maxRecords) ||
|
|
442
|
+
maxRecords <= 0 ||
|
|
443
|
+
maxRecords > MAX_CAPTURE_RECORDS) {
|
|
444
|
+
return null;
|
|
445
|
+
}
|
|
446
|
+
return Object.freeze({ ...config, captureDurationMs, maxRecords });
|
|
447
|
+
}
|
|
448
|
+
function isNonEmptyString(value) {
|
|
449
|
+
return typeof value === 'string' && value.trim().length > 0;
|
|
450
|
+
}
|
|
451
|
+
//# sourceMappingURL=command-latency-trace-collector.service.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"command-latency-trace-collector.service.js","sourceRoot":"","sources":["../../../../src/modules/devices/services/command-latency-trace-collector.service.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,uDAAqD;AACrD,6CAAqD;AACrD,qCAAuC;AACvC,+CAA8C;AAC9C,qDAA8C;AAE9C,2CAA+E;AAqBlE,QAAA,6BAA6B,GAAG,MAAM,CAAC,+BAA+B,CAAC,CAAC;AAoFrF,MAAM,uBAAuB,GAAG,MAAM,CAAC;AACvC,MAAM,mBAAmB,GAAG,KAAK,CAAC;AAW3B,IAAM,mCAAmC,2CAAzC,MAAM,mCAAmC;IAc/C,YAGC,OAA0C;QAb1B,YAAO,GAAG,IAAI,oCAAiB,EAAmB,CAAC;QACnD,mBAAc,GAAG,IAAI,GAAG,EAAuB,CAAC;QAChD,uBAAkB,GAAG,IAAI,GAAG,EAAuB,CAAC;QACpD,aAAQ,GAAiC,EAAE,CAAC;QAC5C,mBAAc,GAAG,IAAI,GAAG,EAA8B,CAAC;QACvD,gBAAW,GAAG,IAAI,GAAG,EAAiB,CAAC;QAEhD,gBAAW,GAAG,CAAC,CAAC;QAChB,eAAU,GAAG,KAAK,CAAC;QAO1B,IAAI,CAAC,MAAM,GAAG,eAAe,CAAC,OAAO,IAAI,sBAAsB,EAAE,CAAC,CAAC;QACnE,IAAI,CAAC,aAAa,GAAG,qCAAmC,CAAC,aAAa,EAAE,CAAC;IAC1E,CAAC;IAED,MAAM,CAAC,aAAa;QACnB,IAAI,CAAC;YACJ,OAAO,IAAA,wBAAU,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,CAAC,IAAI,EAAE,CAAC,MAAM,GAAG,CAAC,CAAC;AAC7D,CAAC"}
|
|
@@ -1,5 +1,13 @@
|
|
|
1
1
|
export declare class DeviceStructureLockService {
|
|
2
|
-
private readonly
|
|
3
|
-
private
|
|
2
|
+
private readonly context;
|
|
3
|
+
private readonly queue;
|
|
4
|
+
private activeReaders;
|
|
5
|
+
private writerActive;
|
|
6
|
+
runShared<T>(fn: () => Promise<T>): Promise<T>;
|
|
4
7
|
runExclusive<T>(fn: () => Promise<T>): Promise<T>;
|
|
8
|
+
private enqueue;
|
|
9
|
+
private drain;
|
|
10
|
+
private execute;
|
|
11
|
+
private runNested;
|
|
12
|
+
private waitForNestedOperations;
|
|
5
13
|
}
|
|
@@ -11,16 +11,95 @@ const node_async_hooks_1 = require("node:async_hooks");
|
|
|
11
11
|
const common_1 = require("@nestjs/common");
|
|
12
12
|
let DeviceStructureLockService = class DeviceStructureLockService {
|
|
13
13
|
constructor() {
|
|
14
|
-
this.
|
|
15
|
-
this.
|
|
14
|
+
this.context = new node_async_hooks_1.AsyncLocalStorage();
|
|
15
|
+
this.queue = [];
|
|
16
|
+
this.activeReaders = 0;
|
|
17
|
+
this.writerActive = false;
|
|
18
|
+
}
|
|
19
|
+
async runShared(fn) {
|
|
20
|
+
const context = this.context.getStore();
|
|
21
|
+
if (context?.active) {
|
|
22
|
+
return this.runNested(context, fn);
|
|
23
|
+
}
|
|
24
|
+
return this.enqueue('shared', fn);
|
|
16
25
|
}
|
|
17
26
|
async runExclusive(fn) {
|
|
18
|
-
|
|
19
|
-
|
|
27
|
+
const context = this.context.getStore();
|
|
28
|
+
if (context?.active) {
|
|
29
|
+
if (context.mode === 'shared') {
|
|
30
|
+
throw new Error('Device structure lock cannot be upgraded from shared to exclusive');
|
|
31
|
+
}
|
|
32
|
+
return this.runNested(context, fn);
|
|
33
|
+
}
|
|
34
|
+
return this.enqueue('exclusive', fn);
|
|
35
|
+
}
|
|
36
|
+
enqueue(mode, fn) {
|
|
37
|
+
return new Promise((resolve, reject) => {
|
|
38
|
+
this.queue.push({ mode, fn, resolve, reject });
|
|
39
|
+
this.drain();
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
drain() {
|
|
43
|
+
if (this.writerActive || this.queue.length === 0) {
|
|
44
|
+
return;
|
|
45
|
+
}
|
|
46
|
+
const next = this.queue[0];
|
|
47
|
+
if (next.mode === 'exclusive') {
|
|
48
|
+
if (this.activeReaders !== 0) {
|
|
49
|
+
return;
|
|
50
|
+
}
|
|
51
|
+
this.queue.shift();
|
|
52
|
+
this.writerActive = true;
|
|
53
|
+
this.execute(next);
|
|
54
|
+
return;
|
|
55
|
+
}
|
|
56
|
+
while (this.queue[0]?.mode === 'shared') {
|
|
57
|
+
const reader = this.queue.shift();
|
|
58
|
+
if (!reader) {
|
|
59
|
+
return;
|
|
60
|
+
}
|
|
61
|
+
this.activeReaders += 1;
|
|
62
|
+
this.execute(reader);
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
execute(request) {
|
|
66
|
+
const context = { mode: request.mode, active: true, nestedOperations: new Set() };
|
|
67
|
+
void Promise.resolve()
|
|
68
|
+
.then(() => this.context.run(context, request.fn))
|
|
69
|
+
.then(async (value) => {
|
|
70
|
+
await this.waitForNestedOperations(context);
|
|
71
|
+
request.resolve(value);
|
|
72
|
+
}, async (error) => {
|
|
73
|
+
await this.waitForNestedOperations(context);
|
|
74
|
+
request.reject(error);
|
|
75
|
+
})
|
|
76
|
+
.finally(() => {
|
|
77
|
+
context.active = false;
|
|
78
|
+
if (request.mode === 'exclusive') {
|
|
79
|
+
this.writerActive = false;
|
|
80
|
+
}
|
|
81
|
+
else {
|
|
82
|
+
this.activeReaders -= 1;
|
|
83
|
+
}
|
|
84
|
+
this.drain();
|
|
85
|
+
});
|
|
86
|
+
}
|
|
87
|
+
runNested(context, fn) {
|
|
88
|
+
let operation;
|
|
89
|
+
try {
|
|
90
|
+
operation = Promise.resolve(fn());
|
|
91
|
+
}
|
|
92
|
+
catch (error) {
|
|
93
|
+
operation = Promise.reject(error instanceof Error ? error : new Error(String(error)));
|
|
94
|
+
}
|
|
95
|
+
context.nestedOperations.add(operation);
|
|
96
|
+
void operation.then(() => context.nestedOperations.delete(operation), () => context.nestedOperations.delete(operation));
|
|
97
|
+
return operation;
|
|
98
|
+
}
|
|
99
|
+
async waitForNestedOperations(context) {
|
|
100
|
+
while (context.nestedOperations.size > 0) {
|
|
101
|
+
await Promise.allSettled(context.nestedOperations);
|
|
20
102
|
}
|
|
21
|
-
const ticket = this.tail.then(() => this.heldOnThisChain.run(true, fn), () => this.heldOnThisChain.run(true, fn));
|
|
22
|
-
this.tail = ticket.then(() => { }, () => { });
|
|
23
|
-
return ticket;
|
|
24
103
|
}
|
|
25
104
|
};
|
|
26
105
|
exports.DeviceStructureLockService = DeviceStructureLockService;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"device-structure-lock.service.js","sourceRoot":"","sources":["../../../../src/modules/devices/services/device-structure-lock.service.ts"],"names":[],"mappings":";;;;;;;;;AAAA,uDAAqD;AAErD,2CAA4C;AA0BrC,IAAM,0BAA0B,GAAhC,MAAM,0BAA0B;IAAhC;QACW,
|
|
1
|
+
{"version":3,"file":"device-structure-lock.service.js","sourceRoot":"","sources":["../../../../src/modules/devices/services/device-structure-lock.service.ts"],"names":[],"mappings":";;;;;;;;;AAAA,uDAAqD;AAErD,2CAA4C;AA0BrC,IAAM,0BAA0B,GAAhC,MAAM,0BAA0B;IAAhC;QACW,YAAO,GAAG,IAAI,oCAAiB,EAAe,CAAC;QAC/C,UAAK,GAA2B,EAAE,CAAC;QAC5C,kBAAa,GAAG,CAAC,CAAC;QAClB,iBAAY,GAAG,KAAK,CAAC;IAyH9B,CAAC;IAvHA,KAAK,CAAC,SAAS,CAAI,EAAoB;QACtC,MAAM,OAAO,GAAG,IAAI,CAAC,OAAO,CAAC,QAAQ,EAAE,CAAC;QAIxC,IAAI,OAAO,EAAE,MAAM,EAAE,CAAC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