ts-onvif
Version:
Client to ONVIF devices
83 lines (82 loc) • 2.63 kB
TypeScript
import { Duration } from './interfaces/basics';
interface OnvifErrorOptions {
/**
* Raw error response from the server
*/
xml?: string;
}
/**
* Type for common duration values, ISO duration or milliseconds
*/
export type CommonDuration = string | number;
export declare class OnvifError extends Error {
readonly xml?: string;
constructor(message: string, options?: OnvifErrorOptions);
}
export interface LineraseOptions {
array: string[];
rawXML?: string[];
name?: string;
}
/**
* Parse SOAP object to pretty JS-object
* @param xml xml2js object
* @param options
* @param options.array these tags will always be treated as arrays
* @param options.rawXML values of these tags will be in xml2js format
*/
export declare function linerase<T = any>(xml: any, options?: LineraseOptions): T;
/**
* Generate GUID
*/
export declare function guid(): string;
/**
* Split Digest authentication string
*/
export declare function splitArgs(args: string): string[];
export type OnvifResponse = Promise<[Record<string, any>, string]>;
/**
* @param tagName
*/
export declare function camelCase(tagName: string): string;
interface ParseSOAPStringOptions {
array?: string[];
rawXML?: string[];
attributesGroupName?: string;
attributeNamePrefix?: string;
}
/**
* Parse SOAP response
* @param xml
* @param options
*/
export declare function parseSOAPString<T>(xml: string, options?: ParseSOAPStringOptions): Promise<[T, string]>;
/**
* Create a record from the list where the key is commonly used parameter
* For example, from the profiles array get an object where we can have rapid access to profile using its token
* @param list
* @param groupKey
*/
export declare function struct<T, K extends keyof T>(list: T[], groupKey: K): Record<string, T>;
export declare function build(object: any): string;
/**
* Use ISO duration or convert milliseconds to ISO duration
* @param duration
*/
export declare function toIsoDuration(duration: CommonDuration): Duration;
/**
* Converts an ISO Duration (H, M, S) to milliseconds.
* @param duration - The duration string (e.g., "PT5S", "PT1M", "PT1H30M")
*/
export declare function toMs(duration: CommonDuration): number;
/**
* Get Digest headers from headers array
* @param headersArray
*/
export declare function getDigestHeaders(headersArray: string[]): string[];
/**
* Mutable function to convert string values to their appropriate types.
* Tags in `rawXML` are re-parsed and get `__any__` as the xml2js object.
*/
export declare function formatXMLValues(xml: any, options?: ParseSOAPStringOptions): void;
export {};