import { ScryptedInterface , ScryptedInterfaceDescriptors } from "@scrypted/sdk/types" ; export const allInterfaceMethods = [ ] . concat ( ... Object . values ( ScryptedInterfaceDescriptors ) . map ( ( type ) => type . methods ) ) ; export const allInterfaceProperties = [ ] . concat ( ... Object . values ( ScryptedInterfaceDescriptors ) . map ( ( type ) => type . properties ) ) ; export const deviceMethods = [ 'listen' , 'setName' , 'setRoom' , 'setType' ] ; export const methodInterfaces = { } ; for ( const desc of Object . values ( ScryptedInterfaceDescriptors ) ) { for ( const method of desc . methods ) { methodInterfaces [ method ] = desc . name ; } } export const propertyInterfaces = { } ; for ( const descriptor of Object . values ( ScryptedInterfaceDescriptors ) ) { for ( const property of descriptor . properties ) { propertyInterfaces [ property ] = descriptor . name as ScryptedInterface ; } } export function isValidInterfaceMethod ( interfaces , method ) { const availableMethods = [ ] . concat ( ... Object . values ( ScryptedInterfaceDescriptors ) . filter ( ( e ) => interfaces . includes ( e . name ) ) . map ( ( type ) => type . methods ) ) ; return availableMethods . includes ( method ) || ScryptedInterfaceDescriptors [ ScryptedInterface . ScryptedDevice ] . methods . includes ( method ) ; } export function isValidInterfaceProperty ( interfaces , property ) { const availableProperties = [ ] . concat ( ... Object . values ( ScryptedInterfaceDescriptors ) . filter ( ( e ) => interfaces . includes ( e . name ) ) . map ( ( type ) => type . properties ) ) ; return availableProperties . includes ( property ) ; }