mirror of
https://github.com/koush/scrypted.git
synced 2026-02-12 18:12:04 +00:00
19 lines
1.0 KiB
TypeScript
19 lines
1.0 KiB
TypeScript
import { ScryptedInterface, ScryptedInterfaceProperty } from "@scrypted/types";
|
|
import { propertyInterfaces } from "./descriptor";
|
|
|
|
export function checkProperty(key: string, value: any) {
|
|
if (key === ScryptedInterfaceProperty.id)
|
|
throw new Error("id is read only");
|
|
if (key === ScryptedInterfaceProperty.mixins)
|
|
throw new Error("mixins is read only");
|
|
if (key === ScryptedInterfaceProperty.interfaces)
|
|
throw new Error("interfaces is a read only post-mixin computed property, use providedInterfaces");
|
|
const iface = propertyInterfaces[key.toString()];
|
|
if (iface === ScryptedInterface.ScryptedDevice) {
|
|
// only allow info to be set, since that doesn't actually change the descriptor
|
|
// or the provided* properties (room, interfaces, name, type).
|
|
if (key !== ScryptedInterfaceProperty.info)
|
|
throw new Error(`${key.toString()} can not be set. Use DeviceManager.onDevicesChanges or DeviceManager.onDeviceDiscovered to update the device description.`);
|
|
}
|
|
}
|