/** * Type guard to check if an object is of type `StackInfo`. * * This function checks if the provided object contains the necessary properties * (`mac_address`, `stack_serial_number`, and `boards`) and ensures `boards` is an array. * * @param obj - The object to check. * @returns `true` if the object conforms to the `StackInfo` type, otherwise `false`. */ export declare function isStackInfo(obj: any): obj is StackInfo; /** * Type guard to check if an object is of type `HardwareDescription`. * * This function validates if the provided object contains the necessary properties, * including `fileVersion`, a `device` object with `serialNumber`, and optionally an `assembly` property. * * @param obj - The object to check. * @returns `true` if the object conforms to the `HardwareDescription` type, otherwise `false`. */ export declare function isHardwareDescription(obj: any): obj is HardwareDescription; export interface HardwareComponent { name: string; version: string; serialNumber: string; } export type AssemblyComponent = HardwareComponent; export type DeviceComponent = HardwareComponent; export interface Assembly { name: string; id: string; version: string; serialNumber: string; components: AssemblyComponent[]; imageId?: string; } export interface HardwareDevice { name: string; id: string; version: string; keyId: string; serialNumber: string; macAddress: string; components: DeviceComponent[]; imageId?: string; } /** * @link https://docs.google.com/document/d/1bafY-F8qFMLd0Las8fQFF6H9PTVYFjv01bhV7owqx8E */ export interface HardwareDescription { fileVersion: string; assembly?: Assembly; device: HardwareDevice; } /** * Retrieves the ID from the assembly if available; otherwise, falls back to the device ID. * * @example * "9002" */ export declare function getIdFromHardwareDescription(hw: HardwareDescription): string; /** * Constructs the API ID from the hardware description file. * The API ID is a combination of the assembly or device ID, version, and optionally a Key ID, which is used for encrypting firmware binaries. * Note: In the "Hardware Description File Format" document, the API ID is now referred to as FWID for clarity. * @param hd The hardware description object. * @param skipKeyId If true, assembles the API ID without including the Key ID. * @returns An API identifier, such as "9600-02" or "9600-02-2423". */ export declare function getApiIdentifierFromHardwareDescription(hd: HardwareDescription, skipKeyId?: boolean): string; export declare function getNameFromHardwareDescription(hd: HardwareDescription): string; export declare function getSerialNumberFromHardwareDescription(hd: HardwareDescription): string; export declare function getAllComponentsFromHardwareDescription(hd: HardwareDescription): HardwareComponent[]; export declare function getImageIdFromHardwareDescription(hd: HardwareDescription): string | undefined; /** * Verifies if two sets of device components are identical. * Both sets must contain the same number of components, and each component must match by name and version. */ export declare function deviceComponentsMatch(a: DeviceComponent[], b: DeviceComponent[]): boolean; /** * This template is to be used in cases where hardware description file is not available on a device. * It is imperative to replace the serial number with a unique identifier. */ export declare const dummyHardwareDescriptionFileContentTemplate: HardwareDescription; export declare const synapticonSerialNumberRegExp: RegExp; /** * Represents a structured serial number. * * A serial number follows the format: `productId-revision-consecutiveNumber-productionWeek`. * Example: `8506-01-040595-4023` * - `8506` → Product ID * - `01` → Revision * - `040595` → Consecutive Number * - `4023` → Production Week */ export interface SerialNumber { /** * Unique consecutive number assigned to the product. * Example: `040595` */ consecutiveNumber: string; /** * Identifier for the product model or type. * Example: `8506` */ productId: string; /** * Week and year of production. * Example: `4023` (Week 40 of the year 2023) */ productionWeek: string; /** * Revision number indicating product iteration or version. * Example: `01` */ revision: string; /** * Combined product identifier including revision. * Example: `8506-01` */ versionedProductId: string; } /** * Parses a serial number and returns an instance of {@link SerialNumber}. * * @throws {Error} Throws an error if the provided serial number does not match the expected pattern. */ export declare function parseSerialNumber(serialNumber: string): SerialNumber; export interface Board { description?: string; serial_number?: string; device_serial_number?: string; revision?: string; version?: string; } export interface StackInfo { mac_address: number; stack_serial_number: string; boards: Board[]; } /** * Extracts device components from the provided Stack Info. * The Stack Info typically includes three components: Com, Core, and Drive, each with a name, serial number, and version. */ export declare function extractDeviceComponentsFromStackInfo(stackInfo: StackInfo): DeviceComponent[]; /** * Generates a device serial number from a given address. * The address is formatted into a string in the form `XXXX-XX-XXXX000-0000`. * * @param address - The device address as a number, which will be used to create the serial number. * @returns A string representing the formatted device serial number. * * @example * const address = 95010100014791843; * const serialNumber = makeDeviceSerialNumberFromAddress(address); * console.log(serialNumber); // "9501-01-00014790000-0000" */ export declare function makeDeviceSerialNumberFromAddress(address: number): string; /** * Extracts product IDs and versioned product IDs from a given source. * * This function handles three types of input: * - If the source is a string, it parses the serial number to extract both `productId` and `versionedProductId`. * - If the source is a `HardwareDescription`, it extracts the `productId`, `versionedProductId`, `deviceProductId`, * and `versionedDeviceProductId` from either the device or assembly information. * - If the source is a `StackInfo`, it parses the `stack_serial_number` to extract the `productId` and `versionedProductId`. * * @param source - The source from which to extract the product information. It can be a string, * `StackInfo`, or `HardwareDescription`. * @returns An object containing the following properties: * - `deviceProductId`: The ID of the device. * - `productId`: The general product ID. * - `versionedDeviceProductId`: The device ID with version. * - `versionedProductId`: The general product ID with version. * * @throws {Error} Throws an error if the `source` is of an invalid type. */ export declare function extractProductId(source: string | StackInfo | HardwareDescription): { deviceProductId: string; productId: string; versionedDeviceProductId: string; versionedProductId: string; };