@player-ui/player
Version:
36 lines • 2.11 kB
TypeScript
import { SyncWaterfallHook } from "tapable-ts";
import type { Schema as SchemaType, Formatting } from "@player-ui/types";
import type { BindingInstance } from "../binding";
import type { ValidationProvider, ValidationObject } from "../validator";
import type { FormatDefinition, FormatOptions, FormatType } from "./types";
/** Expand the authored schema into a set of paths -> DataTypes */
export declare function parse(schema: SchemaType.Schema): Map<string, SchemaType.DataTypes>;
/**
* The Schema is the central hub for all data invariants, and metaData associated with the data-model itself
* Outside of the types defined in the JSON payload, it doesn't manage or keep any state.
* It simply servers as an orchestrator for other modules to interface w/ the schema.
*/
export declare class SchemaController implements ValidationProvider {
private formatters;
private types;
readonly schema: Map<string, SchemaType.DataTypes>;
private bindingSchemaNormalizedCache;
readonly hooks: {
resolveTypeForBinding: SyncWaterfallHook<[SchemaType.DataTypes | undefined, BindingInstance], Record<string, any>>;
};
constructor(schema?: SchemaType.Schema);
addFormatters(fns: Array<FormatType<any, any, FormatOptions>>): void;
addDataTypes(types: Array<SchemaType.DataType<any>>): void;
getValidationsForBinding(binding: BindingInstance): Array<ValidationObject> | undefined;
private normalizeBinding;
getType(binding: BindingInstance): SchemaType.DataTypes | undefined;
getApparentType(binding: BindingInstance): SchemaType.DataTypes | undefined;
getTypeDefinition(dataType: string): SchemaType.DataType<any> | undefined;
getFormatterForType(formatReference: Formatting.Reference): FormatDefinition<unknown, unknown> | undefined;
/**
* Given a binding, fetch a function that's responsible for formatting, and/or de-formatting the data
* If no formatter is registered, it will return undefined
*/
getFormatter(binding: BindingInstance): FormatDefinition<unknown, unknown> | undefined;
}
//# sourceMappingURL=schema.d.ts.map