/** * Schema definition system for Loro Mirror * * This module provides utilities to define schemas that map between JavaScript types and Loro CRDT types. */ import { AnySchemaOptions, AnySchemaType, BooleanSchemaType, ContainerSchemaType, IgnoreSchemaType, LoroListSchema, LoroMapSchema, LoroMapSchemaWithCatchall, LoroMovableListSchema, LoroTextSchemaType, LoroTreeSchema, NumberSchemaType, RootSchemaDefinition, RootSchemaType, SchemaDefinition, SchemaOptions, SchemaType, StringSchemaType, InferType, TransformDefinition } from "./types.js"; /** * String schema builder with transform method. * Transform decode/encode never receive null/undefined - they pass through as-is. */ type StringSchemaBuilder = StringSchemaType & { options: O; } & { transform: (def: TransformDefinition) => StringSchemaType & { options: O; transform: TransformDefinition; }; }; type StringSchemaFactory = { (): StringSchemaBuilder; (options: O): StringSchemaBuilder; (options: O): StringSchemaBuilder; }; /** * Number schema builder with transform method. * Transform decode/encode never receive null/undefined - they pass through as-is. */ type NumberSchemaBuilder = NumberSchemaType & { options: O; } & { transform: (def: TransformDefinition) => NumberSchemaType & { options: O; transform: TransformDefinition; }; }; /** * Boolean schema builder with transform method. * Transform decode/encode never receive null/undefined - they pass through as-is. */ type BooleanSchemaBuilder = BooleanSchemaType & { options: O; } & { transform: (def: TransformDefinition) => BooleanSchemaType & { options: O; transform: TransformDefinition; }; }; export * from "./types.js"; export * from "./validators.js"; /** * Create a schema definition */ export declare function schema, O extends SchemaOptions = {}>(definition: RootSchemaDefinition, options?: O): RootSchemaType & { options: O; }; export declare namespace schema { var String: StringSchemaFactory; var Any: (options?: O) => AnySchemaType & { options: O; }; var Number: (options?: O) => NumberSchemaBuilder; var Boolean: (options?: O) => BooleanSchemaBuilder; var Ignore: (options?: O) => IgnoreSchemaType & { options: O; }; var LoroMap: = {}, O extends SchemaOptions = {}>(definition: SchemaDefinition, options?: O) => LoroMapSchema & { options: O; } & { catchall: (catchallSchema: C) => LoroMapSchemaWithCatchall; }; var LoroMapRecord: (valueSchema: T, options?: O) => LoroMapSchemaWithCatchall<{}, T> & { options: O; }; var LoroList: (itemSchema: T, idSelector?: (item: InferType) => string, options?: O) => LoroListSchema & { options: O; }; var LoroMovableList: (itemSchema: T, idSelector: (item: InferType) => string, options?: O) => LoroMovableListSchema & { options: O; }; var LoroText: (options?: O) => LoroTextSchemaType & { options: O; }; var LoroTree: >(nodeSchema: LoroMapSchema, options?: SchemaOptions) => LoroTreeSchema; } //# sourceMappingURL=index.d.ts.map