UNPKG

@show-runner/fixturelibrary

Version:

Utility library making it easy to work with the open-fixture-library.

112 lines (111 loc) 4.05 kB
import { Fixture } from './types'; interface MakeModel { key: string; make: string; model: string; } /** * The Fixture Library * * The main class for managing DMX-Fixtures. * ## Example - `commonJs` * ```js * const { FixtureLibrary } = require('fixturelibrary'); * const fl = new FixtureLibrary(); * * async function foo(){ * // Fetching a Fixture from the Library * const fixture = await fl.getFixture('cameo/auro-spot-300'); * console.log(`${fixture.name} has ${fixture.modes.length} Modes.`); * * // This will return true since we're validating a fixture from Ofl. * console.log(fl.validate(fixture)); * } * ``` * * ## Example - `ESM/TS` * ```ts * import { FixtureLibrary } from 'fixturelibrary'; * * const fl = new FixtureLibrary(); * const fixture = await fl.getFixture('arri/broadcaster-2-plus'); * ``` */ export declare class FixtureLibrary { /** * @internal * The FixtureIndex object storing/handling storage of fixture definition */ private fixtureIndex; /** * @internal * Flag for if downloads from the web are allowed */ private webAccess; /** * @internal * Storing the Json Schema Validator object */ private ajv; /** * @internal * Object for storing manufacturers at build time. */ private manufacturers; /** * @param webAccess if web requests are allowed */ constructor(webAccess?: boolean); /** * Saving the Index to a file to be available after execution. */ private saveIndex; /** * Get a Fixture from the Library or OFL if allowed. * This relies on reading definitions from file/web and caching. * Execution time depends on the size of the definition (.6 - 4ms) and if it was cached (.01ms). * In Case it needs to be downloaded, it will take alot longer. (depending on your connection) * @param key Key of the fixture * @param override if existing entries should be overwritten * @returns Fixture Definition or undefined if not found */ getFixture(key: string): Promise<Fixture | undefined>; getIndexItems(): MakeModel[]; private getMake; /** * Adding a new fixture to the Library. * @param key new and unique fixture key * @param fixture Fixture Definition * @param sha The version SHA of the fixture (Can be usefull for Versioning) * @param validate If the fixture should be validated against the OFL Schema * @param override If existing entries should be overwritten * @returns The passed Fixture Definition to enable method chaining */ setFixture(key: string, fixture: Fixture, sha?: string, validate?: boolean, override?: boolean): Promise<Fixture | undefined>; /** * Validate a fixture definition against the Open Fixture Library Schema * @param fixture the fixture definition * @returns wether the fixture is applicable to the schema or not */ validate(fixture: any): boolean; /** * This call has a long executiontime and is therefore **Not Recommended** to be used in scripts! * Please use `npx syncOfl shallow` instead! * * Insteadof {@link downloadOfl}, this only downloads the references to the OFL fixtures * and none of the files. * @returns List of all the fixtures which got updated. */ fetchOfl(): Promise<string[] | void>; /** * This call has a long executiontime and is therefore **Not Recommended** to be used in scripts! * Please use `npx syncOfl` instead! * * **ONLY** available when allowing web access usage. * Downloading the whole Open Fixture Library to the fixture index. * The Fixtureindex should, after a successfull download, have an additional ~30KB in size. * @returns List of all the fixtures which got updated. */ downloadOfl(): Promise<string[] | void>; } export default FixtureLibrary;