maleo-identity 0.0.91__py3-none-any.whl → 0.0.92__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 maleo-identity might be problematic. Click here for more details.
- maleo/identity/constants/organization.py +15 -8
- maleo/identity/constants/organization_registration_code.py +10 -7
- maleo/identity/constants/user.py +11 -13
- maleo/identity/constants/user_profile.py +9 -12
- maleo/identity/enums/organization.py +4 -4
- maleo/identity/enums/organization_registration_code.py +5 -0
- maleo/identity/enums/user.py +4 -8
- maleo/identity/enums/user_profile.py +4 -10
- maleo/identity/mixins/organization.py +10 -8
- maleo/identity/mixins/organization_registration_code.py +8 -11
- maleo/identity/mixins/user.py +17 -31
- maleo/identity/mixins/user_profile.py +37 -67
- maleo/identity/models.py +313 -0
- maleo/identity/schemas/common.py +257 -0
- maleo/identity/schemas/organization.py +162 -0
- maleo/identity/schemas/organization_registration_code.py +162 -0
- maleo/identity/schemas/user.py +181 -0
- maleo/identity/schemas/user_profile.py +212 -0
- maleo/identity/types/{base/organization_registration_code.py → user_profile.py} +2 -1
- maleo_identity-0.0.92.dist-info/METADATA +118 -0
- maleo_identity-0.0.92.dist-info/RECORD +33 -0
- maleo_identity-0.0.92.dist-info/licenses/LICENSE +57 -0
- maleo/identity/client/__init__.py +0 -0
- maleo/identity/client/manager.py +0 -157
- maleo/identity/client/services/__init__.py +0 -0
- maleo/identity/client/services/organization.py +0 -1944
- maleo/identity/client/services/organization_registration_code.py +0 -470
- maleo/identity/client/services/organization_role.py +0 -276
- maleo/identity/client/services/user.py +0 -1559
- maleo/identity/client/services/user_organization.py +0 -276
- maleo/identity/client/services/user_organization_role.py +0 -278
- maleo/identity/client/services/user_profile.py +0 -276
- maleo/identity/client/services/user_system_role.py +0 -276
- maleo/identity/constants/organization_role.py +0 -35
- maleo/identity/constants/user_organization.py +0 -58
- maleo/identity/constants/user_organization_role.py +0 -47
- maleo/identity/constants/user_system_role.py +0 -16
- maleo/identity/db.py +0 -4
- maleo/identity/dtos/__init__.py +0 -0
- maleo/identity/dtos/configuration.py +0 -15
- maleo/identity/dtos/data/__init__.py +0 -0
- maleo/identity/dtos/data/organization_registration_code.py +0 -15
- maleo/identity/dtos/data/user_profile.py +0 -33
- maleo/identity/dtos/data/user_system_role.py +0 -9
- maleo/identity/dtos/settings.py +0 -17
- maleo/identity/enums/general.py +0 -5
- maleo/identity/enums/organization_role.py +0 -7
- maleo/identity/enums/user_organization.py +0 -14
- maleo/identity/enums/user_organization_role.py +0 -15
- maleo/identity/enums/user_system_role.py +0 -5
- maleo/identity/mixins/organization_role.py +0 -15
- maleo/identity/mixins/user_organization.py +0 -6
- maleo/identity/mixins/user_organization_role.py +0 -6
- maleo/identity/mixins/user_system_role.py +0 -6
- maleo/identity/models/__init__.py +0 -0
- maleo/identity/models/organization.py +0 -62
- maleo/identity/models/organization_registration_code.py +0 -33
- maleo/identity/models/organization_role.py +0 -37
- maleo/identity/models/user.py +0 -39
- maleo/identity/models/user_organization.py +0 -48
- maleo/identity/models/user_organization_role.py +0 -61
- maleo/identity/models/user_profile.py +0 -33
- maleo/identity/models/user_system_role.py +0 -26
- maleo/identity/schemas/data/__init__.py +0 -0
- maleo/identity/schemas/data/organization.py +0 -36
- maleo/identity/schemas/data/organization_registration_code.py +0 -27
- maleo/identity/schemas/data/organization_role.py +0 -32
- maleo/identity/schemas/data/user.py +0 -33
- maleo/identity/schemas/data/user_organization.py +0 -23
- maleo/identity/schemas/data/user_organization_role.py +0 -13
- maleo/identity/schemas/data/user_profile.py +0 -59
- maleo/identity/schemas/data/user_system_role.py +0 -25
- maleo/identity/schemas/metadata/__init__.py +0 -0
- maleo/identity/schemas/metadata/user.py +0 -6
- maleo/identity/schemas/parameter/__init__.py +0 -0
- maleo/identity/schemas/parameter/client/__init__.py +0 -0
- maleo/identity/schemas/parameter/client/organization.py +0 -74
- maleo/identity/schemas/parameter/client/organization_registration_code.py +0 -24
- maleo/identity/schemas/parameter/client/organization_role.py +0 -42
- maleo/identity/schemas/parameter/client/user.py +0 -44
- maleo/identity/schemas/parameter/client/user_organization.py +0 -62
- maleo/identity/schemas/parameter/client/user_organization_role.py +0 -49
- maleo/identity/schemas/parameter/client/user_profile.py +0 -28
- maleo/identity/schemas/parameter/client/user_system_role.py +0 -43
- maleo/identity/schemas/parameter/general/__init__.py +0 -0
- maleo/identity/schemas/parameter/general/organization.py +0 -92
- maleo/identity/schemas/parameter/general/organization_registration_code.py +0 -86
- maleo/identity/schemas/parameter/general/organization_role.py +0 -14
- maleo/identity/schemas/parameter/general/user.py +0 -150
- maleo/identity/schemas/parameter/general/user_organization.py +0 -18
- maleo/identity/schemas/parameter/general/user_organization_role.py +0 -15
- maleo/identity/schemas/parameter/general/user_profile.py +0 -119
- maleo/identity/schemas/parameter/general/user_system_role.py +0 -30
- maleo/identity/schemas/parameter/service/__init__.py +0 -0
- maleo/identity/schemas/parameter/service/organization.py +0 -60
- maleo/identity/schemas/parameter/service/organization_registration_code.py +0 -24
- maleo/identity/schemas/parameter/service/organization_role.py +0 -35
- maleo/identity/schemas/parameter/service/user.py +0 -47
- maleo/identity/schemas/parameter/service/user_organization_role.py +0 -36
- maleo/identity/schemas/parameter/service/user_profile.py +0 -28
- maleo/identity/schemas/parameter/service/user_system_role.py +0 -31
- maleo/identity/types/base/__init__.py +0 -0
- maleo_identity-0.0.91.dist-info/METADATA +0 -39
- maleo_identity-0.0.91.dist-info/RECORD +0 -106
- /maleo/identity/types/{base/organization.py → organization.py} +0 -0
- /maleo/identity/types/{base/user.py → organization_registration_code.py} +0 -0
- /maleo/identity/types/{base/user_profile.py → user.py} +0 -0
- {maleo_identity-0.0.91.dist-info → maleo_identity-0.0.92.dist-info}/WHEEL +0 -0
- {maleo_identity-0.0.91.dist-info → maleo_identity-0.0.92.dist-info}/top_level.txt +0 -0
|
@@ -0,0 +1,162 @@
|
|
|
1
|
+
from pydantic import BaseModel, Field
|
|
2
|
+
from typing import Generic, Literal, TypeVar, overload
|
|
3
|
+
from uuid import UUID
|
|
4
|
+
from maleo.enums.organization import (
|
|
5
|
+
OrganizationType,
|
|
6
|
+
OptOrganizationType,
|
|
7
|
+
FullOrganizationTypeMixin,
|
|
8
|
+
OptListOfOrganizationTypes,
|
|
9
|
+
FullOrganizationTypesMixin,
|
|
10
|
+
)
|
|
11
|
+
from maleo.enums.status import (
|
|
12
|
+
ListOfDataStatuses,
|
|
13
|
+
FULL_DATA_STATUSES,
|
|
14
|
+
)
|
|
15
|
+
from maleo.schemas.mixins.filter import convert as convert_filter
|
|
16
|
+
from maleo.schemas.mixins.identity import (
|
|
17
|
+
IdentifierTypeValue,
|
|
18
|
+
Ids,
|
|
19
|
+
UUIDs,
|
|
20
|
+
Keys,
|
|
21
|
+
Names,
|
|
22
|
+
)
|
|
23
|
+
from maleo.schemas.mixins.sort import convert as convert_sort
|
|
24
|
+
from maleo.schemas.parameter import (
|
|
25
|
+
ReadSingleParameter as BaseReadSingleParameter,
|
|
26
|
+
ReadPaginatedMultipleParameter,
|
|
27
|
+
StatusUpdateParameter as BaseStatusUpdateParameter,
|
|
28
|
+
DeleteSingleParameter as BaseDeleteSingleParameter,
|
|
29
|
+
)
|
|
30
|
+
from maleo.types.dict import StrToAnyDict
|
|
31
|
+
from maleo.types.integer import OptListOfInts
|
|
32
|
+
from maleo.types.string import OptStr, OptListOfStrs
|
|
33
|
+
from maleo.types.uuid import OptListOfUUIDs
|
|
34
|
+
from ..enums.organization import IdentifierType
|
|
35
|
+
from ..mixins.organization import Key, Name
|
|
36
|
+
from ..types.organization import IdentifierValueType
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
class CreateParameter(Name[str], Key[str], FullOrganizationTypeMixin[OrganizationType]):
|
|
40
|
+
pass
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
class ReadMultipleParameter(
|
|
44
|
+
ReadPaginatedMultipleParameter,
|
|
45
|
+
Names[OptListOfStrs],
|
|
46
|
+
Keys[OptListOfStrs],
|
|
47
|
+
FullOrganizationTypesMixin[OptListOfOrganizationTypes],
|
|
48
|
+
UUIDs[OptListOfUUIDs],
|
|
49
|
+
Ids[OptListOfInts],
|
|
50
|
+
):
|
|
51
|
+
@property
|
|
52
|
+
def _query_param_fields(self) -> set[str]:
|
|
53
|
+
return {
|
|
54
|
+
"ids",
|
|
55
|
+
"uuids",
|
|
56
|
+
"statuses",
|
|
57
|
+
"organization_types",
|
|
58
|
+
"keys",
|
|
59
|
+
"names",
|
|
60
|
+
"search",
|
|
61
|
+
"page",
|
|
62
|
+
"limit",
|
|
63
|
+
"use_cache",
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
def to_query_params(self) -> StrToAnyDict:
|
|
67
|
+
params = self.model_dump(
|
|
68
|
+
mode="json", include=self._query_param_fields, exclude_none=True
|
|
69
|
+
)
|
|
70
|
+
params["filters"] = convert_filter(self.date_filters)
|
|
71
|
+
params["sorts"] = convert_sort(self.sort_columns)
|
|
72
|
+
params = {k: v for k, v in params.items()}
|
|
73
|
+
return params
|
|
74
|
+
|
|
75
|
+
|
|
76
|
+
class ReadSingleParameter(BaseReadSingleParameter[IdentifierType, IdentifierValueType]):
|
|
77
|
+
@overload
|
|
78
|
+
@classmethod
|
|
79
|
+
def new(
|
|
80
|
+
cls,
|
|
81
|
+
identifier_type: Literal[IdentifierType.ID],
|
|
82
|
+
identifier_value: int,
|
|
83
|
+
statuses: ListOfDataStatuses = list(FULL_DATA_STATUSES),
|
|
84
|
+
use_cache: bool = True,
|
|
85
|
+
) -> "ReadSingleParameter": ...
|
|
86
|
+
@overload
|
|
87
|
+
@classmethod
|
|
88
|
+
def new(
|
|
89
|
+
cls,
|
|
90
|
+
identifier_type: Literal[IdentifierType.UUID],
|
|
91
|
+
identifier_value: UUID,
|
|
92
|
+
statuses: ListOfDataStatuses = list(FULL_DATA_STATUSES),
|
|
93
|
+
use_cache: bool = True,
|
|
94
|
+
) -> "ReadSingleParameter": ...
|
|
95
|
+
@overload
|
|
96
|
+
@classmethod
|
|
97
|
+
def new(
|
|
98
|
+
cls,
|
|
99
|
+
identifier_type: Literal[IdentifierType.KEY],
|
|
100
|
+
identifier_value: str,
|
|
101
|
+
statuses: ListOfDataStatuses = list(FULL_DATA_STATUSES),
|
|
102
|
+
use_cache: bool = True,
|
|
103
|
+
) -> "ReadSingleParameter": ...
|
|
104
|
+
@classmethod
|
|
105
|
+
def new(
|
|
106
|
+
cls,
|
|
107
|
+
identifier_type: IdentifierType,
|
|
108
|
+
identifier_value: IdentifierValueType,
|
|
109
|
+
statuses: ListOfDataStatuses = list(FULL_DATA_STATUSES),
|
|
110
|
+
use_cache: bool = True,
|
|
111
|
+
) -> "ReadSingleParameter":
|
|
112
|
+
return cls(
|
|
113
|
+
identifier_type=identifier_type,
|
|
114
|
+
identifier_value=identifier_value,
|
|
115
|
+
statuses=statuses,
|
|
116
|
+
use_cache=use_cache,
|
|
117
|
+
)
|
|
118
|
+
|
|
119
|
+
def to_query_params(self) -> StrToAnyDict:
|
|
120
|
+
return self.model_dump(
|
|
121
|
+
mode="json", include={"statuses", "use_cache"}, exclude_none=True
|
|
122
|
+
)
|
|
123
|
+
|
|
124
|
+
|
|
125
|
+
class FullUpdateData(Name[str], Key[str], FullOrganizationTypeMixin[OrganizationType]):
|
|
126
|
+
pass
|
|
127
|
+
|
|
128
|
+
|
|
129
|
+
class PartialUpdateData(
|
|
130
|
+
Name[OptStr], Key[OptStr], FullOrganizationTypeMixin[OptOrganizationType]
|
|
131
|
+
):
|
|
132
|
+
pass
|
|
133
|
+
|
|
134
|
+
|
|
135
|
+
UpdateDataT = TypeVar("UpdateDataT", FullUpdateData, PartialUpdateData)
|
|
136
|
+
|
|
137
|
+
|
|
138
|
+
class UpdateDataMixin(BaseModel, Generic[UpdateDataT]):
|
|
139
|
+
data: UpdateDataT = Field(..., description="Update data")
|
|
140
|
+
|
|
141
|
+
|
|
142
|
+
class UpdateParameter(
|
|
143
|
+
UpdateDataMixin[UpdateDataT],
|
|
144
|
+
IdentifierTypeValue[
|
|
145
|
+
IdentifierType,
|
|
146
|
+
IdentifierValueType,
|
|
147
|
+
],
|
|
148
|
+
Generic[UpdateDataT],
|
|
149
|
+
):
|
|
150
|
+
pass
|
|
151
|
+
|
|
152
|
+
|
|
153
|
+
class StatusUpdateParameter(
|
|
154
|
+
BaseStatusUpdateParameter[IdentifierType, IdentifierValueType],
|
|
155
|
+
):
|
|
156
|
+
pass
|
|
157
|
+
|
|
158
|
+
|
|
159
|
+
class DeleteSingleParameter(
|
|
160
|
+
BaseDeleteSingleParameter[IdentifierType, IdentifierValueType]
|
|
161
|
+
):
|
|
162
|
+
pass
|
|
@@ -0,0 +1,162 @@
|
|
|
1
|
+
from pydantic import BaseModel, Field
|
|
2
|
+
from typing import Generic, Literal, TypeVar, overload
|
|
3
|
+
from uuid import UUID
|
|
4
|
+
from maleo.enums.status import (
|
|
5
|
+
ListOfDataStatuses,
|
|
6
|
+
FULL_DATA_STATUSES,
|
|
7
|
+
)
|
|
8
|
+
from maleo.schemas.mixins.filter import convert as convert_filter
|
|
9
|
+
from maleo.schemas.mixins.general import Codes
|
|
10
|
+
from maleo.schemas.mixins.identity import (
|
|
11
|
+
IdentifierTypeValue,
|
|
12
|
+
Ids,
|
|
13
|
+
IntOrganizationId,
|
|
14
|
+
UUIDs,
|
|
15
|
+
UUIDOrganizationIds,
|
|
16
|
+
)
|
|
17
|
+
from maleo.schemas.mixins.sort import convert as convert_sort
|
|
18
|
+
from maleo.schemas.parameter import (
|
|
19
|
+
ReadSingleParameter as BaseReadSingleParameter,
|
|
20
|
+
ReadPaginatedMultipleParameter,
|
|
21
|
+
StatusUpdateParameter as BaseStatusUpdateParameter,
|
|
22
|
+
DeleteSingleParameter as BaseDeleteSingleParameter,
|
|
23
|
+
)
|
|
24
|
+
from maleo.types.dict import StrToAnyDict
|
|
25
|
+
from maleo.types.integer import OptInt, OptListOfInts
|
|
26
|
+
from maleo.types.string import OptStr, OptListOfStrs
|
|
27
|
+
from maleo.types.uuid import OptListOfUUIDs
|
|
28
|
+
from ..enums.organization_registration_code import IdentifierType
|
|
29
|
+
from ..mixins.organization_registration_code import Code, MaxUses
|
|
30
|
+
from ..types.organization_registration_code import IdentifierValueType
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
class BaseCreateParameter(
|
|
34
|
+
MaxUses[int],
|
|
35
|
+
Code[OptStr],
|
|
36
|
+
):
|
|
37
|
+
pass
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
class CreateParameter(
|
|
41
|
+
BaseCreateParameter,
|
|
42
|
+
IntOrganizationId[int],
|
|
43
|
+
):
|
|
44
|
+
pass
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
class ReadMultipleParameter(
|
|
48
|
+
ReadPaginatedMultipleParameter,
|
|
49
|
+
Codes[OptListOfStrs],
|
|
50
|
+
UUIDOrganizationIds[OptListOfUUIDs],
|
|
51
|
+
UUIDs[OptListOfUUIDs],
|
|
52
|
+
Ids[OptListOfInts],
|
|
53
|
+
):
|
|
54
|
+
@property
|
|
55
|
+
def _query_param_fields(self) -> set[str]:
|
|
56
|
+
return {
|
|
57
|
+
"ids",
|
|
58
|
+
"uuids",
|
|
59
|
+
"statuses",
|
|
60
|
+
"organization_ids",
|
|
61
|
+
"codes",
|
|
62
|
+
"search",
|
|
63
|
+
"page",
|
|
64
|
+
"limit",
|
|
65
|
+
"use_cache",
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
def to_query_params(self) -> StrToAnyDict:
|
|
69
|
+
params = self.model_dump(
|
|
70
|
+
mode="json", include=self._query_param_fields, exclude_none=True
|
|
71
|
+
)
|
|
72
|
+
params["filters"] = convert_filter(self.date_filters)
|
|
73
|
+
params["sorts"] = convert_sort(self.sort_columns)
|
|
74
|
+
params = {k: v for k, v in params.items()}
|
|
75
|
+
return params
|
|
76
|
+
|
|
77
|
+
|
|
78
|
+
class ReadSingleParameter(BaseReadSingleParameter[IdentifierType, IdentifierValueType]):
|
|
79
|
+
@overload
|
|
80
|
+
@classmethod
|
|
81
|
+
def new(
|
|
82
|
+
cls,
|
|
83
|
+
identifier_type: Literal[IdentifierType.ID, IdentifierType.ORGANIZATION_ID],
|
|
84
|
+
identifier_value: int,
|
|
85
|
+
statuses: ListOfDataStatuses = list(FULL_DATA_STATUSES),
|
|
86
|
+
use_cache: bool = True,
|
|
87
|
+
) -> "ReadSingleParameter": ...
|
|
88
|
+
@overload
|
|
89
|
+
@classmethod
|
|
90
|
+
def new(
|
|
91
|
+
cls,
|
|
92
|
+
identifier_type: Literal[IdentifierType.UUID],
|
|
93
|
+
identifier_value: UUID,
|
|
94
|
+
statuses: ListOfDataStatuses = list(FULL_DATA_STATUSES),
|
|
95
|
+
use_cache: bool = True,
|
|
96
|
+
) -> "ReadSingleParameter": ...
|
|
97
|
+
@overload
|
|
98
|
+
@classmethod
|
|
99
|
+
def new(
|
|
100
|
+
cls,
|
|
101
|
+
identifier_type: Literal[IdentifierType.CODE],
|
|
102
|
+
identifier_value: str,
|
|
103
|
+
statuses: ListOfDataStatuses = list(FULL_DATA_STATUSES),
|
|
104
|
+
use_cache: bool = True,
|
|
105
|
+
) -> "ReadSingleParameter": ...
|
|
106
|
+
@classmethod
|
|
107
|
+
def new(
|
|
108
|
+
cls,
|
|
109
|
+
identifier_type: IdentifierType,
|
|
110
|
+
identifier_value: IdentifierValueType,
|
|
111
|
+
statuses: ListOfDataStatuses = list(FULL_DATA_STATUSES),
|
|
112
|
+
use_cache: bool = True,
|
|
113
|
+
) -> "ReadSingleParameter":
|
|
114
|
+
return cls(
|
|
115
|
+
identifier_type=identifier_type,
|
|
116
|
+
identifier_value=identifier_value,
|
|
117
|
+
statuses=statuses,
|
|
118
|
+
use_cache=use_cache,
|
|
119
|
+
)
|
|
120
|
+
|
|
121
|
+
def to_query_params(self) -> StrToAnyDict:
|
|
122
|
+
return self.model_dump(
|
|
123
|
+
mode="json", include={"statuses", "use_cache"}, exclude_none=True
|
|
124
|
+
)
|
|
125
|
+
|
|
126
|
+
|
|
127
|
+
class FullUpdateData(MaxUses[int], Code[str]):
|
|
128
|
+
pass
|
|
129
|
+
|
|
130
|
+
|
|
131
|
+
class PartialUpdateData(MaxUses[OptInt], Code[OptStr]):
|
|
132
|
+
pass
|
|
133
|
+
|
|
134
|
+
|
|
135
|
+
UpdateDataT = TypeVar("UpdateDataT", FullUpdateData, PartialUpdateData)
|
|
136
|
+
|
|
137
|
+
|
|
138
|
+
class UpdateDataMixin(BaseModel, Generic[UpdateDataT]):
|
|
139
|
+
data: UpdateDataT = Field(..., description="Update data")
|
|
140
|
+
|
|
141
|
+
|
|
142
|
+
class UpdateParameter(
|
|
143
|
+
UpdateDataMixin[UpdateDataT],
|
|
144
|
+
IdentifierTypeValue[
|
|
145
|
+
IdentifierType,
|
|
146
|
+
IdentifierValueType,
|
|
147
|
+
],
|
|
148
|
+
Generic[UpdateDataT],
|
|
149
|
+
):
|
|
150
|
+
pass
|
|
151
|
+
|
|
152
|
+
|
|
153
|
+
class StatusUpdateParameter(
|
|
154
|
+
BaseStatusUpdateParameter[IdentifierType, IdentifierValueType],
|
|
155
|
+
):
|
|
156
|
+
pass
|
|
157
|
+
|
|
158
|
+
|
|
159
|
+
class DeleteSingleParameter(
|
|
160
|
+
BaseDeleteSingleParameter[IdentifierType, IdentifierValueType]
|
|
161
|
+
):
|
|
162
|
+
pass
|
|
@@ -0,0 +1,181 @@
|
|
|
1
|
+
from pydantic import BaseModel, Field
|
|
2
|
+
from typing import Annotated, Generic, Literal, TypeVar, overload
|
|
3
|
+
from uuid import UUID
|
|
4
|
+
from maleo.enums.status import (
|
|
5
|
+
ListOfDataStatuses,
|
|
6
|
+
FULL_DATA_STATUSES,
|
|
7
|
+
)
|
|
8
|
+
from maleo.enums.user import (
|
|
9
|
+
UserType,
|
|
10
|
+
OptUserType,
|
|
11
|
+
FullUserTypeMixin,
|
|
12
|
+
OptListOfUserTypes,
|
|
13
|
+
FullUserTypesMixin,
|
|
14
|
+
)
|
|
15
|
+
from maleo.schemas.mixins.filter import convert as convert_filter
|
|
16
|
+
from maleo.schemas.mixins.identity import (
|
|
17
|
+
IdentifierTypeValue,
|
|
18
|
+
Ids,
|
|
19
|
+
UUIDs,
|
|
20
|
+
)
|
|
21
|
+
from maleo.schemas.mixins.sort import convert as convert_sort
|
|
22
|
+
from maleo.schemas.parameter import (
|
|
23
|
+
ReadSingleParameter as BaseReadSingleParameter,
|
|
24
|
+
ReadPaginatedMultipleParameter,
|
|
25
|
+
StatusUpdateParameter as BaseStatusUpdateParameter,
|
|
26
|
+
DeleteSingleParameter as BaseDeleteSingleParameter,
|
|
27
|
+
)
|
|
28
|
+
from maleo.types.dict import StrToAnyDict
|
|
29
|
+
from maleo.types.integer import OptListOfInts
|
|
30
|
+
from maleo.types.string import OptStr, OptListOfStrs
|
|
31
|
+
from maleo.types.uuid import OptListOfUUIDs
|
|
32
|
+
from ..enums.user import IdentifierType
|
|
33
|
+
from ..mixins.user import (
|
|
34
|
+
Username,
|
|
35
|
+
Usernames,
|
|
36
|
+
Email,
|
|
37
|
+
Emails,
|
|
38
|
+
Phone,
|
|
39
|
+
Phones,
|
|
40
|
+
)
|
|
41
|
+
from ..types.user import IdentifierValueType
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
class CreateParameter(
|
|
45
|
+
Phone[str], Email[str], Username[str], FullUserTypeMixin[UserType]
|
|
46
|
+
):
|
|
47
|
+
pass
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
class ReadMultipleParameter(
|
|
51
|
+
ReadPaginatedMultipleParameter,
|
|
52
|
+
Phones[OptListOfStrs],
|
|
53
|
+
Emails[OptListOfStrs],
|
|
54
|
+
Usernames[OptListOfStrs],
|
|
55
|
+
FullUserTypesMixin[OptListOfUserTypes],
|
|
56
|
+
UUIDs[OptListOfUUIDs],
|
|
57
|
+
Ids[OptListOfInts],
|
|
58
|
+
):
|
|
59
|
+
@property
|
|
60
|
+
def _query_param_fields(self) -> set[str]:
|
|
61
|
+
return {
|
|
62
|
+
"ids",
|
|
63
|
+
"uuids",
|
|
64
|
+
"statuses",
|
|
65
|
+
"user_types",
|
|
66
|
+
"usernames",
|
|
67
|
+
"emails",
|
|
68
|
+
"phones",
|
|
69
|
+
"search",
|
|
70
|
+
"page",
|
|
71
|
+
"limit",
|
|
72
|
+
"use_cache",
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
def to_query_params(self) -> StrToAnyDict:
|
|
76
|
+
params = self.model_dump(
|
|
77
|
+
mode="json", include=self._query_param_fields, exclude_none=True
|
|
78
|
+
)
|
|
79
|
+
params["filters"] = convert_filter(self.date_filters)
|
|
80
|
+
params["sorts"] = convert_sort(self.sort_columns)
|
|
81
|
+
params = {k: v for k, v in params.items()}
|
|
82
|
+
return params
|
|
83
|
+
|
|
84
|
+
|
|
85
|
+
class ReadSingleParameter(BaseReadSingleParameter[IdentifierType, IdentifierValueType]):
|
|
86
|
+
@overload
|
|
87
|
+
@classmethod
|
|
88
|
+
def new(
|
|
89
|
+
cls,
|
|
90
|
+
identifier_type: Literal[IdentifierType.ID],
|
|
91
|
+
identifier_value: int,
|
|
92
|
+
statuses: ListOfDataStatuses = list(FULL_DATA_STATUSES),
|
|
93
|
+
use_cache: bool = True,
|
|
94
|
+
) -> "ReadSingleParameter": ...
|
|
95
|
+
@overload
|
|
96
|
+
@classmethod
|
|
97
|
+
def new(
|
|
98
|
+
cls,
|
|
99
|
+
identifier_type: Literal[IdentifierType.UUID],
|
|
100
|
+
identifier_value: UUID,
|
|
101
|
+
statuses: ListOfDataStatuses = list(FULL_DATA_STATUSES),
|
|
102
|
+
use_cache: bool = True,
|
|
103
|
+
) -> "ReadSingleParameter": ...
|
|
104
|
+
@overload
|
|
105
|
+
@classmethod
|
|
106
|
+
def new(
|
|
107
|
+
cls,
|
|
108
|
+
identifier_type: Literal[IdentifierType.USERNAME, IdentifierType.EMAIL],
|
|
109
|
+
identifier_value: str,
|
|
110
|
+
statuses: ListOfDataStatuses = list(FULL_DATA_STATUSES),
|
|
111
|
+
use_cache: bool = True,
|
|
112
|
+
) -> "ReadSingleParameter": ...
|
|
113
|
+
@classmethod
|
|
114
|
+
def new(
|
|
115
|
+
cls,
|
|
116
|
+
identifier_type: IdentifierType,
|
|
117
|
+
identifier_value: IdentifierValueType,
|
|
118
|
+
statuses: ListOfDataStatuses = list(FULL_DATA_STATUSES),
|
|
119
|
+
use_cache: bool = True,
|
|
120
|
+
) -> "ReadSingleParameter":
|
|
121
|
+
return cls(
|
|
122
|
+
identifier_type=identifier_type,
|
|
123
|
+
identifier_value=identifier_value,
|
|
124
|
+
statuses=statuses,
|
|
125
|
+
use_cache=use_cache,
|
|
126
|
+
)
|
|
127
|
+
|
|
128
|
+
def to_query_params(self) -> StrToAnyDict:
|
|
129
|
+
return self.model_dump(
|
|
130
|
+
mode="json", include={"statuses", "use_cache"}, exclude_none=True
|
|
131
|
+
)
|
|
132
|
+
|
|
133
|
+
|
|
134
|
+
class ChangePasswordData(BaseModel):
|
|
135
|
+
old: Annotated[str, Field(..., description="Old Password", max_length=255)]
|
|
136
|
+
old_confirmation: Annotated[
|
|
137
|
+
str, Field(..., description="Old Password Confirmation", max_length=255)
|
|
138
|
+
]
|
|
139
|
+
new: Annotated[str, Field(..., description="New Password", max_length=255)]
|
|
140
|
+
|
|
141
|
+
|
|
142
|
+
class FullUpdateData(
|
|
143
|
+
Phone[str], Email[str], Username[str], FullUserTypeMixin[UserType]
|
|
144
|
+
):
|
|
145
|
+
pass
|
|
146
|
+
|
|
147
|
+
|
|
148
|
+
class PartialUpdateData(
|
|
149
|
+
Phone[OptStr], Email[OptStr], Username[OptStr], FullUserTypeMixin[OptUserType]
|
|
150
|
+
):
|
|
151
|
+
pass
|
|
152
|
+
|
|
153
|
+
|
|
154
|
+
UpdateDataT = TypeVar("UpdateDataT", FullUpdateData, PartialUpdateData)
|
|
155
|
+
|
|
156
|
+
|
|
157
|
+
class UpdateDataMixin(BaseModel, Generic[UpdateDataT]):
|
|
158
|
+
data: UpdateDataT = Field(..., description="Update data")
|
|
159
|
+
|
|
160
|
+
|
|
161
|
+
class UpdateParameter(
|
|
162
|
+
UpdateDataMixin[UpdateDataT],
|
|
163
|
+
IdentifierTypeValue[
|
|
164
|
+
IdentifierType,
|
|
165
|
+
IdentifierValueType,
|
|
166
|
+
],
|
|
167
|
+
Generic[UpdateDataT],
|
|
168
|
+
):
|
|
169
|
+
pass
|
|
170
|
+
|
|
171
|
+
|
|
172
|
+
class StatusUpdateParameter(
|
|
173
|
+
BaseStatusUpdateParameter[IdentifierType, IdentifierValueType],
|
|
174
|
+
):
|
|
175
|
+
pass
|
|
176
|
+
|
|
177
|
+
|
|
178
|
+
class DeleteSingleParameter(
|
|
179
|
+
BaseDeleteSingleParameter[IdentifierType, IdentifierValueType]
|
|
180
|
+
):
|
|
181
|
+
pass
|
|
@@ -0,0 +1,212 @@
|
|
|
1
|
+
from pydantic import BaseModel, Field
|
|
2
|
+
from typing import Generic, Literal, TypeVar, overload
|
|
3
|
+
from uuid import UUID
|
|
4
|
+
from maleo.enums.identity import OptBloodType, BloodTypeMixin, OptGender, GenderMixin
|
|
5
|
+
from maleo.enums.status import (
|
|
6
|
+
ListOfDataStatuses,
|
|
7
|
+
FULL_DATA_STATUSES,
|
|
8
|
+
)
|
|
9
|
+
from maleo.schemas.mixins.filter import convert as convert_filter
|
|
10
|
+
from maleo.schemas.mixins.identity import IdentifierTypeValue, Ids, UUIDs, IntUserId
|
|
11
|
+
from maleo.schemas.mixins.sort import convert as convert_sort
|
|
12
|
+
from maleo.schemas.parameter import (
|
|
13
|
+
ReadSingleParameter as BaseReadSingleParameter,
|
|
14
|
+
ReadPaginatedMultipleParameter,
|
|
15
|
+
StatusUpdateParameter as BaseStatusUpdateParameter,
|
|
16
|
+
DeleteSingleParameter as BaseDeleteSingleParameter,
|
|
17
|
+
)
|
|
18
|
+
from maleo.types.datetime import OptDate
|
|
19
|
+
from maleo.types.dict import StrToAnyDict
|
|
20
|
+
from maleo.types.integer import OptListOfInts
|
|
21
|
+
from maleo.types.string import OptStr
|
|
22
|
+
from maleo.types.uuid import OptListOfUUIDs
|
|
23
|
+
from ..enums.user_profile import IdentifierType
|
|
24
|
+
from ..mixins.user_profile import (
|
|
25
|
+
IdCard,
|
|
26
|
+
LeadingTitle,
|
|
27
|
+
FirstName,
|
|
28
|
+
MiddleName,
|
|
29
|
+
LastName,
|
|
30
|
+
EndingTitle,
|
|
31
|
+
FullName,
|
|
32
|
+
BirthPlace,
|
|
33
|
+
BirthDate,
|
|
34
|
+
AvatarName,
|
|
35
|
+
)
|
|
36
|
+
from ..types.user_profile import IdentifierValueType
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
class CoreCreateData(
|
|
40
|
+
BloodTypeMixin[OptBloodType],
|
|
41
|
+
GenderMixin[OptGender],
|
|
42
|
+
BirthDate[OptDate],
|
|
43
|
+
BirthPlace[OptStr],
|
|
44
|
+
FullName[str],
|
|
45
|
+
EndingTitle[OptStr],
|
|
46
|
+
LastName[str],
|
|
47
|
+
MiddleName[OptStr],
|
|
48
|
+
FirstName[str],
|
|
49
|
+
LeadingTitle[OptStr],
|
|
50
|
+
IdCard[OptStr],
|
|
51
|
+
):
|
|
52
|
+
pass
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
class EssentialData(
|
|
56
|
+
AvatarName[str],
|
|
57
|
+
BloodTypeMixin[OptBloodType],
|
|
58
|
+
GenderMixin[OptGender],
|
|
59
|
+
BirthDate[OptDate],
|
|
60
|
+
BirthPlace[OptStr],
|
|
61
|
+
FullName[str],
|
|
62
|
+
EndingTitle[OptStr],
|
|
63
|
+
LastName[str],
|
|
64
|
+
MiddleName[OptStr],
|
|
65
|
+
FirstName[str],
|
|
66
|
+
LeadingTitle[OptStr],
|
|
67
|
+
IdCard[OptStr],
|
|
68
|
+
):
|
|
69
|
+
pass
|
|
70
|
+
|
|
71
|
+
|
|
72
|
+
class InsertData(
|
|
73
|
+
EssentialData,
|
|
74
|
+
IntUserId[int],
|
|
75
|
+
):
|
|
76
|
+
pass
|
|
77
|
+
|
|
78
|
+
|
|
79
|
+
class ReadMultipleParameter(
|
|
80
|
+
ReadPaginatedMultipleParameter,
|
|
81
|
+
UUIDs[OptListOfUUIDs],
|
|
82
|
+
Ids[OptListOfInts],
|
|
83
|
+
):
|
|
84
|
+
@property
|
|
85
|
+
def _query_param_fields(self) -> set[str]:
|
|
86
|
+
return {
|
|
87
|
+
"ids",
|
|
88
|
+
"uuids",
|
|
89
|
+
"statuses",
|
|
90
|
+
"search",
|
|
91
|
+
"page",
|
|
92
|
+
"limit",
|
|
93
|
+
"use_cache",
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
def to_query_params(self) -> StrToAnyDict:
|
|
97
|
+
params = self.model_dump(
|
|
98
|
+
mode="json", include=self._query_param_fields, exclude_none=True
|
|
99
|
+
)
|
|
100
|
+
params["filters"] = convert_filter(self.date_filters)
|
|
101
|
+
params["sorts"] = convert_sort(self.sort_columns)
|
|
102
|
+
params = {k: v for k, v in params.items()}
|
|
103
|
+
return params
|
|
104
|
+
|
|
105
|
+
|
|
106
|
+
class ReadSingleParameter(BaseReadSingleParameter[IdentifierType, IdentifierValueType]):
|
|
107
|
+
@overload
|
|
108
|
+
@classmethod
|
|
109
|
+
def new(
|
|
110
|
+
cls,
|
|
111
|
+
identifier_type: Literal[IdentifierType.ID, IdentifierType.USER_ID],
|
|
112
|
+
identifier_value: int,
|
|
113
|
+
statuses: ListOfDataStatuses = list(FULL_DATA_STATUSES),
|
|
114
|
+
use_cache: bool = True,
|
|
115
|
+
) -> "ReadSingleParameter": ...
|
|
116
|
+
@overload
|
|
117
|
+
@classmethod
|
|
118
|
+
def new(
|
|
119
|
+
cls,
|
|
120
|
+
identifier_type: Literal[IdentifierType.UUID],
|
|
121
|
+
identifier_value: UUID,
|
|
122
|
+
statuses: ListOfDataStatuses = list(FULL_DATA_STATUSES),
|
|
123
|
+
use_cache: bool = True,
|
|
124
|
+
) -> "ReadSingleParameter": ...
|
|
125
|
+
@overload
|
|
126
|
+
@classmethod
|
|
127
|
+
def new(
|
|
128
|
+
cls,
|
|
129
|
+
identifier_type: Literal[IdentifierType.ID_CARD],
|
|
130
|
+
identifier_value: str,
|
|
131
|
+
statuses: ListOfDataStatuses = list(FULL_DATA_STATUSES),
|
|
132
|
+
use_cache: bool = True,
|
|
133
|
+
) -> "ReadSingleParameter": ...
|
|
134
|
+
@classmethod
|
|
135
|
+
def new(
|
|
136
|
+
cls,
|
|
137
|
+
identifier_type: IdentifierType,
|
|
138
|
+
identifier_value: IdentifierValueType,
|
|
139
|
+
statuses: ListOfDataStatuses = list(FULL_DATA_STATUSES),
|
|
140
|
+
use_cache: bool = True,
|
|
141
|
+
) -> "ReadSingleParameter":
|
|
142
|
+
return cls(
|
|
143
|
+
identifier_type=identifier_type,
|
|
144
|
+
identifier_value=identifier_value,
|
|
145
|
+
statuses=statuses,
|
|
146
|
+
use_cache=use_cache,
|
|
147
|
+
)
|
|
148
|
+
|
|
149
|
+
def to_query_params(self) -> StrToAnyDict:
|
|
150
|
+
return self.model_dump(
|
|
151
|
+
mode="json", include={"statuses", "use_cache"}, exclude_none=True
|
|
152
|
+
)
|
|
153
|
+
|
|
154
|
+
|
|
155
|
+
class FullUpdateData(
|
|
156
|
+
BloodTypeMixin[OptBloodType],
|
|
157
|
+
GenderMixin[OptGender],
|
|
158
|
+
BirthDate[OptDate],
|
|
159
|
+
BirthPlace[OptStr],
|
|
160
|
+
EndingTitle[OptStr],
|
|
161
|
+
LastName[str],
|
|
162
|
+
MiddleName[OptStr],
|
|
163
|
+
FirstName[str],
|
|
164
|
+
LeadingTitle[OptStr],
|
|
165
|
+
IdCard[OptStr],
|
|
166
|
+
):
|
|
167
|
+
pass
|
|
168
|
+
|
|
169
|
+
|
|
170
|
+
class PartialUpdateData(
|
|
171
|
+
BloodTypeMixin[OptBloodType],
|
|
172
|
+
GenderMixin[OptGender],
|
|
173
|
+
BirthDate[OptDate],
|
|
174
|
+
BirthPlace[OptStr],
|
|
175
|
+
EndingTitle[OptStr],
|
|
176
|
+
LastName[OptStr],
|
|
177
|
+
MiddleName[OptStr],
|
|
178
|
+
FirstName[OptStr],
|
|
179
|
+
LeadingTitle[OptStr],
|
|
180
|
+
IdCard[OptStr],
|
|
181
|
+
):
|
|
182
|
+
pass
|
|
183
|
+
|
|
184
|
+
|
|
185
|
+
UpdateDataT = TypeVar("UpdateDataT", FullUpdateData, PartialUpdateData)
|
|
186
|
+
|
|
187
|
+
|
|
188
|
+
class UpdateDataMixin(BaseModel, Generic[UpdateDataT]):
|
|
189
|
+
data: UpdateDataT = Field(..., description="Update data")
|
|
190
|
+
|
|
191
|
+
|
|
192
|
+
class UpdateParameter(
|
|
193
|
+
UpdateDataMixin[UpdateDataT],
|
|
194
|
+
IdentifierTypeValue[
|
|
195
|
+
IdentifierType,
|
|
196
|
+
IdentifierValueType,
|
|
197
|
+
],
|
|
198
|
+
Generic[UpdateDataT],
|
|
199
|
+
):
|
|
200
|
+
pass
|
|
201
|
+
|
|
202
|
+
|
|
203
|
+
class StatusUpdateParameter(
|
|
204
|
+
BaseStatusUpdateParameter[IdentifierType, IdentifierValueType],
|
|
205
|
+
):
|
|
206
|
+
pass
|
|
207
|
+
|
|
208
|
+
|
|
209
|
+
class DeleteSingleParameter(
|
|
210
|
+
BaseDeleteSingleParameter[IdentifierType, IdentifierValueType]
|
|
211
|
+
):
|
|
212
|
+
pass
|