documente_shared 0.1.72__py3-none-any.whl → 0.1.73__py3-none-any.whl

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.

@@ -1,3 +1,8 @@
1
1
  import pytz
2
+ from os import environ
2
3
 
3
- la_paz_tz = pytz.timezone("America/La_Paz")
4
+
5
+ la_paz_tz = pytz.timezone("America/La_Paz")
6
+
7
+ DOCUMENTE_API_URL = environ.get("DOCUMENTE_API_URL")
8
+ DOCUMENTE_API_KEY = environ.get("DOCUMENTE_API_KEY")
@@ -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 ProcessingCaseCategory
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
- label: str
15
+ name: str
16
+ tenant_slug: str
16
17
  status: ProcessingStatus
17
- category: Optional[ProcessingCaseCategory] = None
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.label == other.label
67
+ and self.name == other.name
67
68
  and self.status == other.status
68
- and self.category == other.category
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.label,
82
+ 'label': self.name,
82
83
  'status': str(self.status),
83
84
  'category': (
84
- str(self.category)
85
- if self.category else None
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
- label=data.get('label'),
129
+ name=data.get('label'),
129
130
  status=ProcessingStatus.from_value(data.get('status')),
130
- category=(
131
- ProcessingCaseCategory.from_value(data.get('category'))
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')),
@@ -1,12 +1,13 @@
1
1
  from documente_shared.domain.base_enum import BaseEnum
2
2
 
3
3
 
4
- class ProcessingCaseCategory(BaseEnum):
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 == ProcessingCaseCategory.BCP_MICROCREDITO
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, case_id: str) -> Optional[ProcessingCase]:
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, digest: str) -> Optional[ProcessingCaseItem]:
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, case_id: str) -> Optional[ProcessingCase]:
17
- item = self.get(key={'case_id': case_id})
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={'case_id': instance.case_id})
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, digest: str) -> Optional[ProcessingCaseItem]:
17
- item = self.get(key={'digest': 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 []
@@ -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
  Metadata-Version: 2.1
2
2
  Name: documente_shared
3
- Version: 0.1.72
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
 
@@ -7,30 +7,33 @@ documente_shared/application/time_utils.py,sha256=_fxgh8VoGPkdsft47COJ16vFwt8pMb
7
7
  documente_shared/application/timezone.py,sha256=NHpzTzOPD_fWQiJ4BrRqt_TIDs5XyB5ZMR7x8vUk8gQ,183
8
8
  documente_shared/domain/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
9
9
  documente_shared/domain/base_enum.py,sha256=DojAfn-zQdtjtImeHUpBzE6TBTm07XrbMOdW3h8RVd8,1449
10
- documente_shared/domain/constants.py,sha256=jOlMKFq12FgiYMJcQHku8IVwuOE5t-HEPuSV_zEeIFo,56
10
+ documente_shared/domain/constants.py,sha256=NG5BGaXBr_FnzudjTRPxpDpyiSDdaB_PLCdlYlFUQeU,187
11
11
  documente_shared/domain/entities/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
12
12
  documente_shared/domain/entities/document.py,sha256=AthTUyA-QZE3WAT7lMoKVr_Z8mO_3qERuCnZge0DTLQ,12595
13
13
  documente_shared/domain/entities/document_metadata.py,sha256=ygyFIC5qwxlm8DUM5kvVFny9zJfPQS8vNLM2br5XsQ8,2353
14
14
  documente_shared/domain/entities/in_memory_result.py,sha256=Q1E9vnLL5Hz5xunOqWtQmJOMjoK5KN42LZr18GlBAZo,1246
15
- documente_shared/domain/entities/processing_case.py,sha256=rGbFs3XhKppGOfH3XMa2BiCyr7lnqRMjhDXM6oUwKXE,5157
15
+ documente_shared/domain/entities/processing_case.py,sha256=3bL6BgFwWe6F5keZ6A1K_lLsrwGpkcKg98roM_i6kEQ,5167
16
16
  documente_shared/domain/entities/processing_case_item.py,sha256=hglyPhZBSjlMKVdEVccyHXU3aQRdZ8hfZlXDJnkf7wA,7996
17
17
  documente_shared/domain/entities/processing_event.py,sha256=m1O0gcNaE_SszeIhxM3uYPHSpyOUmize6mfRw1_bYZo,1723
18
18
  documente_shared/domain/enums/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
19
19
  documente_shared/domain/enums/common.py,sha256=vXldMUPhhWo0PfTgYwDSjI8bur_lYcImZYiV7yAO7DQ,2262
20
20
  documente_shared/domain/enums/document.py,sha256=NltZA1YVgJ7dVfSQdJFIE0ZUGf9Y-nxNXsVQ6GiPLL4,1827
21
- documente_shared/domain/enums/processing_case.py,sha256=DLVk0VnVzrKs1CvXVGHV9p8mBUHLUrOSJJ1POE-Ek3o,1546
21
+ documente_shared/domain/enums/processing_case.py,sha256=LhFhcoWlockxcpplsVdC6M2kpXn7sOdzQySf24wFhx8,1572
22
22
  documente_shared/domain/repositories/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
23
23
  documente_shared/domain/repositories/document.py,sha256=vJzr6c92gqBzyhaEdjrvnoneKRrWmJ0AsvocPnhxiLU,767
24
- documente_shared/domain/repositories/processing_case.py,sha256=7WE5RdLr04ysGXAdkJYmbfcLpMyOMeuDJGounZKMZqs,729
25
- documente_shared/domain/repositories/processing_case_item.py,sha256=yD-v_24UzHwNdq75KRJGwHemTVFpO9LMIPSup4GbyKs,959
24
+ documente_shared/domain/repositories/processing_case.py,sha256=E2AivKrtoWdGiI9XLZp6-8xN7YZrd_is8jl3GOyYYvQ,726
25
+ documente_shared/domain/repositories/processing_case_item.py,sha256=XZLmYsHkaJ0gyMlACHZX2FywxdcH9oJ6-rvWdJgWpbs,957
26
26
  documente_shared/infrastructure/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
27
+ documente_shared/infrastructure/documente_client.py,sha256=UjVWs9DKa-yhw5DVbcEs8iJxalHOarusVayi_ob6QhE,494
27
28
  documente_shared/infrastructure/dynamo_table.py,sha256=TMQbcuty7wjDMbuhI8PbT0IGXelgELsNTtqTEQeZ824,2112
28
29
  documente_shared/infrastructure/repositories/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
29
30
  documente_shared/infrastructure/repositories/dynamo_document.py,sha256=_Yp4gtA-n-hJ2w2wAM5BMCs2Mf46Q2Kq3eHqlxudkL4,1443
30
- documente_shared/infrastructure/repositories/dynamo_processing_case.py,sha256=Wt0di0402mrnvYNqe5ywDtFFdXjnHHvLDG4k_MQfmTE,1401
31
- documente_shared/infrastructure/repositories/dynamo_processing_case_item.py,sha256=gG7H7hyeKTPMywTUmnq0nClrpaOqVPy7bh1OLBzV4pE,1816
31
+ documente_shared/infrastructure/repositories/dynamo_processing_case.py,sha256=UJcROnmfKvE5k_GZOHvaYDvnNSX4Rm22xCB7tUaUUEU,1386
32
+ documente_shared/infrastructure/repositories/dynamo_processing_case_item.py,sha256=reHtgWmLXbLhWUw14sG22Mj7RVzs8XZmTt13kElUcpA,1812
33
+ documente_shared/infrastructure/repositories/http_processing_case.py,sha256=0etYPjeWW2bWvKtBvgeaZQxj-qw91T228biIbJSGsGo,1683
34
+ documente_shared/infrastructure/repositories/http_processing_case_item.py,sha256=2-I2Oq4PFI1WsSnOzNC5OlqU1NE2QdZ5X3U_CjA-cls,2187
32
35
  documente_shared/infrastructure/s3_bucket.py,sha256=vT_yN42RFQXubtUn8ln-j13Os_-25UGClVtXg5Bkv6I,1932
33
36
  documente_shared/infrastructure/sqs_queue.py,sha256=KZWeHZ9zmXmrxoNpOQX7GEdDhZ1knbPXgwSwFwJblGg,1504
34
- documente_shared-0.1.72.dist-info/METADATA,sha256=k9oTLxK2WigrpoZx6Psxtqs_OOBWWM-6VuAXZ_kjUVc,839
35
- documente_shared-0.1.72.dist-info/WHEEL,sha256=Nq82e9rUAnEjt98J6MlVmMCZb-t9cYE2Ir1kpBmnWfs,88
36
- documente_shared-0.1.72.dist-info/RECORD,,
37
+ documente_shared-0.1.73.dist-info/METADATA,sha256=KVhxyT5zo7u_nG8RjY2pzflZ3SvZxyw_4-KQNu-QCIs,881
38
+ documente_shared-0.1.73.dist-info/WHEEL,sha256=Nq82e9rUAnEjt98J6MlVmMCZb-t9cYE2Ir1kpBmnWfs,88
39
+ documente_shared-0.1.73.dist-info/RECORD,,