cumulocity-cypress
Version:
Cypress commands for Cumulocity IoT
59 lines (58 loc) • 2.91 kB
TypeScript
import { C8yTestHierarchyTree } from "./types";
export declare function safeStringify(obj: any, indent?: number): string;
export declare function sanitizeStringifiedObject(obj: any): any;
/**
* Gets the case-sensitive path for a given case-insensitive path. The path is
* assumed to be a dot-separated string. If the path is an array, it is assumed
* to be a list of keys.
*
* @param obj The object to query
* @param path The case-insensitive path to find
* @returns The actual case-sensitive path if found, undefined otherwise
*/
export declare function toSensitiveObjectKeyPath(obj: any, path: string | string[]): string | undefined;
/**
* Gets the value of a case-insensitive key path from an object. The path is
* assumed to be a dot-separated string. If the path is an array, it is assumed
* to be a list of keys.
*
* This function supports deep access to cookie and set-cookie headers, e.g.
* `requestHeaders.cookie.authorization`. Cookie headers are parsed and the value
* of the specified cookie is returned. If the cookie is not found, undefined is returned.
*
* @example
* get_i(obj, "obj.key.token")
* get_i(obj, ["obj", "key", "token"])
* get_i(obj, "obj.key[0].token")
* get_i(obj, "obj.key.0.token")
* get_i(obj, "requestHeaders.cookie.authorization")
* get_i(obj, "requestHeaders.set-cookie.authorization")
*
* @param obj The object to query
* @param keyPath The case-insensitive key path to find
* @returns The value of the key path if found, undefined otherwise
*/
export declare function get_i(obj: any, keyPath: string | string[]): any | undefined;
/**
* Returns the shortest unique prefixes for the given words. The prefixes are
* unique in the sense that they are not prefixes of any other word in the list.
*
* @param words The list of words to find the prefixes for.
* @returns The list of shortest unique prefixes.
*/
export declare function shortestUniquePrefixes(words: string[]): string[];
export declare function getLastDefinedValue<T>(data: T[], index: number): T | undefined;
/**
* Converts a value to an array. If the value is an array, it is returned as is.
* @param value The value to convert to an array
* @returns The value as an array if it is not already an array
*/
export declare function to_array<T>(value: T | T[] | undefined): T[] | undefined;
/**
* Converts a string value to a boolean. Supported values are "true", "false", "1", and "0".
* @param input The input string to convert to a boolean
* @param defaultValue The default value to return if the input is not a valid boolean string
* @returns The boolean value of the input string or the default value if the input is not a valid boolean string
*/
export declare function to_boolean(input: string, defaultValue: boolean): boolean;
export declare function buildTestHierarchy<T>(objects: T[], hierarchyfn: (obj: T) => string[] | undefined): C8yTestHierarchyTree<T>;