node-switchbot 3.6.5 → 4.0.0-beta.0
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/.github/npm-version-script-esm.js +97 -0
- package/CHANGELOG.md +586 -0
- package/PRODUCTION_READY.md +135 -0
- package/README.md +92 -0
- package/dist/api.d.ts +130 -0
- package/dist/api.d.ts.map +1 -0
- package/dist/api.js +286 -0
- package/dist/api.js.map +1 -0
- package/dist/ble.d.ts +116 -0
- package/dist/ble.d.ts.map +1 -0
- package/dist/ble.js +430 -0
- package/dist/ble.js.map +1 -0
- package/dist/devices/base.d.ts +146 -0
- package/dist/devices/base.d.ts.map +1 -0
- package/dist/devices/base.js +324 -0
- package/dist/devices/base.js.map +1 -0
- package/dist/devices/index.d.ts +30 -0
- package/dist/devices/index.d.ts.map +1 -0
- package/dist/devices/index.js +34 -0
- package/dist/devices/index.js.map +1 -0
- package/dist/devices/wo-air-purifier-table.d.ts +8 -0
- package/dist/devices/wo-air-purifier-table.d.ts.map +1 -0
- package/dist/devices/wo-air-purifier-table.js +12 -0
- package/dist/devices/wo-air-purifier-table.js.map +1 -0
- package/dist/devices/wo-air-purifier.d.ts +28 -0
- package/dist/devices/wo-air-purifier.d.ts.map +1 -0
- package/dist/devices/wo-air-purifier.js +105 -0
- package/dist/devices/wo-air-purifier.js.map +1 -0
- package/dist/devices/wo-blind-tilt.d.ts +36 -0
- package/dist/devices/wo-blind-tilt.d.ts.map +1 -0
- package/dist/devices/wo-blind-tilt.js +95 -0
- package/dist/devices/wo-blind-tilt.js.map +1 -0
- package/dist/devices/wo-bulb.d.ts +32 -0
- package/dist/devices/wo-bulb.d.ts.map +1 -0
- package/dist/devices/wo-bulb.js +109 -0
- package/dist/devices/wo-bulb.js.map +1 -0
- package/dist/devices/wo-ceiling-light.d.ts +8 -0
- package/dist/devices/wo-ceiling-light.d.ts.map +1 -0
- package/dist/devices/wo-ceiling-light.js +12 -0
- package/dist/devices/wo-ceiling-light.js.map +1 -0
- package/dist/devices/wo-contact.d.ts +12 -0
- package/dist/devices/wo-contact.d.ts.map +1 -0
- package/dist/devices/wo-contact.js +50 -0
- package/dist/devices/wo-contact.js.map +1 -0
- package/dist/devices/wo-curtain.d.ts +28 -0
- package/dist/devices/wo-curtain.d.ts.map +1 -0
- package/dist/devices/wo-curtain.js +82 -0
- package/dist/devices/wo-curtain.js.map +1 -0
- package/dist/devices/wo-hand.d.ts +24 -0
- package/dist/devices/wo-hand.d.ts.map +1 -0
- package/dist/devices/wo-hand.js +70 -0
- package/dist/devices/wo-hand.js.map +1 -0
- package/dist/devices/wo-hub2.d.ts +12 -0
- package/dist/devices/wo-hub2.d.ts.map +1 -0
- package/dist/devices/wo-hub2.js +48 -0
- package/dist/devices/wo-hub2.js.map +1 -0
- package/dist/devices/wo-hub3.d.ts +8 -0
- package/dist/devices/wo-hub3.d.ts.map +1 -0
- package/dist/devices/wo-hub3.js +12 -0
- package/dist/devices/wo-hub3.js.map +1 -0
- package/dist/devices/wo-humi.d.ts +28 -0
- package/dist/devices/wo-humi.d.ts.map +1 -0
- package/dist/devices/wo-humi.js +91 -0
- package/dist/devices/wo-humi.js.map +1 -0
- package/dist/devices/wo-humi2.d.ts +8 -0
- package/dist/devices/wo-humi2.d.ts.map +1 -0
- package/dist/devices/wo-humi2.js +12 -0
- package/dist/devices/wo-humi2.js.map +1 -0
- package/dist/devices/wo-io-sensor-th.d.ts +8 -0
- package/dist/devices/wo-io-sensor-th.d.ts.map +1 -0
- package/dist/devices/wo-io-sensor-th.js +12 -0
- package/dist/devices/wo-io-sensor-th.js.map +1 -0
- package/dist/devices/wo-keypad.d.ts +13 -0
- package/dist/devices/wo-keypad.d.ts.map +1 -0
- package/dist/devices/wo-keypad.js +46 -0
- package/dist/devices/wo-keypad.js.map +1 -0
- package/dist/devices/wo-leak.d.ts +12 -0
- package/dist/devices/wo-leak.d.ts.map +1 -0
- package/dist/devices/wo-leak.js +46 -0
- package/dist/devices/wo-leak.js.map +1 -0
- package/dist/devices/wo-lock-pro.d.ts +24 -0
- package/dist/devices/wo-lock-pro.d.ts.map +1 -0
- package/dist/devices/wo-lock-pro.js +72 -0
- package/dist/devices/wo-lock-pro.js.map +1 -0
- package/dist/devices/wo-lock.d.ts +20 -0
- package/dist/devices/wo-lock.d.ts.map +1 -0
- package/dist/devices/wo-lock.js +64 -0
- package/dist/devices/wo-lock.js.map +1 -0
- package/dist/devices/wo-plug-mini-jp.d.ts +8 -0
- package/dist/devices/wo-plug-mini-jp.d.ts.map +1 -0
- package/dist/devices/wo-plug-mini-jp.js +12 -0
- package/dist/devices/wo-plug-mini-jp.js.map +1 -0
- package/dist/devices/wo-plug-mini-us.d.ts +24 -0
- package/dist/devices/wo-plug-mini-us.d.ts.map +1 -0
- package/dist/devices/wo-plug-mini-us.js +70 -0
- package/dist/devices/wo-plug-mini-us.js.map +1 -0
- package/dist/devices/wo-presence.d.ts +12 -0
- package/dist/devices/wo-presence.d.ts.map +1 -0
- package/dist/devices/wo-presence.js +48 -0
- package/dist/devices/wo-presence.js.map +1 -0
- package/dist/devices/wo-relay-switch-1.d.ts +24 -0
- package/dist/devices/wo-relay-switch-1.d.ts.map +1 -0
- package/dist/devices/wo-relay-switch-1.js +70 -0
- package/dist/devices/wo-relay-switch-1.js.map +1 -0
- package/dist/devices/wo-relay-switch-1pm.d.ts +8 -0
- package/dist/devices/wo-relay-switch-1pm.d.ts.map +1 -0
- package/dist/devices/wo-relay-switch-1pm.js +12 -0
- package/dist/devices/wo-relay-switch-1pm.js.map +1 -0
- package/dist/devices/wo-remote.d.ts +13 -0
- package/dist/devices/wo-remote.d.ts.map +1 -0
- package/dist/devices/wo-remote.js +45 -0
- package/dist/devices/wo-remote.js.map +1 -0
- package/dist/devices/wo-sensor-th-plus.d.ts +8 -0
- package/dist/devices/wo-sensor-th-plus.d.ts.map +1 -0
- package/dist/devices/wo-sensor-th-plus.js +12 -0
- package/dist/devices/wo-sensor-th-plus.js.map +1 -0
- package/dist/devices/wo-sensor-th-pro-co2.d.ts +8 -0
- package/dist/devices/wo-sensor-th-pro-co2.d.ts.map +1 -0
- package/dist/devices/wo-sensor-th-pro-co2.js +12 -0
- package/dist/devices/wo-sensor-th-pro-co2.js.map +1 -0
- package/dist/devices/wo-sensor-th-pro.d.ts +8 -0
- package/dist/devices/wo-sensor-th-pro.d.ts.map +1 -0
- package/dist/devices/wo-sensor-th-pro.js +12 -0
- package/dist/devices/wo-sensor-th-pro.js.map +1 -0
- package/dist/devices/wo-sensor-th.d.ts +12 -0
- package/dist/devices/wo-sensor-th.d.ts.map +1 -0
- package/dist/devices/wo-sensor-th.js +49 -0
- package/dist/devices/wo-sensor-th.js.map +1 -0
- package/dist/devices/wo-strip.d.ts +8 -0
- package/dist/devices/wo-strip.d.ts.map +1 -0
- package/dist/devices/wo-strip.js +12 -0
- package/dist/devices/wo-strip.js.map +1 -0
- package/dist/errors.d.ts +63 -0
- package/dist/errors.d.ts.map +1 -0
- package/dist/errors.js +103 -0
- package/dist/errors.js.map +1 -0
- package/dist/index.d.ts +10 -6
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +9 -10
- package/dist/index.js.map +1 -1
- package/dist/settings.d.ts +126 -47
- package/dist/settings.d.ts.map +1 -1
- package/dist/settings.js +214 -64
- package/dist/settings.js.map +1 -1
- package/dist/switchbot.d.ts +80 -0
- package/dist/switchbot.d.ts.map +1 -0
- package/dist/switchbot.js +376 -0
- package/dist/switchbot.js.map +1 -0
- package/dist/types/api.d.ts +187 -0
- package/dist/types/api.d.ts.map +1 -0
- package/dist/types/api.js +6 -0
- package/dist/types/api.js.map +1 -0
- package/dist/types/ble.d.ts +246 -343
- package/dist/types/ble.d.ts.map +1 -1
- package/dist/types/ble.js +94 -1
- package/dist/types/ble.js.map +1 -1
- package/dist/types/device.d.ts +209 -0
- package/dist/types/device.d.ts.map +1 -0
- package/dist/types/device.js +6 -0
- package/dist/types/device.js.map +1 -0
- package/dist/types/index.d.ts +115 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/index.js +19 -0
- package/dist/types/index.js.map +1 -0
- package/dist/utils/index.d.ts +97 -0
- package/dist/utils/index.d.ts.map +1 -0
- package/dist/utils/index.js +206 -0
- package/dist/utils/index.js.map +1 -0
- package/docs/assets/hierarchy.js +1 -1
- package/docs/assets/highlight.css +20 -6
- package/docs/assets/icons.js +1 -1
- package/docs/assets/icons.svg +1 -1
- package/docs/assets/main.js +2 -2
- package/docs/assets/navigation.js +1 -1
- package/docs/assets/search.js +1 -1
- package/docs/assets/style.css +3 -3
- package/docs/classes/APIError.html +6 -0
- package/docs/classes/APINotAvailableError.html +4 -0
- package/docs/classes/BLEConnection.html +17 -0
- package/docs/classes/BLENotAvailableError.html +4 -0
- package/docs/classes/BLEScanner.html +15 -0
- package/docs/classes/CommandFailedError.html +6 -0
- package/docs/classes/ConnectionTimeoutError.html +5 -0
- package/docs/classes/DeviceManager.html +25 -0
- package/docs/classes/DeviceNotFoundError.html +4 -0
- package/docs/classes/DiscoveryError.html +5 -0
- package/docs/classes/OpenAPIClient.html +66 -0
- package/docs/classes/SwitchBot.html +21 -0
- package/docs/classes/SwitchBotDevice.html +28 -0
- package/docs/classes/SwitchBotError.html +4 -0
- package/docs/classes/ValidationError.html +5 -0
- package/docs/classes/WoAirPurifier.html +32 -80
- package/docs/classes/WoAirPurifierTable.html +36 -83
- package/docs/classes/WoBlindTilt.html +34 -73
- package/docs/classes/WoBulb.html +33 -85
- package/docs/classes/WoCeilingLight.html +38 -107
- package/docs/classes/WoContact.html +27 -52
- package/docs/classes/WoCurtain.html +32 -69
- package/docs/classes/WoHand.html +30 -59
- package/docs/classes/WoHub2.html +27 -52
- package/docs/classes/WoHub3.html +28 -52
- package/docs/classes/WoHumi.html +33 -65
- package/docs/classes/WoHumi2.html +36 -67
- package/docs/classes/WoIOSensorTH.html +28 -53
- package/docs/classes/WoKeypad.html +28 -52
- package/docs/classes/WoLeak.html +27 -53
- package/docs/classes/WoPlugMiniJP.html +34 -78
- package/docs/classes/WoPlugMiniUS.html +30 -75
- package/docs/classes/WoPresence.html +27 -60
- package/docs/classes/WoRelaySwitch1.html +31 -55
- package/docs/classes/WoRelaySwitch1PM.html +34 -57
- package/docs/classes/WoRemote.html +28 -52
- package/docs/classes/WoSensorTH.html +27 -46
- package/docs/classes/WoSensorTHPlus.html +28 -46
- package/docs/classes/WoSensorTHPro.html +28 -46
- package/docs/classes/WoSensorTHProCO2.html +28 -46
- package/docs/classes/WoSmartLock.html +29 -111
- package/docs/classes/WoSmartLockPro.html +31 -111
- package/docs/classes/WoStrip.html +38 -94
- package/docs/enums/LogLevel.html +4 -7
- package/docs/enums/SwitchBotBLEModel.html +11 -5
- package/docs/enums/SwitchBotBLEModelName.html +13 -6
- package/docs/functions/updateBaseURL.html +3 -3
- package/docs/hierarchy.html +1 -1
- package/docs/index.html +40 -6
- package/docs/interfaces/APICommandRequest.html +5 -0
- package/docs/interfaces/APICommandResponse.html +5 -0
- package/docs/interfaces/APIDevice.html +18 -0
- package/docs/interfaces/APIDeviceStatus.html +36 -0
- package/docs/interfaces/APIErrorResponse.html +5 -0
- package/docs/interfaces/APIResponse.html +5 -0
- package/docs/interfaces/AirPurifierCommands.html +5 -0
- package/docs/interfaces/AirPurifierServiceData.html +14 -0
- package/docs/interfaces/AirPurifierStatus.html +17 -0
- package/docs/interfaces/BLEAdvertisement.html +6 -0
- package/docs/interfaces/BLEScanOptions.html +10 -0
- package/docs/interfaces/BLEServiceData.html +10 -0
- package/docs/interfaces/BlindTiltCommands.html +7 -0
- package/docs/interfaces/BlindTiltServiceData.html +14 -0
- package/docs/interfaces/BlindTiltStatus.html +15 -0
- package/docs/interfaces/BotCommands.html +4 -0
- package/docs/interfaces/BotServiceData.html +12 -0
- package/docs/interfaces/BotStatus.html +14 -0
- package/docs/interfaces/BulbCommands.html +6 -0
- package/docs/interfaces/BulbServiceData.html +19 -0
- package/docs/interfaces/BulbStatus.html +16 -0
- package/docs/interfaces/CeilingLightCommands.html +6 -0
- package/docs/interfaces/CeilingLightServiceData.html +19 -0
- package/docs/interfaces/CeilingLightStatus.html +16 -0
- package/docs/interfaces/CommandResult.html +12 -0
- package/docs/interfaces/ContactServiceData.html +13 -0
- package/docs/interfaces/ContactStatus.html +15 -0
- package/docs/interfaces/CurtainCommands.html +5 -0
- package/docs/interfaces/CurtainServiceData.html +14 -0
- package/docs/interfaces/CurtainStatus.html +17 -0
- package/docs/interfaces/DeviceInfo.html +26 -0
- package/docs/interfaces/DeviceListResponse.html +4 -0
- package/docs/interfaces/DeviceStatus.html +12 -0
- package/docs/interfaces/DiscoveryOptions.html +14 -0
- package/docs/interfaces/HubServiceData.html +14 -0
- package/docs/interfaces/HubStatus.html +15 -0
- package/docs/interfaces/HumidifierCommands.html +5 -0
- package/docs/interfaces/HumidifierServiceData.html +14 -0
- package/docs/interfaces/HumidifierStatus.html +18 -0
- package/docs/interfaces/KeypadStatus.html +13 -0
- package/docs/interfaces/LeakServiceData.html +11 -0
- package/docs/interfaces/LeakStatus.html +13 -0
- package/docs/interfaces/LockCommands.html +3 -0
- package/docs/interfaces/LockServiceData.html +15 -0
- package/docs/interfaces/LockStatus.html +15 -0
- package/docs/interfaces/MeterServiceData.html +13 -0
- package/docs/interfaces/MeterStatus.html +15 -0
- package/docs/interfaces/MotionServiceData.html +13 -0
- package/docs/interfaces/MotionStatus.html +14 -0
- package/docs/interfaces/PlugCommands.html +4 -0
- package/docs/interfaces/PlugServiceData.html +17 -0
- package/docs/interfaces/PlugStatus.html +16 -0
- package/docs/interfaces/PresenceServiceData.html +12 -0
- package/docs/interfaces/PresenceStatus.html +14 -0
- package/docs/interfaces/RelaySwitchCommands.html +4 -0
- package/docs/interfaces/RelaySwitchServiceData.html +14 -0
- package/docs/interfaces/RelaySwitchStatus.html +16 -0
- package/docs/interfaces/RemoteStatus.html +12 -0
- package/docs/interfaces/SceneListResponse.html +3 -0
- package/docs/interfaces/StripCommands.html +6 -0
- package/docs/interfaces/StripServiceData.html +19 -0
- package/docs/interfaces/StripStatus.html +16 -0
- package/docs/interfaces/SwitchBotConfig.html +18 -0
- package/docs/interfaces/WebhookConfig.html +4 -0
- package/docs/interfaces/WebhookDetails.html +7 -0
- package/docs/interfaces/WebhookQueryResponse.html +5 -0
- package/docs/interfaces/WebhookSetupResponse.html +5 -0
- package/docs/modules.html +1 -1
- package/docs/types/ConnectionType.html +2 -0
- package/docs/types/PhysicalDeviceType.html +2 -0
- package/docs/types/VirtualDeviceType.html +2 -0
- package/docs/variables/urls.html +1 -1
- package/package.json +11 -20
- package/.github/scripts/npm-version-script-esm-auto.js +0 -207
- package/dist/device.d.ts +0 -1577
- package/dist/device.d.ts.map +0 -1
- package/dist/device.js +0 -3493
- package/dist/device.js.map +0 -1
- package/dist/device.test.d.ts +0 -2
- package/dist/device.test.d.ts.map +0 -1
- package/dist/device.test.js +0 -255
- package/dist/device.test.js.map +0 -1
- package/dist/index.test.d.ts +0 -2
- package/dist/index.test.d.ts.map +0 -1
- package/dist/index.test.js +0 -14
- package/dist/index.test.js.map +0 -1
- package/dist/parameter-checker.d.ts +0 -91
- package/dist/parameter-checker.d.ts.map +0 -1
- package/dist/parameter-checker.js +0 -262
- package/dist/parameter-checker.js.map +0 -1
- package/dist/parameter-checker.test.d.ts +0 -2
- package/dist/parameter-checker.test.d.ts.map +0 -1
- package/dist/parameter-checker.test.js +0 -56
- package/dist/parameter-checker.test.js.map +0 -1
- package/dist/settings.test.d.ts +0 -2
- package/dist/settings.test.d.ts.map +0 -1
- package/dist/settings.test.js +0 -61
- package/dist/settings.test.js.map +0 -1
- package/dist/switchbot-ble.d.ts +0 -89
- package/dist/switchbot-ble.d.ts.map +0 -1
- package/dist/switchbot-ble.js +0 -319
- package/dist/switchbot-ble.js.map +0 -1
- package/dist/switchbot-ble.test.d.ts +0 -2
- package/dist/switchbot-ble.test.d.ts.map +0 -1
- package/dist/switchbot-ble.test.js +0 -32
- package/dist/switchbot-ble.test.js.map +0 -1
- package/dist/switchbot-openapi.d.ts +0 -139
- package/dist/switchbot-openapi.d.ts.map +0 -1
- package/dist/switchbot-openapi.js +0 -375
- package/dist/switchbot-openapi.js.map +0 -1
- package/dist/switchbot-openapi.test.d.ts +0 -2
- package/dist/switchbot-openapi.test.d.ts.map +0 -1
- package/dist/switchbot-openapi.test.js +0 -36
- package/dist/switchbot-openapi.test.js.map +0 -1
- package/dist/types/ble-guards.d.ts +0 -12
- package/dist/types/ble-guards.d.ts.map +0 -1
- package/dist/types/ble-guards.js +0 -10
- package/dist/types/ble-guards.js.map +0 -1
- package/dist/types/ble-guards.test.d.ts +0 -2
- package/dist/types/ble-guards.test.d.ts.map +0 -1
- package/dist/types/ble-guards.test.js +0 -62
- package/dist/types/ble-guards.test.js.map +0 -1
- package/dist/types/openapi.d.ts +0 -635
- package/dist/types/openapi.d.ts.map +0 -1
- package/dist/types/openapi.js +0 -3
- package/dist/types/openapi.js.map +0 -1
- package/docs/classes/Advertising.html +0 -21
- package/docs/classes/ErrorUtils.html +0 -25
- package/docs/classes/ParameterChecker.html +0 -69
- package/docs/classes/SwitchBotBLE.html +0 -39
- package/docs/classes/SwitchBotOpenAPI.html +0 -57
- package/docs/classes/SwitchbotDevice.html +0 -47
- package/docs/classes/ValidationUtils.html +0 -51
- package/docs/classes/WoSmartLockUltra.html +0 -113
- package/docs/enums/SwitchBotBLEModelFriendlyName.html +0 -39
- package/docs/enums/SwitchBotModel.html +0 -52
- package/docs/interfaces/AdvertisementData.html +0 -3
- package/docs/interfaces/Chars.html +0 -4
- package/docs/interfaces/ColorLightServiceDataBase.html +0 -17
- package/docs/interfaces/ErrorObject.html +0 -3
- package/docs/interfaces/LockBaseServiceData.html +0 -15
- package/docs/interfaces/NobleTypes.html +0 -3
- package/docs/interfaces/Params.html +0 -6
- package/docs/interfaces/PlugMiniServiceDataBase.html +0 -12
- package/docs/interfaces/Rule.html +0 -9
- package/docs/interfaces/ServiceData.html +0 -2
- package/docs/interfaces/SwitchBotBLEDevice.html +0 -27
- package/docs/interfaces/SwitchBotScanner.html +0 -6
- package/docs/interfaces/TemperatureServiceDataBase.html +0 -10
- package/docs/interfaces/WebhookDetail.html +0 -6
- package/docs/interfaces/ad.html +0 -5
- package/docs/interfaces/body.html +0 -3
- package/docs/interfaces/bodyChange.html +0 -4
- package/docs/interfaces/deleteWebhookResponse.html +0 -4
- package/docs/interfaces/device.html +0 -7
- package/docs/interfaces/deviceList.html +0 -2
- package/docs/interfaces/deviceStatus.html +0 -7
- package/docs/interfaces/deviceStatusRequest.html +0 -4
- package/docs/interfaces/deviceWebhook.html +0 -4
- package/docs/interfaces/deviceWebhookContext.html +0 -4
- package/docs/interfaces/devices.html +0 -4
- package/docs/interfaces/infraredRemoteList.html +0 -2
- package/docs/interfaces/irdevice.html +0 -5
- package/docs/interfaces/pushRequest.html +0 -5
- package/docs/interfaces/pushResponse.html +0 -5
- package/docs/interfaces/pushResponseBody.html +0 -3
- package/docs/interfaces/queryWebhookResponse.html +0 -4
- package/docs/interfaces/setupWebhookResponse.html +0 -4
- package/docs/interfaces/updateWebhookResponse.html +0 -4
- package/docs/interfaces/webhookRequest.html +0 -4
- package/docs/types/BLEDeviceServiceData.html +0 -1
- package/docs/types/IndoorCam.html +0 -1
- package/docs/types/MacAddress.html +0 -1
- package/docs/types/airPurifier.html +0 -1
- package/docs/types/airPurifierPM25WebhookContext.html +0 -1
- package/docs/types/airPurifierServiceData.html +0 -1
- package/docs/types/airPurifierStatus.html +0 -1
- package/docs/types/airPurifierTable.html +0 -1
- package/docs/types/airPurifierTablePM25WebhookContext.html +0 -1
- package/docs/types/airPurifierTableServiceData.html +0 -1
- package/docs/types/airPurifierTableStatus.html +0 -1
- package/docs/types/airPurifierTableVOC.html +0 -1
- package/docs/types/airPurifierTableVOCStatus.html +0 -1
- package/docs/types/airPurifierTableVOCWebhookContext.html +0 -1
- package/docs/types/airPurifierTableWebhookContext.html +0 -1
- package/docs/types/airPurifierVOC.html +0 -1
- package/docs/types/airPurifierVOCStatus.html +0 -1
- package/docs/types/airPurifierVOCWebhookContext.html +0 -1
- package/docs/types/airPurifierWebhookContext.html +0 -1
- package/docs/types/batteryCirculatorFan.html +0 -1
- package/docs/types/batteryCirculatorFanServiceData.html +0 -1
- package/docs/types/batteryCirculatorFanStatus.html +0 -1
- package/docs/types/batteryCirculatorFanWebhookContext.html +0 -1
- package/docs/types/blindTilt.html +0 -1
- package/docs/types/blindTiltServiceData.html +0 -1
- package/docs/types/blindTiltStatus.html +0 -1
- package/docs/types/blindTiltWebhookContext.html +0 -1
- package/docs/types/bot.html +0 -1
- package/docs/types/botServiceData.html +0 -1
- package/docs/types/botStatus.html +0 -1
- package/docs/types/botWebhookContext.html +0 -1
- package/docs/types/ceilingLight.html +0 -1
- package/docs/types/ceilingLightPro.html +0 -1
- package/docs/types/ceilingLightProServiceData.html +0 -1
- package/docs/types/ceilingLightProStatus.html +0 -1
- package/docs/types/ceilingLightProWebhookContext.html +0 -1
- package/docs/types/ceilingLightServiceData.html +0 -1
- package/docs/types/ceilingLightStatus.html +0 -1
- package/docs/types/ceilingLightWebhookContext.html +0 -1
- package/docs/types/circulatorFanStatus.html +0 -1
- package/docs/types/circulatorFanWebhookContext.html +0 -1
- package/docs/types/colorBulb.html +0 -1
- package/docs/types/colorBulbServiceData.html +0 -1
- package/docs/types/colorBulbStatus.html +0 -1
- package/docs/types/colorBulbWebhookContext.html +0 -1
- package/docs/types/commandType.html +0 -2
- package/docs/types/contactSensor.html +0 -1
- package/docs/types/contactSensorServiceData.html +0 -1
- package/docs/types/contactSensorStatus.html +0 -1
- package/docs/types/contactSensorWebhookContext.html +0 -1
- package/docs/types/curtain.html +0 -1
- package/docs/types/curtain3.html +0 -1
- package/docs/types/curtain3ServiceData.html +0 -1
- package/docs/types/curtain3WebhookContext.html +0 -1
- package/docs/types/curtainServiceData.html +0 -1
- package/docs/types/curtainStatus.html +0 -1
- package/docs/types/curtainWebhookContext.html +0 -1
- package/docs/types/floorCleaningRobotS10.html +0 -1
- package/docs/types/floorCleaningRobotS10Status.html +0 -1
- package/docs/types/floorCleaningRobotS10WebhookContext.html +0 -1
- package/docs/types/hub2.html +0 -1
- package/docs/types/hub2ServiceData.html +0 -1
- package/docs/types/hub2Status.html +0 -1
- package/docs/types/hub2WebhookContext.html +0 -1
- package/docs/types/hub3ServiceData.html +0 -1
- package/docs/types/humidifier.html +0 -1
- package/docs/types/humidifier2ServiceData.html +0 -1
- package/docs/types/humidifier2Status.html +0 -1
- package/docs/types/humidifier2WebhookContext.html +0 -1
- package/docs/types/humidifierServiceData.html +0 -1
- package/docs/types/humidifierStatus.html +0 -1
- package/docs/types/humidifierWebhookContext.html +0 -1
- package/docs/types/indoorCameraWebhookContext.html +0 -1
- package/docs/types/keypad.html +0 -1
- package/docs/types/keypadDetectorServiceData.html +0 -1
- package/docs/types/keypadTouch.html +0 -1
- package/docs/types/keypadTouchWebhookContext.html +0 -1
- package/docs/types/keypadWebhookContext.html +0 -1
- package/docs/types/lock.html +0 -1
- package/docs/types/lockPro.html +0 -1
- package/docs/types/lockProServiceData.html +0 -1
- package/docs/types/lockProStatus.html +0 -1
- package/docs/types/lockProWebhookContext.html +0 -1
- package/docs/types/lockServiceData.html +0 -1
- package/docs/types/lockStatus.html +0 -1
- package/docs/types/lockWebhookContext.html +0 -1
- package/docs/types/meter.html +0 -1
- package/docs/types/meterPlus.html +0 -1
- package/docs/types/meterPlusServiceData.html +0 -1
- package/docs/types/meterPlusStatus.html +0 -1
- package/docs/types/meterPlusWebhookContext.html +0 -1
- package/docs/types/meterPro.html +0 -1
- package/docs/types/meterProCO2ServiceData.html +0 -1
- package/docs/types/meterProCO2Status.html +0 -1
- package/docs/types/meterProCO2WebhookContext.html +0 -1
- package/docs/types/meterProServiceData.html +0 -1
- package/docs/types/meterProStatus.html +0 -1
- package/docs/types/meterProWebhookContext.html +0 -1
- package/docs/types/meterServiceData.html +0 -1
- package/docs/types/meterStatus.html +0 -1
- package/docs/types/meterWebhookContext.html +0 -1
- package/docs/types/motionSensor.html +0 -1
- package/docs/types/motionSensorServiceData.html +0 -1
- package/docs/types/motionSensorStatus.html +0 -1
- package/docs/types/motionSensorWebhookContext.html +0 -1
- package/docs/types/onadvertisement.html +0 -1
- package/docs/types/ondiscover.html +0 -1
- package/docs/types/outdoorMeter.html +0 -1
- package/docs/types/outdoorMeterServiceData.html +0 -1
- package/docs/types/outdoorMeterStatus.html +0 -1
- package/docs/types/outdoorMeterWebhookContext.html +0 -1
- package/docs/types/panTiltCamWebhookContext.html +0 -1
- package/docs/types/pantiltCam.html +0 -1
- package/docs/types/pantiltCam2k.html +0 -1
- package/docs/types/plug.html +0 -1
- package/docs/types/plugMini.html +0 -1
- package/docs/types/plugMiniJPServiceData.html +0 -1
- package/docs/types/plugMiniJPWebhookContext.html +0 -1
- package/docs/types/plugMiniStatus.html +0 -1
- package/docs/types/plugMiniUSServiceData.html +0 -1
- package/docs/types/plugMiniUSWebhookContext.html +0 -1
- package/docs/types/plugStatus.html +0 -1
- package/docs/types/plugWebhookContext.html +0 -1
- package/docs/types/presenceSensor.html +0 -1
- package/docs/types/presenceSensorServiceData.html +0 -1
- package/docs/types/presenceSensorStatus.html +0 -1
- package/docs/types/presenceSensorWebhookContext.html +0 -1
- package/docs/types/relaySwitch1Context.html +0 -1
- package/docs/types/relaySwitch1PMContext.html +0 -1
- package/docs/types/relaySwitch1PMServiceData.html +0 -1
- package/docs/types/relaySwitch1PMStatus.html +0 -1
- package/docs/types/relaySwitch1ServiceData.html +0 -1
- package/docs/types/relaySwitch1Status.html +0 -1
- package/docs/types/remote.html +0 -1
- package/docs/types/remoteServiceData.html +0 -1
- package/docs/types/robotVacuumCleanerS1.html +0 -1
- package/docs/types/robotVacuumCleanerS1Plus.html +0 -1
- package/docs/types/robotVacuumCleanerS1PlusStatus.html +0 -1
- package/docs/types/robotVacuumCleanerS1PlusWebhookContext.html +0 -1
- package/docs/types/robotVacuumCleanerS1Status.html +0 -1
- package/docs/types/robotVacuumCleanerS1WebhookContext.html +0 -1
- package/docs/types/robotVacuumCleanerServiceData.html +0 -1
- package/docs/types/stripLight.html +0 -1
- package/docs/types/stripLightServiceData.html +0 -1
- package/docs/types/stripLightStatus.html +0 -1
- package/docs/types/stripLightWebhookContext.html +0 -1
- package/docs/types/waterLeakDetector.html +0 -1
- package/docs/types/waterLeakDetectorServiceData.html +0 -1
- package/docs/types/waterLeakDetectorStatus.html +0 -1
- package/docs/types/waterLeakDetectorWebhookContext.html +0 -1
- package/docs/variables/parameterChecker.html +0 -1
- package/eslint.config.js +0 -48
- package/typedoc.json +0 -17
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"parameter-checker.d.ts","sourceRoot":"","sources":["../src/parameter-checker.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,IAAI,EAAE,MAAM,aAAa,CAAA;AAOpD,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;AAE1C,qBAAa,gBAAiB,SAAQ,YAAY;IAChD,OAAO,CAAC,MAAM,CAA2B;IAEzC,OAAO,CAAC,QAAQ,CAAC,YAAY,CAO5B;IAED;;;;;OAKG;IACH,OAAO,CAAC,OAAO;IAIf;;;;OAIG;IACH,IAAI,KAAK,IAAI,WAAW,GAAG,IAAI,CAE9B;IAED;;;;;OAKG;IACH,WAAW,CAAC,KAAK,EAAE,OAAO,GAAG,OAAO;IAIpC;;;;;;;OAOG;IACG,KAAK,CAAC,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,IAAI,CAAC,EAAE,QAAQ,GAAE,OAAe,GAAG,OAAO,CAAC,OAAO,CAAC;IAmDnH;;;;;;;OAOG;IACG,OAAO,CAAC,KAAK,EAAE,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,GAAE,MAAgB,GAAG,OAAO,CAAC,OAAO,CAAC;IA8BnF;;;;;;;OAOG;IACG,SAAS,CAAC,KAAK,EAAE,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,GAAE,MAAgB,GAAG,OAAO,CAAC,OAAO,CAAC;IAerF;;;;;;;OAOG;IACG,SAAS,CAAC,KAAK,EAAE,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,GAAE,MAAgB,GAAG,OAAO,CAAC,OAAO,CAAC;IAerF;;;;;;;OAOG;IACG,QAAQ,CAAC,KAAK,EAAE,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,GAAE,MAAgB,GAAG,OAAO,CAAC,OAAO,CAAC;IAepF;;;;;;;OAOG;IACG,OAAO,CAAC,KAAK,EAAE,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,GAAE,MAAgB,GAAG,OAAO,CAAC,OAAO,CAAC;IAyBnF;;;;;;;OAOG;IACG,QAAQ,CAAC,KAAK,EAAE,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,GAAE,MAAgB,GAAG,OAAO,CAAC,OAAO,CAAC;CAkDrF;AAED,eAAO,MAAM,gBAAgB,kBAAyB,CAAA"}
|
|
@@ -1,262 +0,0 @@
|
|
|
1
|
-
import { Buffer } from 'node:buffer';
|
|
2
|
-
/* Copyright(C) 2024, donavanbecker (https://github.com/donavanbecker). All rights reserved.
|
|
3
|
-
*
|
|
4
|
-
* parameter-checker.ts: Switchbot BLE API registration.
|
|
5
|
-
*/
|
|
6
|
-
import { EventEmitter } from 'node:events';
|
|
7
|
-
export class ParameterChecker extends EventEmitter {
|
|
8
|
-
_error = null;
|
|
9
|
-
// Mapping of type names to checker methods
|
|
10
|
-
typeCheckers = {
|
|
11
|
-
float: this.isFloat.bind(this),
|
|
12
|
-
integer: this.isInteger.bind(this),
|
|
13
|
-
boolean: this.isBoolean.bind(this),
|
|
14
|
-
array: this.isArray.bind(this),
|
|
15
|
-
object: this.isObject.bind(this),
|
|
16
|
-
string: this.isString.bind(this),
|
|
17
|
-
};
|
|
18
|
-
/**
|
|
19
|
-
* Emits a log event with the specified log level and message.
|
|
20
|
-
*
|
|
21
|
-
* @param level - The severity level of the log (e.g., 'info', 'warn', 'error').
|
|
22
|
-
* @param message - The log message to be emitted.
|
|
23
|
-
*/
|
|
24
|
-
emitLog(level, message) {
|
|
25
|
-
this.emit('log', { level, message });
|
|
26
|
-
}
|
|
27
|
-
/**
|
|
28
|
-
* Gets the current error object.
|
|
29
|
-
*
|
|
30
|
-
* @returns {ErrorObject | null} - The current error object or null if no error.
|
|
31
|
-
*/
|
|
32
|
-
get error() {
|
|
33
|
-
return this._error;
|
|
34
|
-
}
|
|
35
|
-
/**
|
|
36
|
-
* Checks if the value is specified (not undefined).
|
|
37
|
-
*
|
|
38
|
-
* @param {unknown} value - The value to check.
|
|
39
|
-
* @returns {boolean} - True if the value is specified, false otherwise.
|
|
40
|
-
*/
|
|
41
|
-
isSpecified(value) {
|
|
42
|
-
return value !== undefined;
|
|
43
|
-
}
|
|
44
|
-
/**
|
|
45
|
-
* Checks if the specified object contains valid values based on the provided rules.
|
|
46
|
-
*
|
|
47
|
-
* @param {Record<string, unknown>} obj - Object including parameters you want to check.
|
|
48
|
-
* @param {Record<string, Rule>} rules - Object including rules for the parameters.
|
|
49
|
-
* @param {boolean} [required] - Flag whether the `obj` is required or not.
|
|
50
|
-
* @returns {Promise<boolean>} - Resolves to true if the value is valid, false otherwise.
|
|
51
|
-
*/
|
|
52
|
-
async check(obj, rules, required = false) {
|
|
53
|
-
this._error = null;
|
|
54
|
-
this.emitLog('debug', `Using rules: ${JSON.stringify(rules)}`);
|
|
55
|
-
if (required && !this.isSpecified(obj)) {
|
|
56
|
-
this._error = { code: 'MISSING_REQUIRED', message: 'The first argument is missing.' };
|
|
57
|
-
return false;
|
|
58
|
-
}
|
|
59
|
-
if (!required && !obj) {
|
|
60
|
-
return true;
|
|
61
|
-
}
|
|
62
|
-
if (!this.isObject(obj, {})) {
|
|
63
|
-
this._error = { code: 'MISSING_REQUIRED', message: 'The first argument is missing.' };
|
|
64
|
-
return false;
|
|
65
|
-
}
|
|
66
|
-
for (const [name, rule] of Object.entries(rules)) {
|
|
67
|
-
const value = obj[name];
|
|
68
|
-
if (!this.isSpecified(value)) {
|
|
69
|
-
if (rule.required) {
|
|
70
|
-
this._error = { code: 'MISSING_REQUIRED', message: `The \`${name}\` is required.` };
|
|
71
|
-
return false;
|
|
72
|
-
}
|
|
73
|
-
continue;
|
|
74
|
-
}
|
|
75
|
-
const checker = rule.type && this.typeCheckers[rule.type];
|
|
76
|
-
if (checker) {
|
|
77
|
-
if (!(await checker(value, rule, name))) {
|
|
78
|
-
return false;
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
else {
|
|
82
|
-
// Unknown type specified in rule
|
|
83
|
-
this.emitLog('error', `Unknown type "${rule.type}" in rule for parameter "${name}"`);
|
|
84
|
-
this._error = { code: 'TYPE_UNKNOWN', message: `Unknown type "${rule.type}" for parameter "${name}"` };
|
|
85
|
-
return false;
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
// Warn about extra parameters not defined in rules
|
|
89
|
-
const extra = Object.keys(obj).filter(key => !(key in rules));
|
|
90
|
-
if (extra.length) {
|
|
91
|
-
this.emitLog('warn', `Ignoring extra parameters: ${extra.join(', ')}`);
|
|
92
|
-
}
|
|
93
|
-
this.emitLog('debug', 'All checks passed.');
|
|
94
|
-
return true;
|
|
95
|
-
}
|
|
96
|
-
/**
|
|
97
|
-
* Checks if the value is a float.
|
|
98
|
-
*
|
|
99
|
-
* @param {unknown} value - The value to check.
|
|
100
|
-
* @param {Rule} rule - The rule object containing validation criteria.
|
|
101
|
-
* @param {string} [name] - The parameter name.
|
|
102
|
-
* @returns {Promise<boolean>} - Resolves to true if the value is valid, false otherwise.
|
|
103
|
-
*/
|
|
104
|
-
async isFloat(value, rule, name = 'value') {
|
|
105
|
-
this._error = null;
|
|
106
|
-
if (!rule.required && !this.isSpecified(value)) {
|
|
107
|
-
return true;
|
|
108
|
-
}
|
|
109
|
-
if (typeof value !== 'number') {
|
|
110
|
-
this._error = { code: 'TYPE_INVALID', message: `The \`${name}\` must be a number (integer or float).` };
|
|
111
|
-
return false;
|
|
112
|
-
}
|
|
113
|
-
if (typeof rule.min === 'number' && value < rule.min) {
|
|
114
|
-
this._error = { code: 'VALUE_UNDERFLOW', message: `The \`${name}\` must be greater than or equal to ${rule.min}.` };
|
|
115
|
-
return false;
|
|
116
|
-
}
|
|
117
|
-
if (typeof rule.max === 'number' && value > rule.max) {
|
|
118
|
-
this._error = { code: 'VALUE_OVERFLOW', message: `The \`${name}\` must be less than or equal to ${rule.max}.` };
|
|
119
|
-
return false;
|
|
120
|
-
}
|
|
121
|
-
if (Array.isArray(rule.enum) && !rule.enum.includes(value)) {
|
|
122
|
-
this._error = { code: 'ENUM_UNMATCH', message: `The \`${name}\` must be any one of ${JSON.stringify(rule.enum)}.` };
|
|
123
|
-
return false;
|
|
124
|
-
}
|
|
125
|
-
return true;
|
|
126
|
-
}
|
|
127
|
-
/**
|
|
128
|
-
* Checks if the value is an integer.
|
|
129
|
-
*
|
|
130
|
-
* @param {unknown} value - The value to check.
|
|
131
|
-
* @param {Rule} rule - The rule object containing validation criteria.
|
|
132
|
-
* @param {string} [name] - The parameter name.
|
|
133
|
-
* @returns {Promise<boolean>} - Resolves to true if the value is valid, false otherwise.
|
|
134
|
-
*/
|
|
135
|
-
async isInteger(value, rule, name = 'value') {
|
|
136
|
-
this._error = null;
|
|
137
|
-
if (!rule.required && !this.isSpecified(value)) {
|
|
138
|
-
return true;
|
|
139
|
-
}
|
|
140
|
-
if (Number.isInteger(value)) {
|
|
141
|
-
return true;
|
|
142
|
-
}
|
|
143
|
-
this._error = { code: 'TYPE_INVALID', message: `The \`${name}\` must be an integer.` };
|
|
144
|
-
return false;
|
|
145
|
-
}
|
|
146
|
-
/**
|
|
147
|
-
* Checks if the value is a boolean.
|
|
148
|
-
*
|
|
149
|
-
* @param {unknown} value - The value to check.
|
|
150
|
-
* @param {Rule} rule - The rule object containing validation criteria.
|
|
151
|
-
* @param {string} [name] - The parameter name.
|
|
152
|
-
* @returns {Promise<boolean>} - Resolves to true if the value is valid, false otherwise.
|
|
153
|
-
*/
|
|
154
|
-
async isBoolean(value, rule, name = 'value') {
|
|
155
|
-
this._error = null;
|
|
156
|
-
if (!rule.required && !this.isSpecified(value)) {
|
|
157
|
-
return true;
|
|
158
|
-
}
|
|
159
|
-
if (typeof value !== 'boolean') {
|
|
160
|
-
this._error = { code: 'TYPE_INVALID', message: `The \`${name}\` must be boolean.` };
|
|
161
|
-
return false;
|
|
162
|
-
}
|
|
163
|
-
return true;
|
|
164
|
-
}
|
|
165
|
-
/**
|
|
166
|
-
* Checks if the value is an object.
|
|
167
|
-
*
|
|
168
|
-
* @param {unknown} value - The value to check.
|
|
169
|
-
* @param {Rule} rule - The rule object containing validation criteria.
|
|
170
|
-
* @param {string} [name] - The parameter name.
|
|
171
|
-
* @returns {Promise<boolean>} - Resolves to true if the value is valid, false otherwise.
|
|
172
|
-
*/
|
|
173
|
-
async isObject(value, rule, name = 'value') {
|
|
174
|
-
this._error = null;
|
|
175
|
-
if (!rule.required && !this.isSpecified(value)) {
|
|
176
|
-
return true;
|
|
177
|
-
}
|
|
178
|
-
if (typeof value !== 'object' || value === null || Array.isArray(value)) {
|
|
179
|
-
this._error = { code: 'TYPE_INVALID', message: `The \`${name}\` must be an object.` };
|
|
180
|
-
return false;
|
|
181
|
-
}
|
|
182
|
-
return true;
|
|
183
|
-
}
|
|
184
|
-
/**
|
|
185
|
-
* Checks if the value is an array.
|
|
186
|
-
*
|
|
187
|
-
* @param {unknown} value - The value to check.
|
|
188
|
-
* @param {Rule} rule - The rule object containing validation criteria.
|
|
189
|
-
* @param {string} [name] - The parameter name.
|
|
190
|
-
* @returns {Promise<boolean>} - Resolves to true if the value is valid, false otherwise.
|
|
191
|
-
*/
|
|
192
|
-
async isArray(value, rule, name = 'value') {
|
|
193
|
-
this._error = null;
|
|
194
|
-
if (!rule.required && !this.isSpecified(value)) {
|
|
195
|
-
return true;
|
|
196
|
-
}
|
|
197
|
-
if (!Array.isArray(value)) {
|
|
198
|
-
this._error = { code: 'TYPE_INVALID', message: 'The value must be an array.' };
|
|
199
|
-
return false;
|
|
200
|
-
}
|
|
201
|
-
if (typeof rule.min === 'number' && value.length < rule.min) {
|
|
202
|
-
this._error = { code: 'LENGTH_UNDERFLOW', message: `The number of elements in the \`${name}\` must be greater than or equal to ${rule.min}.` };
|
|
203
|
-
return false;
|
|
204
|
-
}
|
|
205
|
-
if (typeof rule.max === 'number' && value.length > rule.max) {
|
|
206
|
-
this._error = { code: 'LENGTH_OVERFLOW', message: `The number of elements in the \`${name}\` must be less than or equal to ${rule.max}.` };
|
|
207
|
-
return false;
|
|
208
|
-
}
|
|
209
|
-
return true;
|
|
210
|
-
}
|
|
211
|
-
/**
|
|
212
|
-
* Checks if the value is a string.
|
|
213
|
-
*
|
|
214
|
-
* @param {unknown} value - The value to check.
|
|
215
|
-
* @param {Rule} rule - The rule object containing validation criteria.
|
|
216
|
-
* @param {string} [name] - The parameter name.
|
|
217
|
-
* @returns {Promise<boolean>} - Resolves to true if the value is valid, false otherwise.
|
|
218
|
-
*/
|
|
219
|
-
async isString(value, rule, name = 'value') {
|
|
220
|
-
this._error = null;
|
|
221
|
-
if (!rule.required && !this.isSpecified(value)) {
|
|
222
|
-
return true;
|
|
223
|
-
}
|
|
224
|
-
if (typeof value !== 'string') {
|
|
225
|
-
this._error = { code: 'TYPE_INVALID', message: 'The value must be a string.' };
|
|
226
|
-
return false;
|
|
227
|
-
}
|
|
228
|
-
if (typeof rule.min === 'number' && value.length < rule.min) {
|
|
229
|
-
this._error = { code: 'LENGTH_UNDERFLOW', message: `The number of characters in the \`${name}\` must be greater than or equal to ${rule.min}.` };
|
|
230
|
-
return false;
|
|
231
|
-
}
|
|
232
|
-
if (typeof rule.max === 'number' && value.length > rule.max) {
|
|
233
|
-
this._error = { code: 'LENGTH_OVERFLOW', message: `The number of characters in the \`${name}\` must be less than or equal to ${rule.max}.` };
|
|
234
|
-
return false;
|
|
235
|
-
}
|
|
236
|
-
if (typeof rule.minBytes === 'number') {
|
|
237
|
-
const blen = Buffer.from(value, 'utf8').length;
|
|
238
|
-
if (blen < rule.minBytes) {
|
|
239
|
-
this._error = { code: 'LENGTH_UNDERFLOW', message: `The byte length of the \`${name}\` (${blen} bytes) must be greater than or equal to ${rule.minBytes} bytes.` };
|
|
240
|
-
return false;
|
|
241
|
-
}
|
|
242
|
-
}
|
|
243
|
-
if (typeof rule.maxBytes === 'number') {
|
|
244
|
-
const blen = Buffer.from(value, 'utf8').length;
|
|
245
|
-
if (blen > rule.maxBytes) {
|
|
246
|
-
this._error = { code: 'LENGTH_OVERFLOW', message: `The byte length of the \`${name}\` (${blen} bytes) must be less than or equal to ${rule.maxBytes} bytes.` };
|
|
247
|
-
return false;
|
|
248
|
-
}
|
|
249
|
-
}
|
|
250
|
-
if (rule.pattern instanceof RegExp && !rule.pattern.test(value)) {
|
|
251
|
-
this._error = { code: 'PATTERN_UNMATCH', message: `The \`${name}\` does not conform with the pattern.` };
|
|
252
|
-
return false;
|
|
253
|
-
}
|
|
254
|
-
if (Array.isArray(rule.enum) && !rule.enum.includes(value)) {
|
|
255
|
-
this._error = { code: 'ENUM_UNMATCH', message: `The \`${name}\` must be any one of ${JSON.stringify(rule.enum)}.` };
|
|
256
|
-
return false;
|
|
257
|
-
}
|
|
258
|
-
return true;
|
|
259
|
-
}
|
|
260
|
-
}
|
|
261
|
-
export const parameterChecker = new ParameterChecker();
|
|
262
|
-
//# sourceMappingURL=parameter-checker.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"parameter-checker.js","sourceRoot":"","sources":["../src/parameter-checker.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAA;AACpC;;;GAGG;AACH,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;AAE1C,MAAM,OAAO,gBAAiB,SAAQ,YAAY;IACxC,MAAM,GAAuB,IAAI,CAA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AO,KAAK,CAAA;YACd,CAAC;QACH,CAAC;QAED,IAAI,IAAI,CAAC,OAAO,YAAY,MAAM,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC;YAChE,IAAI,CAAC,MAAM,GAAG,EAAE,IAAI,EAAE,iBAAiB,EAAE,OAAO,EAAE,SAAS,IAAI,uCAAuC,EAAE,CAAA;YACxG,OAAO,KAAK,CAAA;QACd,CAAC;QAED,IAAI,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,EAAE,CAAC;YAC3D,IAAI,CAAC,MAAM,GAAG,EAAE,IAAI,EAAE,cAAc,EAAE,OAAO,EAAE,SAAS,IAAI,yBAAyB,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE,CAAA;YACnH,OAAO,KAAK,CAAA;QACd,CAAC;QAED,OAAO,IAAI,CAAA;IACb,CAAC;CACF;AAED,MAAM,CAAC,MAAM,gBAAgB,GAAG,IAAI,gBAAgB,EAAE,CAAA"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"parameter-checker.test.d.ts","sourceRoot":"","sources":["../src/parameter-checker.test.ts"],"names":[],"mappings":""}
|
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
import { describe, expect, it } from 'vitest';
|
|
2
|
-
import { ParameterChecker } from './parameter-checker.js';
|
|
3
|
-
describe('parameterChecker', () => {
|
|
4
|
-
it('should pass with empty rules and no required object', async () => {
|
|
5
|
-
const checker = new ParameterChecker();
|
|
6
|
-
const result = await checker.check({}, {}, false);
|
|
7
|
-
expect(result).toBe(true);
|
|
8
|
-
expect(checker.error).toBeNull();
|
|
9
|
-
});
|
|
10
|
-
it('should fail when required object is missing', async () => {
|
|
11
|
-
const checker = new ParameterChecker();
|
|
12
|
-
const result = await checker.check(undefined, {}, true);
|
|
13
|
-
expect(result).toBe(false);
|
|
14
|
-
expect(checker.error?.code).toBe('MISSING_REQUIRED');
|
|
15
|
-
});
|
|
16
|
-
it('should fail when required field is missing', async () => {
|
|
17
|
-
const checker = new ParameterChecker();
|
|
18
|
-
const rules = {
|
|
19
|
-
name: { type: 'string', required: true },
|
|
20
|
-
};
|
|
21
|
-
const result = await checker.check({}, rules);
|
|
22
|
-
expect(result).toBe(false);
|
|
23
|
-
expect(checker.error?.code).toBe('MISSING_REQUIRED');
|
|
24
|
-
});
|
|
25
|
-
it('should fail on type mismatch for integer', async () => {
|
|
26
|
-
const checker = new ParameterChecker();
|
|
27
|
-
const rules = {
|
|
28
|
-
age: { type: 'integer', required: true },
|
|
29
|
-
};
|
|
30
|
-
const result = await checker.check({ age: 25.5 }, rules);
|
|
31
|
-
expect(result).toBe(false);
|
|
32
|
-
expect(checker.error?.code).toBe('TYPE_INVALID');
|
|
33
|
-
});
|
|
34
|
-
it('should enforce float min and max', async () => {
|
|
35
|
-
const checker = new ParameterChecker();
|
|
36
|
-
const rules = {
|
|
37
|
-
temperature: { type: 'float', min: 0, max: 100 },
|
|
38
|
-
};
|
|
39
|
-
let result = await checker.check({ temperature: -5 }, rules);
|
|
40
|
-
expect(result).toBe(false);
|
|
41
|
-
expect(checker.error?.code).toBe('VALUE_UNDERFLOW');
|
|
42
|
-
result = await checker.check({ temperature: 150 }, rules);
|
|
43
|
-
expect(result).toBe(false);
|
|
44
|
-
expect(checker.error?.code).toBe('VALUE_OVERFLOW');
|
|
45
|
-
});
|
|
46
|
-
it('should ignore extra parameters', async () => {
|
|
47
|
-
const checker = new ParameterChecker();
|
|
48
|
-
const rules = {
|
|
49
|
-
id: { type: 'integer' },
|
|
50
|
-
};
|
|
51
|
-
const result = await checker.check({ id: 1, extra: 'ignored' }, rules);
|
|
52
|
-
expect(result).toBe(true);
|
|
53
|
-
expect(checker.error).toBeNull();
|
|
54
|
-
});
|
|
55
|
-
});
|
|
56
|
-
//# sourceMappingUR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O,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC,IAAI,CAAC,iBAAiB,CAAC,CAAA;QAEnD,MAAM,GAAG,MAAM,OAAO,CAAC,KAAK,CAAC,EAAE,WAAW,EAAE,GAAG,EAAE,EAAE,KAAK,CAAC,CAAA;QACzD,MAAM,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAA;QAC1B,MAAM,CAAC,OAAO,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC,IAAI,CAAC,gBAAgB,CAAC,CAAA;IACpD,CAAC,CAAC,CAAA;IAEF,EAAE,CAAC,gCAAgC,EAAE,KAAK,IAAI,EAAE;QAC9C,MAAM,OAAO,GAAG,IAAI,gBAAgB,EAAE,CAAA;QACtC,MAAM,KAAK,GAAyB;YAClC,EAAE,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE;SACxB,CAAA;QACD,MAAM,MAAM,GAAG,MAAM,OAAO,CAAC,KAAK,CAAC,EAAE,EAAE,EAAE,CAAC,EAAE,KAAK,EAAE,SAAS,EAAE,EAAE,KAAK,CAAC,CAAA;QACtE,MAAM,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;QACzB,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,QAAQ,EAAE,CAAA;IAClC,CAAC,CAAC,CAAA;AACJ,CAAC,CAAC,CAAA"}
|
package/dist/settings.test.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"settings.test.d.ts","sourceRoot":"","sources":["../src/settings.test.ts"],"names":[],"mappings":""}
|
package/dist/settings.test.js
DELETED
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
import { describe, expect, it } from 'vitest';
|
|
2
|
-
import { CHAR_UUID_DEVICE, CHAR_UUID_NOTIFY, CHAR_UUID_WRITE, COMMAND_TIMEOUT_MSEC, READ_TIMEOUT_MSEC, SERV_UUID_PRIMARY, updateBaseURL, urls, WoSmartLockCommands, WoSmartLockProCommands, WRITE_TIMEOUT_MSEC, } from './settings.js';
|
|
3
|
-
describe('switchBot API Settings', () => {
|
|
4
|
-
it('should have correct Devices URL', () => {
|
|
5
|
-
expect(urls.devicesURL).toBe('https://api.switch-bot.com/v1.1/devices');
|
|
6
|
-
});
|
|
7
|
-
it('should have correct setupWebhook URL', () => {
|
|
8
|
-
expect(urls.setupWebhook).toBe('https://api.switch-bot.com/v1.1/webhook/setupWebhook');
|
|
9
|
-
});
|
|
10
|
-
it('should have correct queryWebhook URL', () => {
|
|
11
|
-
expect(urls.queryWebhook).toBe('https://api.switch-bot.com/v1.1/webhook/queryWebhook');
|
|
12
|
-
});
|
|
13
|
-
it('should have correct updateWebhook URL', () => {
|
|
14
|
-
expect(urls.updateWebhook).toBe('https://api.switch-bot.com/v1.1/webhook/updateWebhook');
|
|
15
|
-
});
|
|
16
|
-
it('should have correct deleteWebhook URL', () => {
|
|
17
|
-
expect(urls.deleteWebhook).toBe('https://api.switch-bot.com/v1.1/webhook/deleteWebhook');
|
|
18
|
-
});
|
|
19
|
-
it('should have correct BLE API constants', () => {
|
|
20
|
-
expect(SERV_UUID_PRIMARY).toBe('cba20d00224d11e69fb80002a5d5c51b');
|
|
21
|
-
expect(CHAR_UUID_WRITE).toBe('cba20002224d11e69fb80002a5d5c51b');
|
|
22
|
-
expect(CHAR_UUID_NOTIFY).toBe('cba20003224d11e69fb80002a5d5c51b');
|
|
23
|
-
expect(CHAR_UUID_DEVICE).toBe('2a00');
|
|
24
|
-
});
|
|
25
|
-
it('should have correct timeout constants', () => {
|
|
26
|
-
expect(READ_TIMEOUT_MSEC).toBe(3000);
|
|
27
|
-
expect(WRITE_TIMEOUT_MSEC).toBe(3000);
|
|
28
|
-
expect(COMMAND_TIMEOUT_MSEC).toBe(3000);
|
|
29
|
-
});
|
|
30
|
-
it('should have correct WoSmartLockProCommands', () => {
|
|
31
|
-
expect(WoSmartLockProCommands.GET_CKIV).toBe('570f2103');
|
|
32
|
-
expect(WoSmartLockProCommands.LOCK_INFO).toBe('570f4f8102');
|
|
33
|
-
expect(WoSmartLockProCommands.UNLOCK).toBe('570f4e0101000080');
|
|
34
|
-
expect(WoSmartLockProCommands.UNLOCK_NO_UNLATCH).toBe('570f4e01010000a0');
|
|
35
|
-
expect(WoSmartLockProCommands.LOCK).toBe('570f4e0101000000');
|
|
36
|
-
expect(WoSmartLockProCommands.ENABLE_NOTIFICATIONS).toBe('570e01001e00008101');
|
|
37
|
-
expect(WoSmartLockProCommands.DISABLE_NOTIFICATIONS).toBe('570e00');
|
|
38
|
-
});
|
|
39
|
-
it('should have correct WoSmartLockCommands', () => {
|
|
40
|
-
expect(WoSmartLockCommands.GET_CKIV).toBe('570f2103');
|
|
41
|
-
expect(WoSmartLockCommands.LOCK_INFO).toBe('570f4f8101');
|
|
42
|
-
expect(WoSmartLockCommands.UNLOCK).toBe('570f4e01011080');
|
|
43
|
-
expect(WoSmartLockCommands.UNLOCK_NO_UNLATCH).toBe('570f4e010110a0');
|
|
44
|
-
expect(WoSmartLockCommands.LOCK).toBe('570f4e01011000');
|
|
45
|
-
expect(WoSmartLockCommands.ENABLE_NOTIFICATIONS).toBe('570e01001e00008101');
|
|
46
|
-
expect(WoSmartLockCommands.DISABLE_NOTIFICATIONS).toBe('570e00');
|
|
47
|
-
});
|
|
48
|
-
it('should update URLs when baseURL is changed', () => {
|
|
49
|
-
const original = urls.baseURL;
|
|
50
|
-
const custom = 'https://custom.api';
|
|
51
|
-
updateBaseURL(custom);
|
|
52
|
-
expect(urls.devicesURL).toBe(`${custom}/v1.1/devices`);
|
|
53
|
-
expect(urls.setupWebhook).toBe(`${custom}/v1.1/webhook/setupWebhook`);
|
|
54
|
-
expect(urls.queryWebhook).toBe(`${custom}/v1.1/webhook/queryWebhook`);
|
|
55
|
-
expect(urls.updateWebhook).toBe(`${custom}/v1.1/webhook/updateWebhook`);
|
|
56
|
-
expect(urls.deleteWebhook).toBe(`${custom}/v1.1/webhook/deleteWebhook`);
|
|
57
|
-
// restore original baseURL
|
|
58
|
-
updateBaseURL(original);
|
|
59
|
-
});
|
|
60
|
-
});
|
|
61
|
-
//# sourceMappingURL=settings.test.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"settings.test.js","sourceRoot":"","sources":["../src/settings.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,QAAQ,CAAA;AAE7C,OAAO,EACL,gBAAgB,EAChB,gBAAgB,EAChB,eAAe,EACf,oBAAoB,EACpB,iBAAiB,EACjB,iBAAiB,EACjB,aAAa,EACb,IAAI,EACJ,mBAAmB,EACnB,sBAAsB,EACtB,kBAAkB,GACnB,MAAM,eAAe,CAAA;AAEtB,QAAQ,CAAC,wBAAwB,EAAE,GAAG,EAAE;IACtC,EAAE,CAAC,iCAAiC,EAAE,GAAG,EAAE;QACzC,MAAM,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC,IAAI,CAAC,yCAAyC,CAAC,CAAA;IACzE,CAAC,CAAC,CAAA;IAEF,EAAE,CAAC,sCAAsC,EAAE,GAAG,EAAE;QAC9C,MAAM,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC,IAAI,CAAC,sDAAsD,CAAC,CAAA;IACxF,CAAC,CAAC,CAAA;IAEF,EAAE,CAAC,sCAAsC,EAAE,GAAG,EAAE;QAC9C,MAAM,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC,IAAI,CAAC,sDAAsD,CAAC,CAAA;IACxF,CAAC,CAAC,CAAA;IAEF,EAAE,CAAC,uCAAuC,EAAE,GAAG,EAAE;QAC/C,MAAM,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC,IAAI,CAAC,uDAAuD,CAAC,CAAA;IAC1F,CAAC,CAAC,CAAA;IAEF,EAAE,CAAC,uCAAuC,EAAE,GAAG,EAAE;QAC/C,MAAM,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC,IAAI,CAAC,uDAAuD,CAAC,C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CAAC,GAAG,MAAM,6BAA6B,CAAC,CAAA;QACvE,MAAM,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC,IAAI,CAAC,GAAG,MAAM,6BAA6B,CAAC,CAAA;QACvE,2BAA2B;QAC3B,aAAa,CAAC,QAAQ,CAAC,CAAA;IACzB,CAAC,CAAC,CAAA;AACJ,CAAC,CAAC,CAAA"}
|
package/dist/switchbot-ble.d.ts
DELETED
|
@@ -1,89 +0,0 @@
|
|
|
1
|
-
import type { onadvertisement, ondiscover, Params } from './device.js';
|
|
2
|
-
import { EventEmitter } from 'node:events';
|
|
3
|
-
import { LogLevel, SwitchbotDevice } from './device.js';
|
|
4
|
-
/**
|
|
5
|
-
* SwitchBotBLE class to interact with SwitchBot devices.
|
|
6
|
-
*/
|
|
7
|
-
export declare class SwitchBotBLE extends EventEmitter {
|
|
8
|
-
nobleInitialized: Promise<void>;
|
|
9
|
-
noble: any;
|
|
10
|
-
ondiscover?: ondiscover;
|
|
11
|
-
onadvertisement?: onadvertisement;
|
|
12
|
-
/**
|
|
13
|
-
* Constructor
|
|
14
|
-
*
|
|
15
|
-
* @param {Params} [params] - Optional parameters
|
|
16
|
-
*/
|
|
17
|
-
constructor(params?: Params);
|
|
18
|
-
/**
|
|
19
|
-
* Emits a log event with the specified log level and message.
|
|
20
|
-
*
|
|
21
|
-
* @param level - The severity level of the log (e.g., 'info', 'warn', 'error').
|
|
22
|
-
* @param message - The log message to be emitted.
|
|
23
|
-
*/
|
|
24
|
-
/**
|
|
25
|
-
* Emits a log event with a defined LogLevel.
|
|
26
|
-
*/
|
|
27
|
-
log(level: LogLevel, message: string): void;
|
|
28
|
-
/**
|
|
29
|
-
* Initializes the noble object.
|
|
30
|
-
*
|
|
31
|
-
* @param {Params} [params] - Optional parameters
|
|
32
|
-
* @returns {Promise<void>} - Resolves when initialization is complete
|
|
33
|
-
*/
|
|
34
|
-
private initialize;
|
|
35
|
-
/**
|
|
36
|
-
* Validates the parameters.
|
|
37
|
-
*
|
|
38
|
-
* @param {Params} params - The parameters to validate.
|
|
39
|
-
* @param {Record<string, unknown>} schema - The schema to validate against.
|
|
40
|
-
* @returns {Promise<void>} - Resolves if parameters are valid, otherwise throws an error.
|
|
41
|
-
*/
|
|
42
|
-
validate(params: Params, schema: Record<string, unknown>): Promise<void>;
|
|
43
|
-
/**
|
|
44
|
-
* Discovers Switchbot devices with enhanced error handling and logging.
|
|
45
|
-
* @param params The discovery parameters.
|
|
46
|
-
* @returns A Promise that resolves with an array of discovered Switchbot devices.
|
|
47
|
-
*/
|
|
48
|
-
discover(params?: Params): Promise<SwitchbotDevice[]>;
|
|
49
|
-
/**
|
|
50
|
-
* Creates a device object based on the peripheral, id, and model.
|
|
51
|
-
*
|
|
52
|
-
* @param {NobleTypes['peripheral']} peripheral - The peripheral object.
|
|
53
|
-
* @param {string} id - The device id.
|
|
54
|
-
* @param {string} model - The device model.
|
|
55
|
-
* @returns {Promise<SwitchbotDevice | null>} - The device object or null.
|
|
56
|
-
*/
|
|
57
|
-
private createDevice;
|
|
58
|
-
/**
|
|
59
|
-
* Filters advertising data based on id and model.
|
|
60
|
-
*
|
|
61
|
-
* @param {Ad} ad - The advertising data.
|
|
62
|
-
* @param {string} id - The device id.
|
|
63
|
-
* @param {string} model - The device model.
|
|
64
|
-
* @returns {Promise<boolean>} - True if the advertising data matches the id and model, false otherwise.
|
|
65
|
-
*/
|
|
66
|
-
private filterAd;
|
|
67
|
-
/**
|
|
68
|
-
* Starts scanning for SwitchBot devices.
|
|
69
|
-
*
|
|
70
|
-
* @param {Params} [params] - Optional parameters.
|
|
71
|
-
* @returns {Promise<void>} - Resolves when scanning starts successfully.
|
|
72
|
-
*/
|
|
73
|
-
startScan(params?: Params): Promise<void>;
|
|
74
|
-
/**
|
|
75
|
-
* Stops scanning for SwitchBot devices.
|
|
76
|
-
*
|
|
77
|
-
* @returns {Promise<void>} - Resolves when scanning stops successfully.
|
|
78
|
-
*/
|
|
79
|
-
stopScan(): Promise<void>;
|
|
80
|
-
/**
|
|
81
|
-
* Waits for the specified time.
|
|
82
|
-
*
|
|
83
|
-
* @param {number} msec - The time to wait in milliseconds.
|
|
84
|
-
* @returns {Promise<void>} - Resolves after the specified time.
|
|
85
|
-
*/
|
|
86
|
-
wait(msec: number): Promise<void>;
|
|
87
|
-
}
|
|
88
|
-
export { LogLevel, SwitchbotDevice };
|
|
89
|
-
//# sourceMappingURL=switchbot-ble.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"switchbot-ble.d.ts","sourceRoot":"","sources":["../src/switchbot-ble.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAkB,eAAe,EAAE,UAAU,EAAE,MAAM,EAAQ,MAAM,aAAa,CAAA;AAE5F,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;AAE1C,OAAO,EAAe,QAAQ,EAAqB,eAAe,EAAuU,MAAM,aAAa,CAAA;AAI5Z;;GAEG;AACH,qBAAa,YAAa,SAAQ,YAAY;IACrC,gBAAgB,EAAE,OAAO,CAAC,IAAI,CAAC,CAAA;IAC/B,KAAK,EAAE,GAAG,CAAA;IACjB,UAAU,CAAC,EAAE,UAAU,CAAA;IACvB,eAAe,CAAC,EAAE,eAAe,CAAA;IAEjC;;;;OAIG;gBACS,MAAM,CAAC,EAAE,MAAM;IAK3B;;;;;OAKG;IACH;;OAEG;IACI,GAAG,CAAC,KAAK,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,GAAG,IAAI;IAKlD;;;;;OAKG;YACW,UAAU;IAmBxB;;;;;;OAMG;IACU,QAAQ,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC;IAQrF;;;;OAIG;IACU,QAAQ,CAAC,MAAM,GAAE,MAAW,GAAG,OAAO,CAAC,eAAe,EAAE,CAAC;IA4GtE;;;;;;;OAOG;YACW,YAAY;IAuC1B;;;;;;;O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