maleo-foundation 0.0.6__py3-none-any.whl → 0.0.8__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.
- maleo_foundation/models/schemas/general.py +35 -1
- maleo_foundation/models/schemas/result.py +2 -50
- maleo_foundation/models/transfers/results/service/query.py +30 -4
- {maleo_foundation-0.0.6.dist-info → maleo_foundation-0.0.8.dist-info}/METADATA +1 -1
- {maleo_foundation-0.0.6.dist-info → maleo_foundation-0.0.8.dist-info}/RECORD +7 -7
- {maleo_foundation-0.0.6.dist-info → maleo_foundation-0.0.8.dist-info}/WHEEL +0 -0
- {maleo_foundation-0.0.6.dist-info → maleo_foundation-0.0.8.dist-info}/top_level.txt +0 -0
@@ -1,7 +1,7 @@
|
|
1
1
|
from __future__ import annotations
|
2
2
|
from datetime import date, datetime, timedelta, timezone
|
3
3
|
from pydantic import BaseModel, Field, model_validator, field_serializer, FieldSerializationInfo
|
4
|
-
from typing import Optional, Any
|
4
|
+
from typing import Optional, Union, Any
|
5
5
|
from uuid import UUID
|
6
6
|
from maleo_foundation.models.enums import BaseEnums
|
7
7
|
from maleo_foundation.constants import REFRESH_TOKEN_DURATION_DAYS, ACCESS_TOKEN_DURATION_MINUTES
|
@@ -48,6 +48,40 @@ class BaseGeneralSchemas:
|
|
48
48
|
|
49
49
|
class KeyPair(PublicKey, PrivateKey): pass
|
50
50
|
|
51
|
+
class Identifiers(BaseModel):
|
52
|
+
id:int = Field(..., ge=1, description="Data's ID, must be >= 1.")
|
53
|
+
uuid:UUID = Field(..., description="Data's UUID.")
|
54
|
+
|
55
|
+
@field_serializer('uuid')
|
56
|
+
def serialize_uuid(self, value:UUID, info:FieldSerializationInfo) -> str:
|
57
|
+
"""Serializes UUID to a hex string."""
|
58
|
+
return str(value)
|
59
|
+
|
60
|
+
class Timestamps(BaseModel):
|
61
|
+
created_at:datetime = Field(..., description="Data's created_at timestamp")
|
62
|
+
updated_at:datetime = Field(..., description="Data's updated_at timestamp")
|
63
|
+
deleted_at:Optional[datetime] = Field(..., description="Data's deleted_at timestamp")
|
64
|
+
restored_at:Optional[datetime] = Field(..., description="Data's restored_at timestamp")
|
65
|
+
deactivated_at:Optional[datetime] = Field(..., description="Data's deactivated_at timestamp")
|
66
|
+
activated_at:datetime = Field(..., description="Data's activated_at timestamp")
|
67
|
+
|
68
|
+
@field_serializer('created_at', 'updated_at', 'deleted_at', 'restored_at', 'deactivated_at', 'activated_at')
|
69
|
+
def serialize_timestamps(self, value:Union[datetime, date], info:FieldSerializationInfo) -> str:
|
70
|
+
"""Serializes datetime/date fields to ISO format."""
|
71
|
+
return value.isoformat()
|
72
|
+
|
73
|
+
class Status(BaseModel):
|
74
|
+
status:BaseEnums.StatusType = Field(..., description="Data's status")
|
75
|
+
|
76
|
+
class Order(BaseModel):
|
77
|
+
order:Optional[int] = Field(..., description="Data's order")
|
78
|
+
|
79
|
+
class Key(BaseModel):
|
80
|
+
key:str = Field(..., description="Data's key")
|
81
|
+
|
82
|
+
class Name(BaseModel):
|
83
|
+
name:str = Field(..., description="Data's name")
|
84
|
+
|
51
85
|
class TokenPayload(BaseModel):
|
52
86
|
t:BaseEnums.TokenType = Field(..., description="Token Type")
|
53
87
|
sr:UUID = Field(..., description="System role")
|
@@ -1,56 +1,8 @@
|
|
1
|
-
from
|
2
|
-
from
|
3
|
-
from typing import Literal, Optional, Union, Any
|
4
|
-
from uuid import UUID
|
5
|
-
from maleo_foundation.models.enums import BaseEnums
|
1
|
+
from pydantic import BaseModel, Field
|
2
|
+
from typing import Literal, Optional, Any
|
6
3
|
from maleo_foundation.models.schemas.general import BaseGeneralSchemas
|
7
4
|
|
8
5
|
class BaseResultSchemas:
|
9
|
-
class Identifiers(BaseModel):
|
10
|
-
id:int = Field(..., ge=1, description="Data's ID, must be >= 1.")
|
11
|
-
uuid:UUID = Field(..., description="Data's UUID.")
|
12
|
-
|
13
|
-
@field_serializer('uuid')
|
14
|
-
def serialize_uuid(self, value:UUID, info:FieldSerializationInfo) -> str:
|
15
|
-
"""Serializes UUID to a hex string."""
|
16
|
-
return str(value)
|
17
|
-
|
18
|
-
class Timestamps(BaseModel):
|
19
|
-
created_at:datetime = Field(..., description="Data's created_at timestamp")
|
20
|
-
updated_at:datetime = Field(..., description="Data's updated_at timestamp")
|
21
|
-
deleted_at:Optional[datetime] = Field(..., description="Data's deleted_at timestamp")
|
22
|
-
restored_at:Optional[datetime] = Field(..., description="Data's restored_at timestamp")
|
23
|
-
deactivated_at:Optional[datetime] = Field(..., description="Data's deactivated_at timestamp")
|
24
|
-
activated_at:datetime = Field(..., description="Data's activated_at timestamp")
|
25
|
-
|
26
|
-
@field_serializer('created_at', 'updated_at', 'deleted_at', 'restored_at', 'deactivated_at', 'activated_at')
|
27
|
-
def serialize_timestamps(self, value:Union[datetime, date], info:FieldSerializationInfo) -> str:
|
28
|
-
"""Serializes datetime/date fields to ISO format."""
|
29
|
-
return value.isoformat()
|
30
|
-
|
31
|
-
class Status(BaseModel):
|
32
|
-
status:BaseEnums.StatusType = Field(..., description="Data's status")
|
33
|
-
|
34
|
-
class Row(Status, Timestamps, Identifiers):
|
35
|
-
@field_validator('*', mode="before")
|
36
|
-
def set_none(cls, values):
|
37
|
-
if isinstance(values, str) and (values == "" or len(values) == 0):
|
38
|
-
return None
|
39
|
-
return values
|
40
|
-
|
41
|
-
@field_serializer('*')
|
42
|
-
def serialize_fields(self, value, info:FieldSerializationInfo) -> Any:
|
43
|
-
"""Serializes all unique-typed fields."""
|
44
|
-
if isinstance(value, UUID):
|
45
|
-
return str(value)
|
46
|
-
if isinstance(value, datetime) or isinstance(value, date):
|
47
|
-
return value.isoformat()
|
48
|
-
return value
|
49
|
-
|
50
|
-
class Config:
|
51
|
-
from_attributes=True
|
52
|
-
|
53
|
-
#* ----- ----- ----- Base ----- ----- ----- *#
|
54
6
|
class Base(BaseModel):
|
55
7
|
success:bool = Field(..., description="Success status")
|
56
8
|
code:Optional[str] = Field(None, description="Optional result code")
|
@@ -1,21 +1,47 @@
|
|
1
1
|
from __future__ import annotations
|
2
|
-
from
|
2
|
+
from datetime import datetime, date
|
3
|
+
from pydantic import FieldSerializationInfo, field_validator, field_serializer, model_validator
|
4
|
+
from uuid import UUID
|
5
|
+
from typing import Any
|
3
6
|
from maleo_foundation.models.schemas.general import BaseGeneralSchemas
|
4
7
|
from maleo_foundation.models.schemas.result import BaseResultSchemas
|
5
8
|
|
6
9
|
class BaseServiceQueryResultsTransfers:
|
10
|
+
class Row(
|
11
|
+
BaseGeneralSchemas.Status,
|
12
|
+
BaseGeneralSchemas.Timestamps,
|
13
|
+
BaseGeneralSchemas.Identifiers
|
14
|
+
):
|
15
|
+
@field_validator('*', mode="before")
|
16
|
+
def set_none(cls, values):
|
17
|
+
if isinstance(values, str) and (values == "" or len(values) == 0):
|
18
|
+
return None
|
19
|
+
return values
|
20
|
+
|
21
|
+
@field_serializer('*')
|
22
|
+
def serialize_fields(self, value, info:FieldSerializationInfo) -> Any:
|
23
|
+
"""Serializes all unique-typed fields."""
|
24
|
+
if isinstance(value, UUID):
|
25
|
+
return str(value)
|
26
|
+
if isinstance(value, datetime) or isinstance(value, date):
|
27
|
+
return value.isoformat()
|
28
|
+
return value
|
29
|
+
|
30
|
+
class Config:
|
31
|
+
from_attributes=True
|
32
|
+
|
7
33
|
class Fail(BaseResultSchemas.Fail): pass
|
8
34
|
|
9
35
|
class NoData(BaseResultSchemas.NoData): pass
|
10
36
|
|
11
37
|
class SingleData(BaseResultSchemas.SingleData):
|
12
|
-
data:
|
38
|
+
data:BaseServiceQueryResultsTransfers.Row
|
13
39
|
|
14
40
|
class UnpaginatedMultipleData(BaseResultSchemas.UnpaginatedMultipleData):
|
15
|
-
data:list[
|
41
|
+
data:list[BaseServiceQueryResultsTransfers.Row]
|
16
42
|
|
17
43
|
class PaginatedMultipleData(BaseResultSchemas.PaginatedMultipleData):
|
18
|
-
data:list[
|
44
|
+
data:list[BaseServiceQueryResultsTransfers.Row]
|
19
45
|
|
20
46
|
@model_validator(mode="before")
|
21
47
|
@classmethod
|
@@ -20,9 +20,9 @@ maleo_foundation/models/__init__.py,sha256=Wh92XAduE1Sg9qi2GMhptyXig0fKcTS5AbGo3
|
|
20
20
|
maleo_foundation/models/enums.py,sha256=Ob2v312JxypHEq7hTKZKOV462FEeLkIjIhpx-YF6Jdw,2203
|
21
21
|
maleo_foundation/models/responses.py,sha256=z2XEHwuxU05NDJSgrA7B7e2fzEQP6Kl3ZM2BO-lDw_A,3786
|
22
22
|
maleo_foundation/models/schemas/__init__.py,sha256=Xj8Ahsqyra-fmEaVcGPok5GOOsPQlKcknHYMvbjvENA,277
|
23
|
-
maleo_foundation/models/schemas/general.py,sha256
|
23
|
+
maleo_foundation/models/schemas/general.py,sha256=-SI19QtHvusbJnj5m5-Kua4jjHkYGoi3FWOJ9RUvobQ,6466
|
24
24
|
maleo_foundation/models/schemas/parameter.py,sha256=1og_crWds6YLS-8Ha5EbAi3ZaNMzNFiIZ06v_HO3b9k,875
|
25
|
-
maleo_foundation/models/schemas/result.py,sha256=
|
25
|
+
maleo_foundation/models/schemas/result.py,sha256=fzzq5mbJSwTXt6r-m9Yz9XNx36gGtroaj7dCCySKSFo,1870
|
26
26
|
maleo_foundation/models/transfers/__init__.py,sha256=B8oCZHE3NTsrJ_rviSXaDsuc-gc25jpjuhJO40lpQiE,222
|
27
27
|
maleo_foundation/models/transfers/parameters/__init__.py,sha256=oKW4RPIEISISRjsJzD8lsCGY1HhZRTzshPpWHcJu86k,353
|
28
28
|
maleo_foundation/models/transfers/parameters/client.py,sha256=oi9LzEIFAg1WVbsnmVegsn8kLDt6tJJbOZLrhfQjs64,2248
|
@@ -35,7 +35,7 @@ maleo_foundation/models/transfers/results/client/controllers/__init__.py,sha256=
|
|
35
35
|
maleo_foundation/models/transfers/results/client/controllers/http.py,sha256=vhjfjchvlTq347mLY2mcE84n_xYMpLkALi_ecQNOAGY,1499
|
36
36
|
maleo_foundation/models/transfers/results/service/__init__.py,sha256=dTjHe1iGIpdulrzawQoOj003sxxObumF63YpUptKrDA,390
|
37
37
|
maleo_foundation/models/transfers/results/service/general.py,sha256=G4x-MhQI7Km9UAcx2uJmrsqA6RBvxpH6VFAd_ynFFd4,1486
|
38
|
-
maleo_foundation/models/transfers/results/service/query.py,sha256=
|
38
|
+
maleo_foundation/models/transfers/results/service/query.py,sha256=Wj9GCWk7FrKP0EoK55vJcr9YJ42Lo24mLXbRk9j0IJw,2566
|
39
39
|
maleo_foundation/models/transfers/results/service/controllers/__init__.py,sha256=HZJWMy2dskzOCzLmp_UaL9rjbQ-sDMI7sd2bXb-4QOU,175
|
40
40
|
maleo_foundation/models/transfers/results/service/controllers/rest.py,sha256=bZ4NibT58aim6p3epFJ9ipR8Z54FkOuFx2GniK4CUfM,1114
|
41
41
|
maleo_foundation/models/types/__init__.py,sha256=0QYcK_1Ekj9W_o_ZVawkBS7Xc25A9j5KY2DRBKmljOI,247
|
@@ -47,7 +47,7 @@ maleo_foundation/utils/exceptions.py,sha256=mcvBwHm6uWpVQkPtO1T2j-GaTYEiyPOeGxiD
|
|
47
47
|
maleo_foundation/utils/logger.py,sha256=ICrFi0MxuAjDy8KTRL7pex1miwzZqZX-HHArgN3niJM,2453
|
48
48
|
maleo_foundation/utils/formatter/__init__.py,sha256=iKf5YCbEdg1qKnFHyKqqcQbqAqEeRUf8mhI3v3dQoj8,78
|
49
49
|
maleo_foundation/utils/formatter/case.py,sha256=TmvvlfzGdC_omMTB5vAa40TZBxQ3hnr-SYeo0M52Rlg,1352
|
50
|
-
maleo_foundation-0.0.
|
51
|
-
maleo_foundation-0.0.
|
52
|
-
maleo_foundation-0.0.
|
53
|
-
maleo_foundation-0.0.
|
50
|
+
maleo_foundation-0.0.8.dist-info/METADATA,sha256=dTfyf5-OfHvdgcFqkpXZs_kKmGRwOuec_myl18xQOa8,3159
|
51
|
+
maleo_foundation-0.0.8.dist-info/WHEEL,sha256=CmyFI0kx5cdEMTLiONQRbGQwjIoR1aIYB7eCAQ4KPJ0,91
|
52
|
+
maleo_foundation-0.0.8.dist-info/top_level.txt,sha256=_iBos3F_bhEOdjOnzeiEYSrCucasc810xXtLBXI8cQc,17
|
53
|
+
maleo_foundation-0.0.8.dist-info/RECORD,,
|
File without changes
|
File without changes
|