aboutsummaryrefslogtreecommitdiff
path: root/editor/state/storage.mli
blob: cad29820dcd511b67fff867c3de3e5d4699de469 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
module Js = Js_of_ocaml.Js

(** Provide a function for extracting the page id from the URL *)
val page_id
  : unit -> Jstr.t option

class type content = object

  method title
    : Jstr.t Js.opt Js.readonly_prop

  method content
    : Jv.t Js.opt Js.readonly_prop

  method date 
    : float Js.opt Js.readonly_prop

end

(** load f] will try to load the content associated with the given key.

    The function [f] is called to identified which is the appropriate page id.
*)
val load
  : Jstr.t option -> content Js.t

val save
  : check:(previous:content Js.t -> update:content Js.t -> bool) -> content Js.t -> Jstr.t option -> (bool, Jv.Error.t) result

(** Remove the page from the storage. *)
val delete 
  : (unit -> Jstr.t option) -> unit

(** Collect all the keys to the existing pages *)
val get_ids
  : unit -> Jstr.t list

val to_json
  : unit -> Jstr.t

val of_json
  : check:(previous:content Js.t -> update:content Js.t -> bool) -> Jstr.t -> (unit, Jv.Error.t) result