From 0a95fc126315e42be41d5f7646e4eec7da6201f9 Mon Sep 17 00:00:00 2001 From: Cyber MacGeddon Date: Sat, 3 May 2025 17:55:17 +0100 Subject: [PATCH] Rework schema --- trustgraph-base/trustgraph/schema/library.py | 91 +++++++++++++++++--- 1 file changed, 77 insertions(+), 14 deletions(-) diff --git a/trustgraph-base/trustgraph/schema/library.py b/trustgraph-base/trustgraph/schema/library.py index 019002f8..fd0c6289 100644 --- a/trustgraph-base/trustgraph/schema/library.py +++ b/trustgraph-base/trustgraph/schema/library.py @@ -6,16 +6,52 @@ from . types import Error from . metadata import Metadata from . documents import Document, TextDocument -# add -# -> (id, document) +# add-document +# -> (document_id, document_metadata, content) # <- () # <- (error) -# list -# -> (user, collection?) -# <- (info) +# remove-document +# -> (document_id) +# <- () # <- (error) +# update-document +# -> (document_id, document_metadata) +# <- () +# <- (error) + +# get-document-metadata +# -> (document_id) +# <- (document_metadata) +# <- (error) + +# get-document-content +# -> (document_id) +# <- (content) +# <- (error) + +# add-processing +# -> (processing_id, processing_metadata) +# <- () +# <- (error) + +# remove-processing +# -> (processing_id) +# <- () +# <- (error) + +# list-documents +# -> (user, collection?) +# <- (document_metadata[]) +# <- (error) + +# list-processing +# -> (user, collection?) +# <- (processing_metadata[]) +# <- (error) + +# OLD: # add(Metadata, Bytes) : error? # copy(id, user, collection) # move(id, user, collection) @@ -26,17 +62,21 @@ from . documents import Document, TextDocument # info(id[]) : DocumentInfo[] # search([]) : id[] -class DocumentPackage(Record): +class DocumentMetadata(Record): id = String() - flow = String() - document = Bytes() + time = Long() kind = String() - user = String() - collection = String() title = String() comments = String() - time = Long() metadata = Array(Triple()) + tags = Array(String()) + +class ProcessingMetadata(Record): + document_id = String() + time = Long() + flow = String() + user = String() + collection = String() class DocumentInfo(Record): id = String() @@ -55,12 +95,35 @@ class Criteria(Record): operator = String() class LibrarianRequest(Record): + + # add-document, remove-document, update-document, get-document-metadata, + # get-document-content, add-processing, remove-processing, list-documents, + # list-processing operation = String() - id = String() - flow = String() - document = DocumentPackage() + + # add-document, remove-document, update-document, get-document-metadata, + # get-document-content + document_id = String() + + # add-processing, remove-processing + processing_id = String() + + # add-document, update-document + document_metadata = DocumentMetadata() + + # add-processing + processing_metadata = ProcessingMetadata() + + # add-document + content = Bytes() + + # list-documents, list-processing user = String() + + # list-documents?, list-processing? collection = String() + + # criteria = Array(Criteria()) class LibrarianResponse(Record):