import type { CommandClasses } from "@zwave-js/core"; import type { BytesView, Expand } from "@zwave-js/shared"; import type { ApplicationCCsFile, ApplicationRFConfigFile, ApplicationTypeFile, ControllerInfoFile, LRNodeInfo, NodeInfo } from "../nvm3/files/index.js"; import type { Route } from "./routeCache.js"; import type { SUCUpdateEntry } from "./sucUpdateEntry.js"; export declare enum NVMAccess { None = 0, Read = 1, Write = 2, ReadWrite = 3 } /** Provides an abstraction to access the contents of an NVM at the binary level */ export interface NVMIO { /** * Opens the NVM for reading and/or writing. * Since different NVM implementations may or may not allow reading and writing at the same time, * the returned value indicates which access patterns are actually allowed. */ open(access: NVMAccess.Read | NVMAccess.Write): Promise; /** Returns the size of the NVM, after it has been opened */ get size(): number; /** Returns which access is currently allowed for this NVM implementation */ get accessMode(): NVMAccess; /** * Determines the size of the data chunks that can be used for writing. * Requires the NVM to be readable. */ determineChunkSize(): Promise; /** * Reads a chunk of data with the given length from the NVM. * If the length is longer than the chunk size, or the end of the NVM is reached, * the returned buffer will be shorter than the requested length. */ read(offset: number, length: number): Promise<{ buffer: BytesView; endOfFile: boolean; }>; /** * Writes a chunk of data with the given length from the NVM. * The returned value indicates how many bytes were actually written. */ write(offset: number, data: BytesView): Promise<{ bytesWritten: number; endOfFile: boolean; }>; /** Closes the NVM */ close(): Promise; } /** A specific NVM implementation */ export interface NVM { /** Checks if a property exists in the NVM */ has(property: ID): Promise; /** Reads a property from the NVM */ get(property: ID): Promise; /** Writes a property to the NVM */ set(property: ID, value: Data): Promise; /** Deletes the property from the NVM */ delete(property: ID): Promise; } /** * Provides an application-level abstraction over an NVM implementation */ export interface NVMAdapter { /** Reads a property from the NVM */ get(property: T, required?: R): Promise : (NVMPropertyToDataType | undefined)>; /** * Changes a property to be written to the NVM later */ set(property: T, value: NVMPropertyToDataType): Promise; /** * Marks a property for deletion from the NVM. In some implementations, * deleting one property may delete multiple properties that are stored together. */ delete(property: NVMProperty): Promise; /** Returns whether there are pending changes that weren't written to the NVM yet */ hasPendingChanges(): boolean; /** Writes all pending changes to the NVM */ commit(): Promise; } export type ControllerNVMPropertyTypes = Expand<{ protocolVersion: string; protocolFileFormat: number; applicationVersion: string; applicationData: BytesView; preferredRepeaters?: number[]; sucUpdateEntries: SUCUpdateEntry[]; appRouteLock: number[]; routeSlaveSUC: number[]; sucPendingUpdate: number[]; pendingDiscovery: number[]; virtualNodeIds: number[]; nodeIds: number[]; } & Partial<{ applicationFileFormat: number; applicationName: string; lrNodeIds: number[]; }> & Partial<{ learnedHomeId: BytesView; commandClasses: CommandClasses[]; systemState: number; watchdogStarted: number; powerLevelNormal: number[]; powerLevelLow: number[]; powerMode: number; powerModeExtintEnable: number; powerModeWutTimeout: number; }> & Pick & Partial> & Partial> & Partial>>; export interface NodeNVMPropertyTypes { info: NodeInfo; routes: { lwr?: Route; nlwr?: Route; }; } export interface LRNodeNVMPropertyTypes { info: LRNodeInfo; } export type ControllerNVMProperty = { domain: "controller"; type: keyof ControllerNVMPropertyTypes; nodeId?: undefined; }; export type ControllerNVMPropertyToDataType

= ControllerNVMPropertyTypes[P["type"]]; export type NodeNVMProperty = { domain: "node"; type: keyof NodeNVMPropertyTypes; nodeId: number; }; export type NodeNVMPropertyToDataType

= P["type"] extends keyof NodeNVMPropertyTypes ? NodeNVMPropertyTypes[P["type"]] : never; export type LRNodeNVMProperty = { domain: "lrnode"; type: keyof LRNodeNVMPropertyTypes; nodeId: number; }; export type LRNodeNVMPropertyToDataType

= P["type"] extends keyof LRNodeNVMPropertyTypes ? LRNodeNVMPropertyTypes[P["type"]] : never; export type NVMProperty = ControllerNVMProperty | NodeNVMProperty | LRNodeNVMProperty; export type NVMPropertyToDataType

= P extends ControllerNVMProperty ? ControllerNVMPropertyToDataType

: P extends NodeNVMProperty ? NodeNVMPropertyToDataType

: P extends LRNodeNVMProperty ? LRNodeNVMPropertyToDataType

: never; //# sourceMappingURL=definitions.d.ts.map