loro-mirror
Version:
Type-safe state management synchronized with Loro CRDT via a declarative schema and bidirectional mirroring.
47 lines • 2.45 kB
TypeScript
/**
* Schema definition system for Loro Mirror
*
* This module provides utilities to define schemas that map between JavaScript types and Loro CRDT types.
*/
import { BooleanSchemaType, ContainerSchemaType, IgnoreSchemaType, LoroListSchema, LoroMapSchema, LoroMapSchemaWithCatchall, LoroMovableListSchema, LoroTextSchemaType, LoroTreeSchema, NumberSchemaType, RootSchemaDefinition, RootSchemaType, SchemaDefinition, SchemaOptions, SchemaType, StringSchemaType, InferType } from "./types";
export * from "./types";
export * from "./validators";
/**
* Create a schema definition
*/
export declare function schema<T extends Record<string, ContainerSchemaType>, O extends SchemaOptions = {}>(definition: RootSchemaDefinition<T>, options?: O): RootSchemaType<T> & {
options: O;
};
export declare namespace schema {
var String: <T extends string = string, O extends SchemaOptions = {}>(options?: O) => StringSchemaType<T> & {
options: O;
};
var Number: <O extends SchemaOptions = {}>(options?: O) => NumberSchemaType & {
options: O;
};
var Boolean: <O extends SchemaOptions = {}>(options?: O) => BooleanSchemaType & {
options: O;
};
var Ignore: <O extends SchemaOptions = {}>(options?: O) => IgnoreSchemaType & {
options: O;
};
var LoroMap: <T extends Record<string, SchemaType> = {}, O extends SchemaOptions = {}>(definition: SchemaDefinition<T>, options?: O) => LoroMapSchema<T> & {
options: O;
} & {
catchall: <C extends SchemaType>(catchallSchema: C) => LoroMapSchemaWithCatchall<T, C>;
};
var LoroMapRecord: <T extends SchemaType, O extends SchemaOptions = {}>(valueSchema: T, options?: O) => LoroMapSchemaWithCatchall<{}, T> & {
options: O;
};
var LoroList: <T extends SchemaType, O extends SchemaOptions = {}>(itemSchema: T, idSelector?: (item: InferType<T>) => string, options?: O) => LoroListSchema<T> & {
options: O;
};
var LoroMovableList: <T extends SchemaType, O extends SchemaOptions = {}>(itemSchema: T, idSelector: (item: InferType<T>) => string, options?: O) => LoroMovableListSchema<T> & {
options: O;
};
var LoroText: <O extends SchemaOptions = {}>(options?: O) => LoroTextSchemaType & {
options: O;
};
var LoroTree: <T extends Record<string, SchemaType>>(nodeSchema: LoroMapSchema<T>, options?: SchemaOptions) => LoroTreeSchema<T>;
}
//# sourceMappingURL=index.d.ts.map