documente_shared 0.1.72__tar.gz → 0.1.73__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.
- {documente_shared-0.1.72 → documente_shared-0.1.73}/PKG-INFO +2 -1
- documente_shared-0.1.73/documente_shared/domain/constants.py +8 -0
- {documente_shared-0.1.72 → documente_shared-0.1.73}/documente_shared/domain/entities/processing_case.py +12 -11
- {documente_shared-0.1.72 → documente_shared-0.1.73}/documente_shared/domain/enums/processing_case.py +3 -2
- {documente_shared-0.1.72 → documente_shared-0.1.73}/documente_shared/domain/repositories/processing_case.py +1 -1
- {documente_shared-0.1.72 → documente_shared-0.1.73}/documente_shared/domain/repositories/processing_case_item.py +1 -1
- documente_shared-0.1.73/documente_shared/infrastructure/documente_client.py +21 -0
- {documente_shared-0.1.72 → documente_shared-0.1.73}/documente_shared/infrastructure/repositories/dynamo_processing_case.py +3 -3
- {documente_shared-0.1.72 → documente_shared-0.1.73}/documente_shared/infrastructure/repositories/dynamo_processing_case_item.py +2 -2
- documente_shared-0.1.73/documente_shared/infrastructure/repositories/http_processing_case.py +41 -0
- documente_shared-0.1.73/documente_shared/infrastructure/repositories/http_processing_case_item.py +53 -0
- {documente_shared-0.1.72 → documente_shared-0.1.73}/pyproject.toml +2 -1
- documente_shared-0.1.72/documente_shared/domain/constants.py +0 -3
- {documente_shared-0.1.72 → documente_shared-0.1.73}/README.md +0 -0
- {documente_shared-0.1.72 → documente_shared-0.1.73}/documente_shared/__init__.py +0 -0
- {documente_shared-0.1.72 → documente_shared-0.1.73}/documente_shared/application/__init__.py +0 -0
- {documente_shared-0.1.72 → documente_shared-0.1.73}/documente_shared/application/digest.py +0 -0
- {documente_shared-0.1.72 → documente_shared-0.1.73}/documente_shared/application/exceptions.py +0 -0
- {documente_shared-0.1.72 → documente_shared-0.1.73}/documente_shared/application/files.py +0 -0
- {documente_shared-0.1.72 → documente_shared-0.1.73}/documente_shared/application/time_utils.py +0 -0
- {documente_shared-0.1.72 → documente_shared-0.1.73}/documente_shared/application/timezone.py +0 -0
- {documente_shared-0.1.72 → documente_shared-0.1.73}/documente_shared/domain/__init__.py +0 -0
- {documente_shared-0.1.72 → documente_shared-0.1.73}/documente_shared/domain/base_enum.py +0 -0
- {documente_shared-0.1.72 → documente_shared-0.1.73}/documente_shared/domain/entities/__init__.py +0 -0
- {documente_shared-0.1.72 → documente_shared-0.1.73}/documente_shared/domain/entities/document.py +0 -0
- {documente_shared-0.1.72 → documente_shared-0.1.73}/documente_shared/domain/entities/document_metadata.py +0 -0
- {documente_shared-0.1.72 → documente_shared-0.1.73}/documente_shared/domain/entities/in_memory_result.py +0 -0
- {documente_shared-0.1.72 → documente_shared-0.1.73}/documente_shared/domain/entities/processing_case_item.py +0 -0
- {documente_shared-0.1.72 → documente_shared-0.1.73}/documente_shared/domain/entities/processing_event.py +0 -0
- {documente_shared-0.1.72 → documente_shared-0.1.73}/documente_shared/domain/enums/__init__.py +0 -0
- {documente_shared-0.1.72 → documente_shared-0.1.73}/documente_shared/domain/enums/common.py +0 -0
- {documente_shared-0.1.72 → documente_shared-0.1.73}/documente_shared/domain/enums/document.py +0 -0
- {documente_shared-0.1.72 → documente_shared-0.1.73}/documente_shared/domain/repositories/__init__.py +0 -0
- {documente_shared-0.1.72 → documente_shared-0.1.73}/documente_shared/domain/repositories/document.py +0 -0
- {documente_shared-0.1.72 → documente_shared-0.1.73}/documente_shared/infrastructure/__init__.py +0 -0
- {documente_shared-0.1.72 → documente_shared-0.1.73}/documente_shared/infrastructure/dynamo_table.py +0 -0
- {documente_shared-0.1.72 → documente_shared-0.1.73}/documente_shared/infrastructure/repositories/__init__.py +0 -0
- {documente_shared-0.1.72 → documente_shared-0.1.73}/documente_shared/infrastructure/repositories/dynamo_document.py +0 -0
- {documente_shared-0.1.72 → documente_shared-0.1.73}/documente_shared/infrastructure/s3_bucket.py +0 -0
- {documente_shared-0.1.72 → documente_shared-0.1.73}/documente_shared/infrastructure/sqs_queue.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: documente_shared
|
|
3
|
-
Version: 0.1.
|
|
3
|
+
Version: 0.1.73
|
|
4
4
|
Summary: Shared utilities for Documente AI projects
|
|
5
5
|
License: MIT
|
|
6
6
|
Author: Tech
|
|
@@ -14,6 +14,7 @@ Classifier: Programming Language :: Python :: 3.12
|
|
|
14
14
|
Requires-Dist: boto3 (>=1.37.19,<2.0.0)
|
|
15
15
|
Requires-Dist: botocore (>=1.37.19,<2.0.0)
|
|
16
16
|
Requires-Dist: pytz (>=2025.2,<2026.0)
|
|
17
|
+
Requires-Dist: requests (>=2.32.3,<3.0.0)
|
|
17
18
|
Requires-Dist: sentry-sdk (>=2.19.2,<3.0.0)
|
|
18
19
|
Description-Content-Type: text/markdown
|
|
19
20
|
|
|
@@ -6,15 +6,16 @@ from documente_shared.application.time_utils import get_datetime_from_data
|
|
|
6
6
|
from documente_shared.domain.constants import la_paz_tz
|
|
7
7
|
from documente_shared.domain.entities.processing_case_item import ProcessingCaseItem
|
|
8
8
|
from documente_shared.domain.enums.common import ProcessingStatus
|
|
9
|
-
from documente_shared.domain.enums.processing_case import
|
|
9
|
+
from documente_shared.domain.enums.processing_case import ProcessingCaseType
|
|
10
10
|
|
|
11
11
|
|
|
12
12
|
@dataclass
|
|
13
13
|
class ProcessingCase(object):
|
|
14
14
|
uuid: str
|
|
15
|
-
|
|
15
|
+
name: str
|
|
16
|
+
tenant_slug: str
|
|
16
17
|
status: ProcessingStatus
|
|
17
|
-
|
|
18
|
+
case_type: Optional[ProcessingCaseType] = None
|
|
18
19
|
enqueued_at: Optional[datetime] = None
|
|
19
20
|
started_at: Optional[datetime] = None
|
|
20
21
|
failed_at: Optional[datetime] = None
|
|
@@ -63,9 +64,9 @@ class ProcessingCase(object):
|
|
|
63
64
|
|
|
64
65
|
return (
|
|
65
66
|
self.uuid == other.uuid
|
|
66
|
-
and self.
|
|
67
|
+
and self.name == other.name
|
|
67
68
|
and self.status == other.status
|
|
68
|
-
and self.
|
|
69
|
+
and self.case_type == other.case_type
|
|
69
70
|
and self.enqueued_at == other.enqueued_at
|
|
70
71
|
and self.started_at == other.started_at
|
|
71
72
|
and self.failed_at == other.failed_at
|
|
@@ -78,11 +79,11 @@ class ProcessingCase(object):
|
|
|
78
79
|
def to_dict(self) -> dict:
|
|
79
80
|
return {
|
|
80
81
|
'uuid': self.uuid,
|
|
81
|
-
'label': self.
|
|
82
|
+
'label': self.name,
|
|
82
83
|
'status': str(self.status),
|
|
83
84
|
'category': (
|
|
84
|
-
str(self.
|
|
85
|
-
if self.
|
|
85
|
+
str(self.case_type)
|
|
86
|
+
if self.case_type else None
|
|
86
87
|
),
|
|
87
88
|
'enqueued_at': self.enqueued_at.isoformat() if self.enqueued_at else None,
|
|
88
89
|
'started_at': self.started_at.isoformat() if self.started_at else None,
|
|
@@ -125,10 +126,10 @@ class ProcessingCase(object):
|
|
|
125
126
|
def from_dict(cls, data: dict) -> 'ProcessingCase':
|
|
126
127
|
return cls(
|
|
127
128
|
uuid=data.get('uuid'),
|
|
128
|
-
|
|
129
|
+
name=data.get('label'),
|
|
129
130
|
status=ProcessingStatus.from_value(data.get('status')),
|
|
130
|
-
|
|
131
|
-
|
|
131
|
+
case_type=(
|
|
132
|
+
ProcessingCaseType.from_value(data.get('category'))
|
|
132
133
|
if data.get('category') else None
|
|
133
134
|
),
|
|
134
135
|
enqueued_at=get_datetime_from_data(input_datetime=data.get('enqueued_at')),
|
{documente_shared-0.1.72 → documente_shared-0.1.73}/documente_shared/domain/enums/processing_case.py
RENAMED
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
from documente_shared.domain.base_enum import BaseEnum
|
|
2
2
|
|
|
3
3
|
|
|
4
|
-
class
|
|
4
|
+
class ProcessingCaseType(BaseEnum):
|
|
5
5
|
BCP_MICROCREDITO = 'BCP_MICROCREDITO'
|
|
6
|
+
UNIVIDA_SOAT = 'UNIVIDA_SOAT'
|
|
6
7
|
|
|
7
8
|
@property
|
|
8
9
|
def is_bcp_microcredito(self):
|
|
9
|
-
return self ==
|
|
10
|
+
return self == ProcessingCaseType.BCP_MICROCREDITO
|
|
10
11
|
|
|
11
12
|
|
|
12
13
|
class ProcessingDocumentType(BaseEnum):
|
|
@@ -8,7 +8,7 @@ from documente_shared.domain.enums.common import ProcessingStatus
|
|
|
8
8
|
class ProcessingCaseRepository(ABC):
|
|
9
9
|
|
|
10
10
|
@abstractmethod
|
|
11
|
-
def find(self,
|
|
11
|
+
def find(self, uuid: str) -> Optional[ProcessingCase]:
|
|
12
12
|
raise NotImplementedError
|
|
13
13
|
|
|
14
14
|
@abstractmethod
|
|
@@ -9,7 +9,7 @@ from documente_shared.domain.enums.common import ProcessingStatus
|
|
|
9
9
|
class ProcessingCaseItemRepository(ABC):
|
|
10
10
|
|
|
11
11
|
@abstractmethod
|
|
12
|
-
def find(self,
|
|
12
|
+
def find(self, uuid: str) -> Optional[ProcessingCaseItem]:
|
|
13
13
|
raise NotImplementedError
|
|
14
14
|
|
|
15
15
|
@abstractmethod
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
from requests import Session
|
|
2
|
+
from dataclasses import dataclass
|
|
3
|
+
from typing import Optional
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
@dataclass
|
|
7
|
+
class DocumenteClientMixin(object):
|
|
8
|
+
api_url: str
|
|
9
|
+
api_key: str
|
|
10
|
+
session: Optional[Session] = None
|
|
11
|
+
|
|
12
|
+
def __post_init__(self):
|
|
13
|
+
self.session = Session()
|
|
14
|
+
self.session.headers.update(self.get_common_headers())
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
def get_common_headers(self) -> dict:
|
|
18
|
+
return {
|
|
19
|
+
"X-Api-Key": self.api_key,
|
|
20
|
+
"Content-Type": "application/json"
|
|
21
|
+
}
|
|
@@ -13,8 +13,8 @@ class DynamoProcessingCaseRepository(
|
|
|
13
13
|
DynamoDBTable,
|
|
14
14
|
ProcessingCaseRepository,
|
|
15
15
|
):
|
|
16
|
-
def find(self,
|
|
17
|
-
item = self.get(key={'
|
|
16
|
+
def find(self, uuid: str) -> Optional[ProcessingCase]:
|
|
17
|
+
item = self.get(key={'uuid': uuid})
|
|
18
18
|
if item:
|
|
19
19
|
return ProcessingCase.from_dict(item)
|
|
20
20
|
return None
|
|
@@ -24,7 +24,7 @@ class DynamoProcessingCaseRepository(
|
|
|
24
24
|
return instance
|
|
25
25
|
|
|
26
26
|
def remove(self, instance: ProcessingCase):
|
|
27
|
-
self.delete(key={'
|
|
27
|
+
self.delete(key={'uuid': instance.uuid})
|
|
28
28
|
|
|
29
29
|
def filter(self, statuses: List[ProcessingStatus]) -> List[ProcessingCase]:
|
|
30
30
|
items = []
|
|
@@ -13,8 +13,8 @@ class DynamoProcessingCaseItemRepository(
|
|
|
13
13
|
DynamoDBTable,
|
|
14
14
|
ProcessingCaseItemRepository,
|
|
15
15
|
):
|
|
16
|
-
def find(self,
|
|
17
|
-
item = self.get(key={'digest':
|
|
16
|
+
def find(self, uuid: str) -> Optional[ProcessingCaseItem]:
|
|
17
|
+
item = self.get(key={'digest': uuid})
|
|
18
18
|
if item:
|
|
19
19
|
return ProcessingCaseItem.from_dict(item)
|
|
20
20
|
return None
|
|
@@ -0,0 +1,41 @@
|
|
|
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.enums.common import ProcessingStatus
|
|
6
|
+
from documente_shared.domain.repositories.processing_case import ProcessingCaseRepository
|
|
7
|
+
from documente_shared.infrastructure.documente_client import DocumenteClientMixin
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
@dataclass
|
|
11
|
+
class HttpProcessingCaseRepository(
|
|
12
|
+
DocumenteClientMixin,
|
|
13
|
+
ProcessingCaseRepository,
|
|
14
|
+
):
|
|
15
|
+
def find(self, uuid: str) -> Optional[ProcessingCase]:
|
|
16
|
+
response = self.session.get(f"{self.api_url}/processing-cases/{uuid}/")
|
|
17
|
+
if response.status_code == 200:
|
|
18
|
+
return ProcessingCase.from_dict(response.json())
|
|
19
|
+
return None
|
|
20
|
+
|
|
21
|
+
def persist(self, instance: ProcessingCase) -> ProcessingCase:
|
|
22
|
+
response = self.session.put(
|
|
23
|
+
url=f"{self.api_url}/processing-cases/{instance.uuid}/",
|
|
24
|
+
json=instance.to_dict,
|
|
25
|
+
)
|
|
26
|
+
if response.status_code not in [200, 201]:
|
|
27
|
+
raise Exception(f'Error persisting processing case: {response.text}')
|
|
28
|
+
return ProcessingCase.from_dict(response.json())
|
|
29
|
+
|
|
30
|
+
def remove(self, instance: ProcessingCase):
|
|
31
|
+
self.session.delete(f"{self.api_url}/processing-cases/{instance.uuid}/")
|
|
32
|
+
|
|
33
|
+
def filter(self, statuses: List[ProcessingStatus]) -> List[ProcessingCase]:
|
|
34
|
+
response = self.session.get(f"{self.api_url}/processing-cases/")
|
|
35
|
+
if response.status_code == 200:
|
|
36
|
+
raw_response = response.json()
|
|
37
|
+
return [
|
|
38
|
+
ProcessingCase.from_dict(item)
|
|
39
|
+
for item in raw_response.get('data', [])
|
|
40
|
+
]
|
|
41
|
+
return []
|
documente_shared-0.1.73/documente_shared/infrastructure/repositories/http_processing_case_item.py
ADDED
|
@@ -0,0 +1,53 @@
|
|
|
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_item import ProcessingCaseItem
|
|
6
|
+
from documente_shared.domain.enums.common import ProcessingStatus
|
|
7
|
+
from documente_shared.domain.repositories.processing_case_item import ProcessingCaseItemRepository
|
|
8
|
+
from documente_shared.infrastructure.documente_client import DocumenteClientMixin
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
@dataclass
|
|
12
|
+
class HttpProcessingCaseItemRepository(
|
|
13
|
+
DocumenteClientMixin,
|
|
14
|
+
ProcessingCaseItemRepository,
|
|
15
|
+
):
|
|
16
|
+
|
|
17
|
+
def find(self, uuid: str) -> Optional[ProcessingCaseItem]:
|
|
18
|
+
response = self.session.get(f"{self.api_url}/processing-case-items/{uuid}/")
|
|
19
|
+
if response.status_code == 200:
|
|
20
|
+
return ProcessingCaseItem.from_dict(response.json())
|
|
21
|
+
return None
|
|
22
|
+
|
|
23
|
+
def persist(self, instance: ProcessingCaseItem) -> ProcessingCaseItem:
|
|
24
|
+
response = self.session.put(
|
|
25
|
+
url=f"{self.api_url}/processing-case-items/{instance.uuid}/",
|
|
26
|
+
json=instance.to_simple_dict,
|
|
27
|
+
)
|
|
28
|
+
if response.status_code in [200, 201]:
|
|
29
|
+
return ProcessingCaseItem.from_dict(response.json())
|
|
30
|
+
return instance
|
|
31
|
+
|
|
32
|
+
def remove(self, instance: ProcessingCaseItem):
|
|
33
|
+
self.session.delete(f"{self.api_url}/processing-case-items/{instance.uuid}/")
|
|
34
|
+
|
|
35
|
+
def filter(self, statuses: List[ProcessingStatus]) -> List[ProcessingCase]:
|
|
36
|
+
response = self.session.get(f"{self.api_url}/processing-case-items/")
|
|
37
|
+
if response.status_code == 200:
|
|
38
|
+
raw_response = response.json()
|
|
39
|
+
return [
|
|
40
|
+
ProcessingCase.from_dict(item)
|
|
41
|
+
for item in raw_response.get('data', [])
|
|
42
|
+
]
|
|
43
|
+
return []
|
|
44
|
+
|
|
45
|
+
def filter_by_case_id(self, case_id: str) -> List[ProcessingCase]:
|
|
46
|
+
response = self.session.get(f"{self.api_url}/processing-case-items/?case_id={case_id}")
|
|
47
|
+
if response.status_code == 200:
|
|
48
|
+
raw_response = response.json()
|
|
49
|
+
return [
|
|
50
|
+
ProcessingCase.from_dict(item)
|
|
51
|
+
for item in raw_response.get('data', [])
|
|
52
|
+
]
|
|
53
|
+
return []
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
[tool.poetry]
|
|
2
2
|
name = "documente_shared"
|
|
3
|
-
version = "0.1.
|
|
3
|
+
version = "0.1.73"
|
|
4
4
|
description = "Shared utilities for Documente AI projects"
|
|
5
5
|
authors = ["Tech <tech@llamitai.com>"]
|
|
6
6
|
license = "MIT"
|
|
@@ -12,6 +12,7 @@ boto3 = "^1.37.19"
|
|
|
12
12
|
botocore = "^1.37.19"
|
|
13
13
|
sentry-sdk = "^2.19.2"
|
|
14
14
|
pytz = "^2025.2"
|
|
15
|
+
requests = "^2.32.3"
|
|
15
16
|
|
|
16
17
|
[tool.poetry.dev-dependencies]
|
|
17
18
|
pytest = "^8.3.4"
|
|
File without changes
|
|
File without changes
|
{documente_shared-0.1.72 → documente_shared-0.1.73}/documente_shared/application/__init__.py
RENAMED
|
File without changes
|
|
File without changes
|
{documente_shared-0.1.72 → documente_shared-0.1.73}/documente_shared/application/exceptions.py
RENAMED
|
File without changes
|
|
File without changes
|
{documente_shared-0.1.72 → documente_shared-0.1.73}/documente_shared/application/time_utils.py
RENAMED
|
File without changes
|
{documente_shared-0.1.72 → documente_shared-0.1.73}/documente_shared/application/timezone.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
{documente_shared-0.1.72 → documente_shared-0.1.73}/documente_shared/domain/entities/__init__.py
RENAMED
|
File without changes
|
{documente_shared-0.1.72 → documente_shared-0.1.73}/documente_shared/domain/entities/document.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{documente_shared-0.1.72 → documente_shared-0.1.73}/documente_shared/domain/enums/__init__.py
RENAMED
|
File without changes
|
|
File without changes
|
{documente_shared-0.1.72 → documente_shared-0.1.73}/documente_shared/domain/enums/document.py
RENAMED
|
File without changes
|
{documente_shared-0.1.72 → documente_shared-0.1.73}/documente_shared/domain/repositories/__init__.py
RENAMED
|
File without changes
|
{documente_shared-0.1.72 → documente_shared-0.1.73}/documente_shared/domain/repositories/document.py
RENAMED
|
File without changes
|
{documente_shared-0.1.72 → documente_shared-0.1.73}/documente_shared/infrastructure/__init__.py
RENAMED
|
File without changes
|
{documente_shared-0.1.72 → documente_shared-0.1.73}/documente_shared/infrastructure/dynamo_table.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
{documente_shared-0.1.72 → documente_shared-0.1.73}/documente_shared/infrastructure/s3_bucket.py
RENAMED
|
File without changes
|
{documente_shared-0.1.72 → documente_shared-0.1.73}/documente_shared/infrastructure/sqs_queue.py
RENAMED
|
File without changes
|