|
1 | 1 | module Json = Yojson.Basic |
2 | 2 | module Json_util = Yojson.Basic.Util |
3 | | -module Model = Cache_model |
4 | 3 |
|
5 | 4 | type api_config = |
6 | 5 | { base_url : string |
@@ -28,12 +27,6 @@ type api_file_upload = |
28 | 27 | ; headers : (string * string) list |
29 | 28 | } |
30 | 29 |
|
31 | | -type api_journal = |
32 | | - { uuid : string |
33 | | - ; title : string |
34 | | - ; journal_day : int |
35 | | - } |
36 | | - |
37 | 30 | type api_graph = |
38 | 31 | { id : string |
39 | 32 | ; name : string |
@@ -96,19 +89,6 @@ let graph_path config suffix = |
96 | 89 |
|
97 | 90 | let json_body fields = Some (Json.to_string (`Assoc fields)) |
98 | 91 |
|
99 | | -let recent_blocks_request config journal_day = |
100 | | - request config "GET" |
101 | | - (graph_path config |
102 | | - ("/blocks?journal-only=true&journal-day-at-most=" |
103 | | - ^ string_of_int journal_day |
104 | | - ^ "&sort=created-at-desc&limit=100")) |
105 | | - None |
106 | | - |
107 | | -let task_statuses_request config = |
108 | | - request config "GET" |
109 | | - (graph_path config "/search?q=Status&types=properties&limit=100") |
110 | | - None |
111 | | - |
112 | 92 | let graphs_request config = request config "GET" "/graphs" None |
113 | 93 |
|
114 | 94 | let create_graph_request config name schema_version e2ee = |
@@ -155,21 +135,6 @@ let encrypted_journal_page_request config uuid title name journal_day = |
155 | 135 | ("journal-day", `Int journal_day); |
156 | 136 | ]) |
157 | 137 |
|
158 | | -let related_request config resource uuid collection = |
159 | | - request config "GET" |
160 | | - (graph_path config |
161 | | - ("/" ^ resource ^ "/" ^ url_encode uuid ^ "/" ^ collection ^ "?limit=100")) |
162 | | - None |
163 | | - |
164 | | -let block_references_request config uuid = |
165 | | - related_request config "blocks" uuid "references" |
166 | | - |
167 | | -let page_references_request config uuid = |
168 | | - related_request config "pages" uuid "references" |
169 | | - |
170 | | -let tag_objects_request config uuid = |
171 | | - related_request config "tags" uuid "objects" |
172 | | - |
173 | 138 | let page_fields page_id = |
174 | 139 | match page_id with |
175 | 140 | | None -> [] |
@@ -363,110 +328,6 @@ let update_block_status_request config uuid status = |
363 | 328 | (graph_path config ("/blocks/" ^ url_encode uuid ^ "/properties/Status")) |
364 | 329 | (json_body [ ("value", `String status) ]) |
365 | 330 |
|
366 | | -let summary_of_json input = |
367 | | - let uuid = string_member "uuid" input in |
368 | | - let title = string_member "title" input in |
369 | | - if uuid <> "" && title <> "" then |
370 | | - Some ({ uuid; title } : Model.entity_summary) |
371 | | - else None |
372 | | - |
373 | | -let summaries_member name input = |
374 | | - List.filter_map summary_of_json (list_member name input) |
375 | | - |
376 | | -let status_of_json input = |
377 | | - let uuid = string_member "uuid" input in |
378 | | - let title = string_member "title" input in |
379 | | - let icon = member "icon" input in |
380 | | - if uuid <> "" && title <> "" then |
381 | | - Some |
382 | | - ({ |
383 | | - uuid; |
384 | | - title; |
385 | | - ident = option_string_member "ident" input; |
386 | | - icon_type = option_string_member "type" icon; |
387 | | - icon_id = option_string_member "id" icon; |
388 | | - icon_color = option_string_member "color" icon; |
389 | | - } |
390 | | - : Model.status) |
391 | | - else None |
392 | | - |
393 | | -let status_choices input = |
394 | | - List.filter_map status_of_json (list_member "choices" input) |
395 | | - |
396 | | -let statuses_from_property_body body = |
397 | | - let input = Json.from_string body in |
398 | | - match member "results" input with |
399 | | - | `List properties -> |
400 | | - (match |
401 | | - List.find_map |
402 | | - (fun property -> |
403 | | - if string_member "ident" property = "logseq.property/status" then |
404 | | - Some (status_choices property) |
405 | | - else None) |
406 | | - properties |
407 | | - with |
408 | | - | Some choices -> choices |
409 | | - | None -> []) |
410 | | - | _ -> status_choices input |
411 | | - |
412 | | -let block_of_json fallback_time input = |
413 | | - let uuid = string_member "uuid" input in |
414 | | - let title = string_member "title" input in |
415 | | - if uuid <> "" && title <> "" then |
416 | | - Some |
417 | | - ({ |
418 | | - uuid; |
419 | | - title; |
420 | | - page_id = string_member "page-id" input; |
421 | | - parent_id = option_string_member "parent-id" input; |
422 | | - order = option_string_member "order" input; |
423 | | - created_at = |
424 | | - (let value = int_member "created-at" input in |
425 | | - if value = 0 then fallback_time else value); |
426 | | - updated_at = |
427 | | - (let value = int_member "updated-at" input in |
428 | | - if value = 0 then fallback_time else value); |
429 | | - sync_status = "synced"; |
430 | | - tags = summaries_member "tags" input; |
431 | | - references = summaries_member "references" input; |
432 | | - breadcrumbs = summaries_member "breadcrumbs" input; |
433 | | - status = status_of_json (member "status" input); |
434 | | - is_asset = false; |
435 | | - asset_type = option_string_member "asset-type" input; |
436 | | - asset_size = |
437 | | - (match member "asset-size" input with |
438 | | - | `Int value -> Some value |
439 | | - | _ -> None); |
440 | | - asset_checksum = option_string_member "asset-checksum" input; |
441 | | - local_path = None; |
442 | | - journal = None; |
443 | | - } |
444 | | - : Model.block) |
445 | | - else None |
446 | | - |
447 | | -let blocks_member key input = |
448 | | - List.filter_map (fun value -> block_of_json 0 value) (list_member key input) |
449 | | - |
450 | | -let blocks_from_list_body key body = blocks_member key (Json.from_string body) |
451 | | - |
452 | | -let journal_of_json input = |
453 | | - let uuid = string_member "uuid" input in |
454 | | - let day = int_member "journal-day" input in |
455 | | - if uuid <> "" && day > 0 then |
456 | | - Some |
457 | | - ({ |
458 | | - uuid; |
459 | | - title = string_member "title" input; |
460 | | - journal_day = day; |
461 | | - } |
462 | | - : api_journal) |
463 | | - else None |
464 | | - |
465 | | -let feed_from_body body = |
466 | | - let input = Json.from_string body in |
467 | | - ( blocks_member "blocks" input |
468 | | - , List.filter_map journal_of_json (list_member "journals" input) ) |
469 | | - |
470 | 331 | let bool_member default name input = |
471 | 332 | match member name input with `Bool value -> value | _ -> default |
472 | 333 |
|
|
0 commit comments