julee.repositories.memory.document

Memory implementation of DocumentRepository.

This module provides an in-memory implementation of the DocumentRepository protocol that follows the Clean Architecture patterns defined in the Fun-Police Framework. It handles document storage with content and metadata in memory dictionaries, ensuring idempotency and proper error handling.

The implementation uses Python dictionaries to store document data, making it ideal for testing scenarios where external dependencies should be avoided. All operations are still async to maintain interface compatibility.

Attributes

Classes

MemoryDocumentRepository

Memory implementation of DocumentRepository using Python dictionaries.

Module Contents

class julee.repositories.memory.document.MemoryDocumentRepository[source]

Bases: julee.domain.repositories.document.DocumentRepository, julee.repositories.memory.base.MemoryRepositoryMixin[julee.domain.models.document.Document]

Memory implementation of DocumentRepository using Python dictionaries.

This implementation stores document metadata and content in memory: - Documents: Dictionary keyed by document_id containing Document objects

This provides a lightweight, dependency-free option for testing while maintaining the same interface as other implementations.

async generate_id()[source]

Generate a unique document identifier.

Returns:

Unique document ID string

Return type:

str

async get(document_id)[source]

Retrieve a document with metadata and content.

Parameters:

document_id (str) – Unique document identifier

Returns:

Document object if found, None otherwise

Return type:

julee.domain.models.document.Document | None

async get_many(document_ids)[source]

Retrieve multiple documents by ID.

Parameters:

document_ids (list[str]) – List of unique document identifiers

Returns:

Dict mapping document_id to Document (or None if not found)

Return type:

dict[str, julee.domain.models.document.Document | None]

async list_all()[source]

List all documents.

Returns:

List of all Document entities in the repository

Return type:

list[julee.domain.models.document.Document]

async save(document)[source]

Save a document with its content and metadata.

If the document has content_bytes, it will be normalized to bytes (encoding str as UTF-8), converted to a ContentStream and the content hash will be calculated automatically.

Parameters:

document (julee.domain.models.document.Document) – Document object to save

Raises:
  • ValueError – If document has no content or content_bytes

  • TypeError – If content_bytes is not bytes or str

entity_name = 'Document'[source]
logger[source]
storage_dict: dict[str, julee.domain.models.document.Document][source]
julee.repositories.memory.document.logger[source]