package octez-libs
A package that contains multiple base libraries used by the Octez suite
Install
Dune Dependency
Authors
Maintainers
Sources
tezos-octez-v20.1.tag.bz2
sha256=ddfb5076eeb0b32ac21c1eed44e8fc86a6743ef18ab23fff02d36e365bb73d61
sha512=d22a827df5146e0aa274df48bc2150b098177ff7e5eab52c6109e867eb0a1f0ec63e6bfbb0e3645a6c2112de3877c91a17df32ccbff301891ce4ba630c997a65
doc/src/octez-libs.rpc/RPC_encoding.ml.html
Source file RPC_encoding.ml
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 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264
(*****************************************************************************) (* *) (* Open Source License *) (* Copyright (c) 2018 Dynamic Ledger Solutions, Inc. <contact@tezos.com> *) (* *) (* Permission is hereby granted, free of charge, to any person obtaining a *) (* copy of this software and associated documentation files (the "Software"),*) (* to deal in the Software without restriction, including without limitation *) (* the rights to use, copy, modify, merge, publish, distribute, sublicense, *) (* and/or sell copies of the Software, and to permit persons to whom the *) (* Software is furnished to do so, subject to the following conditions: *) (* *) (* The above copyright notice and this permission notice shall be included *) (* in all copies or substantial portions of the Software. *) (* *) (* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR*) (* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, *) (* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL *) (* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER*) (* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING *) (* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER *) (* DEALINGS IN THE SOFTWARE. *) (* *) (*****************************************************************************) type 'a t = 'a Data_encoding.t type schema = Data_encoding.json_schema * Data_encoding.Binary_schema.t let unit = Data_encoding.empty let untyped = Data_encoding.(obj1 (req "untyped" string)) let conv f g t = Data_encoding.conv ~schema:(Data_encoding.Json.schema t) f g t let schema ?definitions_path t = ( Data_encoding.Json.schema ?definitions_path t, Data_encoding.Binary.describe t ) let schema_encoding = let open Data_encoding in obj2 (req "json_schema" json_schema) (req "binary_schema" Data_encoding.Binary_schema.encoding) module StringMap = Resto.StringMap let arg_encoding = let open Data_encoding in conv (fun {Resto.Arg.name; descr} -> ((), name, descr)) (fun ((), name, descr) -> {name; descr}) (obj3 (req "id" (constant "single")) (req "name" string) (opt "descr" string)) let multi_arg_encoding = let open Data_encoding in conv (fun {Resto.Arg.name; descr} -> ((), name, descr)) (fun ((), name, descr) -> {name; descr}) (obj3 (req "id" (constant "multiple")) (req "name" string) (opt "descr" string)) open Resto.Description let meth_encoding = Data_encoding.string_enum [ ("GET", `GET); ("POST", `POST); ("DELETE", `DELETE); ("PUT", `PUT); ("PATCH", `PATCH); ] let path_item_encoding = let open Data_encoding in union [ case (Tag 0) string ~title:"PStatic" (function PStatic s -> Some s | _ -> None) (fun s -> PStatic s); case (Tag 1) arg_encoding ~title:"PDynamic" (function PDynamic s -> Some s | _ -> None) (fun s -> PDynamic s); case (Tag 2) multi_arg_encoding ~title:"PDynamicTail" (function PDynamicTail s -> Some s | _ -> None) (fun s -> PDynamicTail s); ] let query_kind_encoding = let open Data_encoding in union [ case (Tag 0) ~title:"Single" (obj1 (req "single" arg_encoding)) (function Single s -> Some s | _ -> None) (fun s -> Single s); case (Tag 1) ~title:"Optional" (obj1 (req "optional" arg_encoding)) (function Optional s -> Some s | _ -> None) (fun s -> Optional s); case (Tag 2) ~title:"Flag" (obj1 (req "flag" empty)) (function Flag -> Some () | _ -> None) (fun () -> Flag); case (Tag 3) ~title:"Multi" (obj1 (req "multi" arg_encoding)) (function Multi s -> Some s | _ -> None) (fun s -> Multi s); ] let query_item_encoding = let open Data_encoding in conv (fun {name; description; kind} -> (name, description, kind)) (fun (name, description, kind) -> {name; description; kind}) (obj3 (req "name" string) (opt "description" string) (req "kind" query_kind_encoding)) let service_descr_encoding = let open Data_encoding in conv (fun {meth; path; description; query; input; output; error} -> ( meth, path, description, query, Option.map Lazy.force input, Lazy.force output, Lazy.force error )) (fun (meth, path, description, query, input, output, error) -> { meth; path; description; query; input = Option.map Lazy.from_val input; output = Lazy.from_val output; error = Lazy.from_val error; }) (obj7 (req "meth" meth_encoding) (req "path" (list path_item_encoding)) (opt "description" string) (req "query" (list query_item_encoding)) (opt "input" schema_encoding) (req "output" schema_encoding) (req "error" schema_encoding)) let directory_descr_encoding = let open Data_encoding in mu "service_tree" @@ fun directory_descr_encoding -> let static_subdirectories_descr_encoding = union [ case (Tag 0) ~title:"Suffixes" (obj1 (req "suffixes" (list (obj2 (req "name" string) (req "tree" directory_descr_encoding))))) (function Suffixes map -> Some (StringMap.bindings map) | _ -> None) (fun m -> let add acc (n, t) = StringMap.add n t acc in Suffixes (List.fold_left add StringMap.empty m)); case (Tag 1) ~title:"Arg" (obj1 (req "dynamic_dispatch" (obj2 (req "arg" arg_encoding) (req "tree" directory_descr_encoding)))) (function Arg (ty, tree) -> Some (ty, tree) | _ -> None) (fun (ty, tree) -> Arg (ty, tree)); ] in let static_directory_descr_encoding = conv (fun {services; subdirs} -> let find s = Resto.MethMap.find_opt s services in (find `GET, find `POST, find `DELETE, find `PUT, find `PATCH, subdirs)) (fun (get, post, delete, put, patch, subdirs) -> let add meth s services = match s with | None -> services | Some s -> Resto.MethMap.add meth s services in let services = Resto.MethMap.empty |> add `GET get |> add `POST post |> add `DELETE delete |> add `PUT put |> add `PATCH patch in {services; subdirs}) (obj6 (opt "get_service" service_descr_encoding) (opt "post_service" service_descr_encoding) (opt "delete_service" service_descr_encoding) (opt "put_service" service_descr_encoding) (opt "patch_service" service_descr_encoding) (opt "subdirs" static_subdirectories_descr_encoding)) in union [ case (Tag 0) ~title:"Static" (obj1 (req "static" static_directory_descr_encoding)) (function Static descr -> Some descr | _ -> None) (fun descr -> Static descr); case (Tag 1) ~title:"Dynamic" (obj1 (req "dynamic" (option string))) (function Dynamic descr -> Some descr | _ -> None) (fun descr -> Dynamic descr); case (Tag 2) ~title:"Empty" (constant "empty") (function Empty -> Some () | _ -> None) (fun () -> Empty); ] let description_request_encoding = let open Data_encoding in conv (fun {recurse} -> recurse) (function recurse -> {recurse}) (obj1 (dft "recursive" bool false)) let description_answer_encoding = directory_descr_encoding let uri_encoding = let open Data_encoding in conv Uri.to_string Uri.of_string string
sectionYPositions = computeSectionYPositions($el), 10)"
x-init="setTimeout(() => sectionYPositions = computeSectionYPositions($el), 10)"
>