UNPKG

@portabletext/patches

Version:
132 lines (109 loc) 2.37 kB
/** @beta */ export declare function applyAll(value: any, patches: any[]): any /** @public */ export declare type DecPatch = { path: Path origin?: Origin type: 'dec' value: JSONValue } /** @public */ export declare type DiffMatchPatch = { path: Path type: 'diffMatchPatch' origin?: Origin value: string } /** @public */ export declare function diffMatchPatch( currentValue: string, nextValue: string, path?: Path, ): DiffMatchPatch /** @public */ export declare type IncPatch = { path: Path origin?: Origin type: 'inc' value: JSONValue } /** @public */ export declare type IndexTuple = [number | '', number | ''] /** @public */ export declare function insert( items: any[], position: InsertPosition_2, path?: Path, ): InsertPatch /** @public */ export declare type InsertPatch = { path: Path origin?: Origin type: 'insert' position: InsertPosition_2 items: JSONValue[] } /** @public */ declare type InsertPosition_2 = 'before' | 'after' | 'replace' export {InsertPosition_2 as InsertPosition} /** @public */ export declare type JSONValue = | number | string | boolean | { [key: string]: JSONValue } | JSONValue[] /** @public */ export declare type KeyedSegment = { _key: string } /** @public */ export declare type Origin = 'remote' | 'local' | 'internal' /** @public */ export declare type Patch = | SetPatch | SetIfMissingPatch | UnsetPatch | InsertPatch | DiffMatchPatch | IncPatch | DecPatch /** @public */ export declare type Path = PathSegment[] /** @public */ export declare type PathSegment = string | number | KeyedSegment | IndexTuple /** @internal */ export declare function prefixPath< T extends { path: Path }, >(patch: T, segment: PathSegment): T /** @public */ export declare function set(value: any, path?: Path): SetPatch /** @public */ export declare function setIfMissing(value: any, path?: Path): SetIfMissingPatch /** @public */ export declare type SetIfMissingPatch = { path: Path origin?: Origin type: 'setIfMissing' value: JSONValue } /** @public */ export declare type SetPatch = { path: Path type: 'set' origin?: Origin value: JSONValue } /** @public */ export declare function unset(path?: Path): UnsetPatch /** @public */ export declare type UnsetPatch = { path: Path origin?: Origin type: 'unset' } export {}