@directctrl/fixturelibrary
Version:
Utility library making it easy to work with the open-fixture-library.
67 lines (66 loc) • 1.9 kB
TypeScript
import { Fixture } from './types';
/**
* Fixture Index Item
*/
export interface IndexItem {
aliasOf?: string;
path?: string;
sha?: string;
url?: string;
}
/**
* When an item call is invalid due to it existing/not existing.
*/
export declare class ItemExistanceError extends Error {
constructor(message: string);
}
/**
* The in memory fixture index consisting of {@link IndexItem}s.
*
* The {@link FileFixtureIndex} is the recommended tool for managing the fixture index,
* since it has a smaller memory footprint (in most cases).
* This class should **ONLY** be used as the main index,
* if local storage isn't viable or if only a few fixtures need to be used.
*/
export declare class FixtureIndex {
/**
* Internal index object.
*/
private index;
private fixtureCache;
/**
* @ignore
* @returns the index Object.
*/
getIndex(): {
[key: string]: IndexItem;
};
/**
* @ignore
* @param data the object the index should be overwritten with
*/
setIndex(data: {
[key: string]: IndexItem;
}): void;
/**
* Adding a {@link IndexItem} to the index.
* @param key fixture key
* @param data a {@link IndexItem} object
* @param override if a existing entry should be overwritten
*/
setIndexItem(key: string, data: IndexItem, override?: boolean): void;
/**
* Checking if an {@link IndexItem} exists in the index.
* @param key fixture key
* @returns if the key was found in the index
*/
hasIndexItem(key: string): boolean;
/**
* Fetching an index item.
* @param key fixture key
* @returns The found IndexItem or undefined if nothing was found.
*/
getIndexItem(key: string): IndexItem | undefined;
cacheFixture(key: string, fixture: Fixture): void;
fixtureFromCache(key: string): Fixture | undefined;
}