import { Item } from './item'; import { ItemCache, PotionResources } from './potion'; /** * Camel case to snake case */ export declare function toSnakeCase(str: string, separator?: string): string; /** * Snake case to camel case */ export declare function toCamelCase(str: string): string; /** * Object type guard * Docs: https://www.typescriptlang.org/docs/handbook/advanced-types.html */ export declare function isJsObject(value: any): value is { [key: string]: any; }; /** * Check if an object is empty */ export declare function isObjectEmpty(obj: {}): boolean; /** * Function type guard */ export declare function isFunction(value: any): value is Function; export declare type KeyMapFunction = (key: string) => string; export declare type ValueMapFunction = (value: any) => any; /** * Object.map() * NOTE: This is NOT a recursive fn. * @param {Object} obj * @param {Function} keyMapFunction - Transform operation to apply on the key. * @param {Function} [valueMapFunction] - Transform operation to apply on the value. * @returns {Object} */ export declare function omap(obj: { [key: string]: any; }, keyMapFunction: KeyMapFunction, valueMapFunction?: ValueMapFunction): { [key: string]: any; }; /** * Aggregate a str based on an Error object and uri */ export declare function getErrorMessage(error: any, uri?: string): string; /** * Convert JSON schema to a JS object */ export declare function fromSchemaJSON(json: any): { [key: string]: any; }; export declare class SelfReference { readonly $uri: string; constructor($uri: string); matches(json: any): boolean; } export declare function replaceSelfReferences(json: any, roots: Map): any; /** * Recursively find every object with {uri} (a Potion item usually) and return a list with all. * @param json - A Potion JSON. * @return {Array} */ export declare function findRoots(json: any, skip?: boolean): Map; /** * Generate a self reference */ export declare function toSelfReference(uri: string): SelfReference; /** * Convert an Object to Potion JSON */ export declare function toPotionJSON(json: any, prefix?: string): { [key: string]: any; }; export declare type PotionID = string | number | null; /** * Parse a Potion ID */ export declare function parsePotionID(id: any): PotionID; /** * Get a Potion ID from a URI */ export declare function getPotionID(uri: string, resourceURI: string): PotionID; /** * Find a Potion resource based on URI */ export declare function findPotionResource(uri: string, resources: PotionResources): { resourceURI: string; resource: typeof Item; } | undefined; /** * Check if some string is a Potion URI */ export declare function isPotionURI(uri: string, resources: PotionResources): boolean; /** * Get the Potion URI from a Potion JSON object */ export declare function hasTypeAndId({$type, $id}: { [key: string]: any; }): boolean; export declare function getPotionURI({$uri, $ref, $type, $id}: { [key: string]: any; }): string; /** * Remove some string from another string */ export declare function removePrefixFromURI(uri: string, str: string): string; /** * Add a prefix to some string (if not already there) */ export declare function addPrefixToURI(uri: string, prefix?: string): string; /** * Merge array of objects into one object. */ export declare function merge(...objects: Array<{ [key: string]: any; }>): any; /** * In-Memory cache * Will be used by default by Potion for caching resources. */ export declare class MemCache implements ItemCache { protected items: Map; has(key: string): boolean; get(key: string): Promise; put(key: string, item: Promise): Promise; remove(key: string): void; } export declare function getGlobal(): any;