UNPKG

dbus-sdk

Version:

A Node.js SDK for interacting with DBus, enabling seamless service calling and exposure with TypeScript support

100 lines 6.08 kB
import { DBusInterfaceOpts } from './types/DBusInterfaceOpts'; import { DBus } from './DBus'; import { DBusService } from './DBusService'; import { DBusObject } from './DBusObject'; import { IntrospectInterface } from './types/IntrospectInterface'; import { IntrospectMethod } from './types/IntrospectMethod'; import { IntrospectProperty } from './types/IntrospectProperty'; import { IntrospectSignal } from './types/IntrospectSignal'; import { ReplyModeMethodCall } from './types/ReplyModeMethodCall'; import { NoReplyModeMethodCall } from './types/NoReplyModeMethodCall'; import { PropertyOperation } from './types/PropertyOperation'; import { DBusSignalEmitter } from './lib/DBusSignalEmitter'; import { ReplyModeParameterObjectMethodCall } from './types/ReplyModeParameterObjectMethodCall'; import { NoReplyModeParameterObjectMethodCall } from './types/NoReplyModeParameterObjectMethodCall'; export declare class DBusInterface { #private; protected readonly opts: DBusInterfaceOpts; protected readonly dbus: DBus; protected readonly service: DBusService; protected readonly object: DBusObject; protected readonly introspectInterface: IntrospectInterface; readonly name: string; /** * Constructor for DBusInterface. * Initializes the DBus interface with the provided options and sets up references to the DBus connection, * service, object, and introspection data. * @param opts - Configuration options for the DBus interface. */ constructor(opts: DBusInterfaceOpts); /** * Converts a parameter object to an array of arguments based on introspection data. * Extracts input parameters from the provided parameter object, mapping them to the expected order of arguments * for a given method as defined in the introspection metadata. If a required parameter is missing, an error is thrown. * @param methodInfo - The introspection metadata of the method, containing argument definitions. * @param inputParameterObject - The parameter object containing named arguments to be mapped. * @returns An array of arguments extracted from the parameter object, ordered according to the method's signature. * @throws {NotEnoughParamsError} If a required parameter is missing from the input object. */ protected objectifiedParameterToArguments(methodInfo: IntrospectMethod, inputParameterObject: Record<string, any>): any[]; /** * Getter for methods with reply mode. * Dynamically creates an object containing methods that expect a reply from the DBus invocation. * Each method handles input arguments with type signatures and returns the result of the invocation. * @returns A record of method names mapped to their callable implementations with reply mode. */ get method(): Record<string, ReplyModeMethodCall>; /** * Getter for methods with reply mode using parameter object pattern. * Dynamically creates an object containing methods that expect a reply from the DBus invocation. * Each method accepts a single parameter object containing named arguments, which are mapped to the expected input parameters * based on the introspection data. This approach enhances readability and avoids errors due to parameter order. * @returns A record of method names mapped to their callable implementations with reply mode, accepting a parameter object. */ get parameterObjectifyMethod(): Record<string, ReplyModeParameterObjectMethodCall>; /** * Getter for methods with no-reply mode. * Dynamically creates an object containing methods that do not expect a reply from the DBus invocation. * These methods are used for fire-and-forget calls. * @returns A record of method names mapped to their callable implementations with no-reply mode. */ get noReplyMethod(): Record<string, NoReplyModeMethodCall>; /** * Getter for methods with no-reply mode using parameter object pattern. * Dynamically creates an object containing methods that do not expect a reply from the DBus invocation. * Each method accepts a single parameter object containing named arguments, which are mapped to the expected input parameters * based on the introspection data. This approach enhances readability and avoids errors due to parameter order. * These methods are used for fire-and-forget calls. * @returns A record of method names mapped to their callable implementations with no-reply mode, accepting a parameter object. */ get parameterObjectifyNoReplyMethod(): Record<string, NoReplyModeParameterObjectMethodCall>; /** * Getter for properties of the DBus interface. * Dynamically creates an object containing property operations (get/set) for each property defined in the introspection data. * Access control is enforced based on property access mode (read/write/readwrite). * @returns A record of property names mapped to their get/set operations. */ get property(): Record<string, PropertyOperation>; /** * Getter for the DBus signal emitter. * Lazily initializes and returns a signal emitter for emitting signals associated with this interface. * @returns A DBusSignalEmitter instance for handling signal emissions. */ get signal(): DBusSignalEmitter; /** * Lists all methods defined in the introspection data for this interface. * @returns An array of IntrospectMethod objects representing the methods of this interface. */ listMethods(): IntrospectMethod[]; /** * Lists all properties defined in the introspection data for this interface. * @returns An array of IntrospectProperty objects representing the properties of this interface. */ listProperties(): IntrospectProperty[]; /** * Lists all signals defined in the introspection data for this interface. * @returns An array of IntrospectSignal objects representing the signals of this interface. */ listSignals(): IntrospectSignal[]; } //# sourceMappingURL=DBusInterface.d.ts.map