2025-02-11 16:01:03 +00:00
|
|
|
|
2025-03-11 16:52:59 +00:00
|
|
|
from pulsar.schema import Record, Bytes, String, Array, Long
|
2025-02-11 16:01:03 +00:00
|
|
|
from . types import Triple
|
|
|
|
|
from . topic import topic
|
|
|
|
|
from . types import Error
|
|
|
|
|
from . metadata import Metadata
|
|
|
|
|
from . documents import Document, TextDocument
|
|
|
|
|
|
2025-05-04 22:26:19 +01:00
|
|
|
# add-document
|
|
|
|
|
# -> (document_id, document_metadata, content)
|
2025-03-11 16:52:59 +00:00
|
|
|
# <- ()
|
|
|
|
|
# <- (error)
|
|
|
|
|
|
2025-05-04 22:26:19 +01:00
|
|
|
# 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
|
2025-03-11 16:52:59 +00:00
|
|
|
# -> (user, collection?)
|
2025-05-04 22:26:19 +01:00
|
|
|
# <- (document_metadata[])
|
2025-03-11 16:52:59 +00:00
|
|
|
# <- (error)
|
|
|
|
|
|
2025-05-04 22:26:19 +01:00
|
|
|
# list-processing
|
|
|
|
|
# -> (user, collection?)
|
|
|
|
|
# <- (processing_metadata[])
|
|
|
|
|
# <- (error)
|
|
|
|
|
|
|
|
|
|
# OLD:
|
2025-02-11 16:01:03 +00:00
|
|
|
# add(Metadata, Bytes) : error?
|
|
|
|
|
# copy(id, user, collection)
|
|
|
|
|
# move(id, user, collection)
|
|
|
|
|
# delete(id)
|
|
|
|
|
# get(id) : Bytes
|
|
|
|
|
# reindex(id)
|
|
|
|
|
# list(user, collection) : id[]
|
|
|
|
|
# info(id[]) : DocumentInfo[]
|
|
|
|
|
# search(<key,op,value>[]) : id[]
|
|
|
|
|
|
2025-05-04 22:26:19 +01:00
|
|
|
class DocumentMetadata(Record):
|
2025-03-11 16:52:59 +00:00
|
|
|
id = String()
|
2025-05-04 22:26:19 +01:00
|
|
|
time = Long()
|
2025-02-11 16:01:03 +00:00
|
|
|
kind = String()
|
2025-02-12 23:39:24 +00:00
|
|
|
title = String()
|
|
|
|
|
comments = String()
|
2025-03-11 16:52:59 +00:00
|
|
|
metadata = Array(Triple())
|
2025-05-04 22:26:19 +01:00
|
|
|
user = String()
|
|
|
|
|
tags = Array(String())
|
2025-02-11 16:01:03 +00:00
|
|
|
|
2025-05-04 22:26:19 +01:00
|
|
|
class ProcessingMetadata(Record):
|
2025-03-11 16:52:59 +00:00
|
|
|
id = String()
|
2025-05-04 22:26:19 +01:00
|
|
|
document_id = String()
|
|
|
|
|
time = Long()
|
|
|
|
|
flow = String()
|
2025-02-11 16:01:03 +00:00
|
|
|
user = String()
|
|
|
|
|
collection = String()
|
2025-05-04 22:26:19 +01:00
|
|
|
tags = Array(String())
|
2025-02-11 16:01:03 +00:00
|
|
|
|
|
|
|
|
class Criteria(Record):
|
|
|
|
|
key = String()
|
|
|
|
|
value = String()
|
|
|
|
|
operator = String()
|
|
|
|
|
|
|
|
|
|
class LibrarianRequest(Record):
|
2025-05-04 22:26:19 +01:00
|
|
|
|
|
|
|
|
# add-document, remove-document, update-document, get-document-metadata,
|
|
|
|
|
# get-document-content, add-processing, remove-processing, list-documents,
|
|
|
|
|
# list-processing
|
2025-02-11 16:01:03 +00:00
|
|
|
operation = String()
|
2025-05-04 22:26:19 +01:00
|
|
|
|
|
|
|
|
# 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
|
2025-02-11 16:01:03 +00:00
|
|
|
user = String()
|
2025-05-04 22:26:19 +01:00
|
|
|
|
|
|
|
|
# list-documents?, list-processing?
|
2025-02-11 16:01:03 +00:00
|
|
|
collection = String()
|
2025-05-04 22:26:19 +01:00
|
|
|
|
|
|
|
|
#
|
2025-02-11 16:01:03 +00:00
|
|
|
criteria = Array(Criteria())
|
|
|
|
|
|
|
|
|
|
class LibrarianResponse(Record):
|
|
|
|
|
error = Error()
|
2025-05-04 22:26:19 +01:00
|
|
|
document_metadata = DocumentMetadata()
|
|
|
|
|
content = Bytes()
|
|
|
|
|
document_metadatas = Array(DocumentMetadata())
|
|
|
|
|
processing_metadatas = Array(ProcessingMetadata())
|
2025-02-11 16:01:03 +00:00
|
|
|
|
|
|
|
|
librarian_request_queue = topic(
|
|
|
|
|
'librarian', kind='non-persistent', namespace='request'
|
|
|
|
|
)
|
|
|
|
|
librarian_response_queue = topic(
|
|
|
|
|
'librarian', kind='non-persistent', namespace='response',
|
|
|
|
|
)
|
|
|
|
|
|