forked from
futur.blue/pegasus
objective categorical abstract machine language personal data server
1type string_spec =
2 { format: string option
3 ; min_length: int option
4 ; max_length: int option
5 ; min_graphemes: int option
6 ; max_graphemes: int option
7 ; known_values: string list option
8 ; enum: string list option
9 ; const: string option
10 ; default: string option
11 ; description: string option }
12
13type integer_spec =
14 { minimum: int option
15 ; maximum: int option
16 ; enum: int list option
17 ; const: int option
18 ; default: int option
19 ; description: string option }
20
21type boolean_spec =
22 {const: bool option; default: bool option; description: string option}
23
24type bytes_spec =
25 {min_length: int option; max_length: int option; description: string option}
26
27type blob_spec =
28 {accept: string list option; max_size: int option; description: string option}
29
30type cid_link_spec = {description: string option}
31
32type array_spec =
33 { items: type_def
34 ; min_length: int option
35 ; max_length: int option
36 ; description: string option }
37
38and property = {type_def: type_def; description: string option}
39
40and object_spec =
41 { properties: (string * property) list
42 ; required: string list option
43 ; nullable: string list option
44 ; description: string option }
45
46and ref_spec =
47 { ref_: string (* e.g., "#localDef" or "com.example.defs#someDef" *)
48 ; description: string option }
49
50and union_spec =
51 {refs: string list; closed: bool option; description: string option}
52
53and token_spec = {description: string option}
54
55and unknown_spec = {description: string option}
56
57and params_spec =
58 { properties: (string * property) list
59 ; required: string list option
60 ; description: string option }
61
62and body_def =
63 {encoding: string; schema: type_def option; description: string option}
64
65and error_def = {name: string; description: string option}
66
67and query_spec =
68 { parameters: params_spec option
69 ; output: body_def option
70 ; errors: error_def list option
71 ; description: string option }
72
73and procedure_spec =
74 { parameters: params_spec option
75 ; input: body_def option
76 ; output: body_def option
77 ; errors: error_def list option
78 ; description: string option }
79
80and subscription_spec =
81 { parameters: params_spec option
82 ; message: body_def option
83 ; errors: error_def list option
84 ; description: string option }
85
86and record_spec =
87 { key: string (* "tid", "nsid", etc. *)
88 ; record: object_spec
89 ; description: string option }
90
91and type_def =
92 | String of string_spec
93 | Integer of integer_spec
94 | Boolean of boolean_spec
95 | Bytes of bytes_spec
96 | Blob of blob_spec
97 | CidLink of cid_link_spec
98 | Array of array_spec
99 | Object of object_spec
100 | Ref of ref_spec
101 | Union of union_spec
102 | Token of token_spec
103 | Unknown of unknown_spec
104 | Query of query_spec
105 | Procedure of procedure_spec
106 | Subscription of subscription_spec
107 | Record of record_spec
108
109type def_entry = {name: string; type_def: type_def}
110
111type lexicon_doc =
112 { lexicon: int (* always 1 *)
113 ; id: string (* nsid *)
114 ; revision: int option
115 ; description: string option
116 ; defs: def_entry list }
117
118type parse_result = (lexicon_doc, string) result