@getanthill/datastore
Version:
Event-Sourced Datastore
28 lines (27 loc) • 1.02 kB
TypeScript
import type Ajv from 'ajv';
import type { AnyObject, Event } from '../typings';
/**
* Returns available event types
* @param {object} schema Event schemas
* @returns {string[]} Event type available versions
*/
export declare function getEventTypes(events: AnyObject): string[];
/**
* Returns available versions for an event type
* @param {object} schema Event schemas
* @param {object} event Object for which the type versions must be returned
* @returns {integer[]} Event type available versions
*/
export declare function getEventTypeVersions(schema: AnyObject, event: Event): {
v: string | undefined;
all: string[];
};
/**
* Validate an event against a JSON Schema contract
* @param {object} event The object to validate
* @param {object} schema The event schema
* @param {object} validator The JSON Schema validator
* @throws AssertionError if invalid
* @returns {void} -
*/
export declare function validate(event: Event, schema: AnyObject, validator: Ajv, throwOnInvalidEvent?: boolean): any;