documente_shared 0.1.96__tar.gz → 0.1.98__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of documente_shared might be problematic. Click here for more details.

Files changed (56) hide show
  1. {documente_shared-0.1.96 → documente_shared-0.1.98}/PKG-INFO +1 -1
  2. documente_shared-0.1.96/documente_shared/domain/entities/in_memory_result.py → documente_shared-0.1.98/documente_shared/domain/entities/in_memory_document.py +15 -1
  3. {documente_shared-0.1.96 → documente_shared-0.1.98}/documente_shared/domain/entities/processing_case.py +3 -2
  4. {documente_shared-0.1.96 → documente_shared-0.1.98}/documente_shared/domain/entities/processing_case_item.py +1 -1
  5. documente_shared-0.1.98/documente_shared/domain/exceptions.py +5 -0
  6. documente_shared-0.1.98/documente_shared/infrastructure/repositories/mem_document.py +37 -0
  7. documente_shared-0.1.98/documente_shared/infrastructure/repositories/mem_processing_case.py +36 -0
  8. {documente_shared-0.1.96 → documente_shared-0.1.98}/pyproject.toml +3 -2
  9. {documente_shared-0.1.96 → documente_shared-0.1.98}/README.md +0 -0
  10. {documente_shared-0.1.96 → documente_shared-0.1.98}/documente_shared/__init__.py +0 -0
  11. {documente_shared-0.1.96 → documente_shared-0.1.98}/documente_shared/application/__init__.py +0 -0
  12. {documente_shared-0.1.96 → documente_shared-0.1.98}/documente_shared/application/dates.py +0 -0
  13. {documente_shared-0.1.96 → documente_shared-0.1.98}/documente_shared/application/digest.py +0 -0
  14. {documente_shared-0.1.96 → documente_shared-0.1.98}/documente_shared/application/exceptions.py +0 -0
  15. {documente_shared-0.1.96 → documente_shared-0.1.98}/documente_shared/application/files.py +0 -0
  16. {documente_shared-0.1.96 → documente_shared-0.1.98}/documente_shared/application/payloads.py +0 -0
  17. {documente_shared-0.1.96 → documente_shared-0.1.98}/documente_shared/application/query_params.py +0 -0
  18. {documente_shared-0.1.96 → documente_shared-0.1.98}/documente_shared/application/time_utils.py +0 -0
  19. {documente_shared-0.1.96 → documente_shared-0.1.98}/documente_shared/application/timezone.py +0 -0
  20. {documente_shared-0.1.96 → documente_shared-0.1.98}/documente_shared/domain/__init__.py +0 -0
  21. {documente_shared-0.1.96 → documente_shared-0.1.98}/documente_shared/domain/base_enum.py +0 -0
  22. {documente_shared-0.1.96 → documente_shared-0.1.98}/documente_shared/domain/constants.py +0 -0
  23. {documente_shared-0.1.96 → documente_shared-0.1.98}/documente_shared/domain/entities/__init__.py +0 -0
  24. {documente_shared-0.1.96 → documente_shared-0.1.98}/documente_shared/domain/entities/document.py +0 -0
  25. {documente_shared-0.1.96 → documente_shared-0.1.98}/documente_shared/domain/entities/document_metadata.py +0 -0
  26. {documente_shared-0.1.96 → documente_shared-0.1.98}/documente_shared/domain/entities/processing_case_filters.py +0 -0
  27. {documente_shared-0.1.96 → documente_shared-0.1.98}/documente_shared/domain/entities/processing_case_item_filters.py +0 -0
  28. {documente_shared-0.1.96 → documente_shared-0.1.98}/documente_shared/domain/entities/processing_event.py +0 -0
  29. {documente_shared-0.1.96 → documente_shared-0.1.98}/documente_shared/domain/entities/scaling.py +0 -0
  30. {documente_shared-0.1.96 → documente_shared-0.1.98}/documente_shared/domain/enums/__init__.py +0 -0
  31. {documente_shared-0.1.96 → documente_shared-0.1.98}/documente_shared/domain/enums/common.py +0 -0
  32. {documente_shared-0.1.96 → documente_shared-0.1.98}/documente_shared/domain/enums/document.py +0 -0
  33. {documente_shared-0.1.96 → documente_shared-0.1.98}/documente_shared/domain/enums/processing_case.py +0 -0
  34. {documente_shared-0.1.96 → documente_shared-0.1.98}/documente_shared/domain/interfaces/__init__.py +0 -0
  35. {documente_shared-0.1.96 → documente_shared-0.1.98}/documente_shared/domain/interfaces/scaling.py +0 -0
  36. {documente_shared-0.1.96 → documente_shared-0.1.98}/documente_shared/domain/repositories/__init__.py +0 -0
  37. {documente_shared-0.1.96 → documente_shared-0.1.98}/documente_shared/domain/repositories/document.py +0 -0
  38. {documente_shared-0.1.96 → documente_shared-0.1.98}/documente_shared/domain/repositories/processing_case.py +0 -0
  39. {documente_shared-0.1.96 → documente_shared-0.1.98}/documente_shared/domain/repositories/processing_case_item.py +0 -0
  40. {documente_shared-0.1.96 → documente_shared-0.1.98}/documente_shared/infrastructure/__init__.py +0 -0
  41. {documente_shared-0.1.96 → documente_shared-0.1.98}/documente_shared/infrastructure/documente_client.py +0 -0
  42. {documente_shared-0.1.96 → documente_shared-0.1.98}/documente_shared/infrastructure/dynamo_table.py +0 -0
  43. {documente_shared-0.1.96 → documente_shared-0.1.98}/documente_shared/infrastructure/lambdas.py +0 -0
  44. {documente_shared-0.1.96 → documente_shared-0.1.98}/documente_shared/infrastructure/repositories/__init__.py +0 -0
  45. {documente_shared-0.1.96 → documente_shared-0.1.98}/documente_shared/infrastructure/repositories/dynamo_document.py +0 -0
  46. {documente_shared-0.1.96 → documente_shared-0.1.98}/documente_shared/infrastructure/repositories/dynamo_processing_case.py +0 -0
  47. {documente_shared-0.1.96 → documente_shared-0.1.98}/documente_shared/infrastructure/repositories/dynamo_processing_case_item.py +0 -0
  48. {documente_shared-0.1.96 → documente_shared-0.1.98}/documente_shared/infrastructure/repositories/http_document_processing.py +0 -0
  49. {documente_shared-0.1.96 → documente_shared-0.1.98}/documente_shared/infrastructure/repositories/http_processing_case.py +0 -0
  50. {documente_shared-0.1.96 → documente_shared-0.1.98}/documente_shared/infrastructure/repositories/http_processing_case_item.py +0 -0
  51. {documente_shared-0.1.96 → documente_shared-0.1.98}/documente_shared/infrastructure/s3_bucket.py +0 -0
  52. {documente_shared-0.1.96 → documente_shared-0.1.98}/documente_shared/infrastructure/services/__init__.py +0 -0
  53. {documente_shared-0.1.96 → documente_shared-0.1.98}/documente_shared/infrastructure/services/http_scaling.py +0 -0
  54. {documente_shared-0.1.96 → documente_shared-0.1.98}/documente_shared/infrastructure/sqs_queue.py +0 -0
  55. {documente_shared-0.1.96 → documente_shared-0.1.98}/documente_shared/presentation/__init__.py +0 -0
  56. {documente_shared-0.1.96 → documente_shared-0.1.98}/documente_shared/presentation/presenters.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: documente_shared
3
- Version: 0.1.96
3
+ Version: 0.1.98
4
4
  Summary: Shared utilities for Documente AI projects
5
5
  License: MIT
6
6
  Author: Tech
@@ -1,10 +1,12 @@
1
- from dataclasses import dataclass
1
+ import base64
2
2
  from typing import Optional
3
+ from dataclasses import dataclass
3
4
 
4
5
  from documente_shared.application.files import (
5
6
  remove_slash_from_path,
6
7
  get_filename_from_path,
7
8
  )
9
+ from documente_shared.domain.exceptions import InMemoryDocumentContentError
8
10
 
9
11
 
10
12
  @dataclass
@@ -48,6 +50,18 @@ class InMemoryDocument(object):
48
50
 
49
51
  @classmethod
50
52
  def from_dict(cls, data: dict):
53
+ has_bytes_content = data.get('file_bytes') and isinstance(data['file_bytes'], bytes)
54
+ has_base64_content = data.get('file_base64') and isinstance(data['file_base64'], str)
55
+
56
+ if not has_bytes_content and not has_base64_content:
57
+ raise InMemoryDocumentContentError
58
+
59
+ if has_bytes_content and not data.get('file_base64'):
60
+ data['file_base64'] = base64.b64encode(data.get('file_bytes')).decode("utf-8")
61
+
62
+ if has_base64_content and not data.get('file_bytes'):
63
+ data['file_bytes'] = base64.b64decode(data.get('file_base64'))
64
+
51
65
  return cls(
52
66
  file_path=data.get('file_path'),
53
67
  file_bytes=data.get('file_bytes'),
@@ -88,9 +88,10 @@ class ProcessingCase(object):
88
88
  def to_dict(self) -> dict:
89
89
  return {
90
90
  'uuid': self.uuid,
91
- 'label': self.name,
91
+ 'tenant_slug': self.tenant_slug,
92
+ 'name': self.name,
92
93
  'status': str(self.status),
93
- 'category': (
94
+ 'case_type': (
94
95
  str(self.case_type)
95
96
  if self.case_type else None
96
97
  ),
@@ -5,7 +5,7 @@ from typing import Optional, List
5
5
 
6
6
  from documente_shared.application.time_utils import get_datetime_from_data
7
7
  from documente_shared.domain.constants import la_paz_tz
8
- from documente_shared.domain.entities.in_memory_result import InMemoryDocument
8
+ from documente_shared.domain.entities.in_memory_document import InMemoryDocument
9
9
  from documente_shared.domain.enums.common import ProcessingStatus, ProcessingSource
10
10
  from documente_shared.domain.enums.processing_case import ProcessingDocumentType
11
11
 
@@ -0,0 +1,5 @@
1
+
2
+
3
+
4
+ class InMemoryDocumentContentError(Exception):
5
+ pass
@@ -0,0 +1,37 @@
1
+ from dataclasses import dataclass
2
+ from typing import List, Optional
3
+
4
+ from documente_shared.domain.entities.document import DocumentProcessing
5
+ from documente_shared.domain.enums.document import DocumentProcessingStatus
6
+ from documente_shared.domain.repositories.document import DocumentProcessingRepository
7
+
8
+
9
+ @dataclass
10
+ class MemoryDocumentProcessingRepository(DocumentProcessingRepository):
11
+ collection: dict[str, DocumentProcessing] = None
12
+
13
+ def __post_init__(self):
14
+ self.collection = self.collection or {}
15
+
16
+ def find(self, digest: str) -> Optional[DocumentProcessing]:
17
+ if digest in self.collection:
18
+ return self.collection[digest]
19
+ return None
20
+
21
+
22
+ def persist(self, instance: DocumentProcessing) -> DocumentProcessing:
23
+ self.collection[instance.digest] = instance
24
+ return instance
25
+
26
+ def remove(self, instance: DocumentProcessing):
27
+ if instance.digest in self.collection:
28
+ del self.collection[instance.digest]
29
+ return None
30
+
31
+ def filter(self, statuses: List[DocumentProcessingStatus]) -> List[DocumentProcessing]:
32
+ items = []
33
+ for status in statuses:
34
+ items.extend(
35
+ [item for item in self.collection.values() if item.status == status]
36
+ )
37
+ return items
@@ -0,0 +1,36 @@
1
+ from dataclasses import dataclass
2
+ from typing import List, Optional
3
+
4
+ from documente_shared.domain.entities.processing_case import ProcessingCase
5
+ from documente_shared.domain.entities.processing_case_filters import ProcessingCaseFilters
6
+
7
+ from documente_shared.domain.repositories.processing_case import ProcessingCaseRepository
8
+
9
+
10
+ @dataclass
11
+ class MemoryProcessingCaseRepository(ProcessingCaseRepository):
12
+ collection: dict[str, ProcessingCase] = None
13
+
14
+ def __post_init__(self):
15
+ self.collection = self.collection or {}
16
+
17
+ def find(
18
+ self,
19
+ uuid: str,
20
+ include_items: bool = False,
21
+ ) -> Optional[ProcessingCase]:
22
+ if uuid in self.collection:
23
+ return self.collection[uuid]
24
+ return None
25
+
26
+ def persist(self, instance: ProcessingCase) -> ProcessingCase:
27
+ self.collection[instance.uuid] = instance
28
+ return instance
29
+
30
+ def remove(self, instance: ProcessingCase):
31
+ if instance.uuid in self.collection:
32
+ del self.collection[instance.uuid]
33
+ return None
34
+
35
+ def filter(self, filters: ProcessingCaseFilters) -> List[ProcessingCase]:
36
+ return []
@@ -1,6 +1,6 @@
1
1
  [tool.poetry]
2
2
  name = "documente_shared"
3
- version = "0.1.96"
3
+ version = "0.1.98"
4
4
  description = "Shared utilities for Documente AI projects"
5
5
  authors = ["Tech <tech@llamitai.com>"]
6
6
  license = "MIT"
@@ -15,9 +15,10 @@ pytz = "^2025.2"
15
15
  requests = "^2.32.3"
16
16
  loguru = "^0.7.3"
17
17
 
18
- [tool.poetry.dev-dependencies]
18
+ [tool.poetry.group.dev.dependencies]
19
19
  pytest = "^8.3.4"
20
20
  ipdb = "^0.13.13"
21
+ expects = "^0.9.0"
21
22
 
22
23
 
23
24
  [tool.pytest.ini_options]