diff --git a/src/index.d.ts b/src/index.d.ts index 715ce30d..1ad4313c 100644 --- a/src/index.d.ts +++ b/src/index.d.ts @@ -19,6 +19,34 @@ export interface HtmlFormatter extends Formatter { hideUnchanged(node?: Element | null, delay?: number): void; } +type AddOperation = { + opp: "add"; + path: string; + value: any +} + +type RemoveOperation = { + opp: "remove"; + path: string; +} + +type ReplaceOperation = { + opp: "replace"; + path: string; + value: any; +} + +type MoveOperation = { + opp: "move"; + path: string; +} + +export type Operation = AddOperation | RemoveOperation | ReplaceOperation | MoveOperation + +export interface JSONPatchFormatter { + format(delta: Delta, original: any): Operation[]; +} + export interface Delta { [key: string]: any; [key: number]: any; @@ -190,7 +218,7 @@ export const formatters: { annotated: Formatter; console: Formatter; html: HtmlFormatter; - jsonpatch: Formatter; + jsonpatch: JSONPatchFormatter; }; export const console: Formatter;