objective categorical abstract machine language personal data server
at main 129 lines 3.4 kB view raw
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 lex_permission = {resource: string; extra: (string * Yojson.Safe.t) list} 92 93and permission_set_spec = 94 { title: string option 95 ; title_lang: (string * string) list option 96 ; detail: string option 97 ; detail_lang: (string * string) list option 98 ; permissions: lex_permission list 99 ; description: string option } 100 101and type_def = 102 | String of string_spec 103 | Integer of integer_spec 104 | Boolean of boolean_spec 105 | Bytes of bytes_spec 106 | Blob of blob_spec 107 | CidLink of cid_link_spec 108 | Array of array_spec 109 | Object of object_spec 110 | Ref of ref_spec 111 | Union of union_spec 112 | Token of token_spec 113 | Unknown of unknown_spec 114 | Query of query_spec 115 | Procedure of procedure_spec 116 | Subscription of subscription_spec 117 | Record of record_spec 118 | PermissionSet of permission_set_spec 119 120type def_entry = {name: string; type_def: type_def} 121 122type lexicon_doc = 123 { lexicon: int (* always 1 *) 124 ; id: string (* nsid *) 125 ; revision: int option 126 ; description: string option 127 ; defs: def_entry list } 128 129type parse_result = (lexicon_doc, string) result