maleo-identity 0.0.97__py3-none-any.whl → 0.0.99__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/api_key.py +13 -0
- maleo/identity/constants/organization.py +0 -14
- maleo/identity/constants/organization_registration_code.py +0 -15
- maleo/identity/constants/organization_relation.py +13 -0
- maleo/identity/constants/patient.py +7 -0
- maleo/identity/constants/user.py +0 -15
- maleo/identity/constants/user_medical_role.py +13 -0
- maleo/identity/constants/user_organization_role.py +13 -0
- maleo/identity/constants/user_profile.py +0 -15
- maleo/identity/constants/user_system_role.py +13 -0
- maleo/identity/dtos.py +295 -0
- maleo/identity/enums/api_key.py +13 -0
- maleo/identity/enums/organization.py +5 -6
- maleo/identity/enums/organization_relation.py +12 -0
- maleo/identity/enums/patient.py +22 -0
- maleo/identity/enums/user.py +10 -6
- maleo/identity/enums/user_medical_role.py +12 -0
- maleo/identity/enums/user_organization_role.py +12 -0
- maleo/identity/enums/user_profile.py +9 -0
- maleo/identity/enums/user_system_role.py +12 -0
- maleo/identity/mixins/api_key.py +6 -0
- maleo/identity/mixins/common.py +29 -0
- maleo/identity/mixins/organization_relation.py +14 -0
- maleo/identity/mixins/patient.py +8 -0
- maleo/identity/mixins/user_profile.py +4 -21
- maleo/identity/models.py +89 -95
- maleo/identity/schemas/api_key.py +128 -0
- maleo/identity/schemas/common.py +152 -120
- maleo/identity/schemas/organization.py +39 -6
- maleo/identity/schemas/organization_registration_code.py +14 -5
- maleo/identity/schemas/organization_relation.py +178 -0
- maleo/identity/schemas/patient.py +234 -0
- maleo/identity/schemas/user.py +19 -4
- maleo/identity/schemas/user_medical_role.py +181 -0
- maleo/identity/schemas/user_organization_role.py +181 -0
- maleo/identity/schemas/user_profile.py +68 -10
- maleo/identity/schemas/user_system_role.py +174 -0
- maleo/identity/types/api_key.py +7 -0
- maleo/identity/types/organization.py +1 -2
- maleo/identity/types/organization_registration_code.py +1 -2
- maleo/identity/types/organization_relation.py +7 -0
- maleo/identity/types/patient.py +4 -0
- maleo/identity/types/user.py +1 -2
- maleo/identity/types/user_medical_role.py +7 -0
- maleo/identity/types/user_organization_role.py +7 -0
- maleo/identity/types/user_profile.py +1 -2
- maleo/identity/types/user_system_role.py +7 -0
- maleo/identity/utils/organization.py +33 -27
- maleo/identity/utils/user.py +33 -27
- maleo/identity/validators/__init__.py +0 -0
- maleo/identity/validators/patient.py +6 -0
- {maleo_identity-0.0.97.dist-info → maleo_identity-0.0.99.dist-info}/METADATA +2 -1
- maleo_identity-0.0.99.dist-info/RECORD +67 -0
- maleo_identity-0.0.97.dist-info/RECORD +0 -36
- {maleo_identity-0.0.97.dist-info → maleo_identity-0.0.99.dist-info}/WHEEL +0 -0
- {maleo_identity-0.0.97.dist-info → maleo_identity-0.0.99.dist-info}/licenses/LICENSE +0 -0
- {maleo_identity-0.0.97.dist-info → maleo_identity-0.0.99.dist-info}/top_level.txt +0 -0
maleo/identity/schemas/common.py
CHANGED
|
@@ -1,35 +1,97 @@
|
|
|
1
|
-
from
|
|
2
|
-
from
|
|
3
|
-
from
|
|
4
|
-
from maleo.enums.
|
|
5
|
-
from maleo.
|
|
6
|
-
OrganizationRole,
|
|
1
|
+
from datetime import date
|
|
2
|
+
from pydantic import BaseModel, Field, model_validator
|
|
3
|
+
from typing import Annotated, Generic, Self, TypeVar, Type
|
|
4
|
+
from maleo.enums.identity import OptRhesus, RhesusMixin
|
|
5
|
+
from maleo.metadata.schemas.organization_role import (
|
|
7
6
|
FullOrganizationRoleMixin,
|
|
8
|
-
|
|
9
|
-
FullOrganizationTypeMixin,
|
|
7
|
+
KeyOrStandardSchema as KeyOrStandardOrganizationRoleSchema,
|
|
10
8
|
)
|
|
11
9
|
from maleo.enums.status import DataStatus as DataStatusEnum, SimpleDataStatusMixin
|
|
12
|
-
from maleo.
|
|
13
|
-
|
|
14
|
-
|
|
10
|
+
from maleo.metadata.schemas.blood_type import (
|
|
11
|
+
FullBloodTypeMixin,
|
|
12
|
+
OptKeyOrStandardSchema as OptKeyOrStandardBloodTypeSchema,
|
|
13
|
+
)
|
|
14
|
+
from maleo.metadata.schemas.gender import (
|
|
15
|
+
FullGenderMixin,
|
|
16
|
+
KeyOrStandardSchema as KeyOrStandardGenderSchema,
|
|
17
|
+
OptKeyOrStandardSchema as OptKeyOrStandardGenderSchema,
|
|
18
|
+
)
|
|
19
|
+
from maleo.metadata.schemas.medical_role import (
|
|
20
|
+
FullMedicalRoleMixin,
|
|
21
|
+
KeyOrStandardSchema as KeyOrStandardMedicalRoleSchema,
|
|
22
|
+
)
|
|
23
|
+
from maleo.metadata.schemas.organization_type import (
|
|
24
|
+
FullOrganizationTypeMixin,
|
|
25
|
+
KeyOrStandardSchema as KeyOrStandardOrganizationTypeSchema,
|
|
26
|
+
)
|
|
27
|
+
from maleo.metadata.schemas.system_role import (
|
|
28
|
+
FullSystemRoleMixin,
|
|
29
|
+
KeyOrStandardSchema as KeyOrStandardSystemRoleSchema,
|
|
30
|
+
)
|
|
31
|
+
from maleo.metadata.schemas.user_type import (
|
|
32
|
+
FullUserTypeMixin,
|
|
33
|
+
KeyOrStandardSchema as KeyOrStandardUserTypeSchema,
|
|
34
|
+
)
|
|
35
|
+
from maleo.schemas.mixins.identity import (
|
|
36
|
+
DataIdentifier,
|
|
37
|
+
IntOrganizationId,
|
|
38
|
+
IntUserId,
|
|
39
|
+
BirthDate,
|
|
40
|
+
DateOfBirth,
|
|
41
|
+
IntSourceId,
|
|
42
|
+
IntTargetId,
|
|
43
|
+
)
|
|
15
44
|
from maleo.schemas.mixins.timestamp import DataTimestamp
|
|
16
45
|
from maleo.types.datetime import OptDate
|
|
46
|
+
from maleo.types.integer import OptInt
|
|
17
47
|
from maleo.types.string import OptStr
|
|
48
|
+
from ..mixins.common import IdCard, FullName, BirthPlace, PlaceOfBirth
|
|
49
|
+
from ..mixins.api_key import APIKey
|
|
18
50
|
from ..mixins.organization_registration_code import Code, MaxUses, CurrentUses
|
|
51
|
+
from ..mixins.organization_relation import IsBidirectional, Metadata
|
|
19
52
|
from ..mixins.organization import Key as OrganizationKey, Name as OrganizationName
|
|
53
|
+
from ..mixins.patient import Passport
|
|
20
54
|
from ..mixins.user_profile import (
|
|
21
|
-
IdCard,
|
|
22
55
|
LeadingTitle,
|
|
23
56
|
FirstName,
|
|
24
57
|
MiddleName,
|
|
25
58
|
LastName,
|
|
26
59
|
EndingTitle,
|
|
27
|
-
|
|
28
|
-
BirthPlace,
|
|
29
|
-
BirthDate,
|
|
30
|
-
AvatarName,
|
|
60
|
+
AvatarUrl,
|
|
31
61
|
)
|
|
32
62
|
from ..mixins.user import Username, Email, Phone
|
|
63
|
+
from ..validators.patient import validate_id_card_or_passport
|
|
64
|
+
|
|
65
|
+
|
|
66
|
+
class APIKeySchema(
|
|
67
|
+
APIKey,
|
|
68
|
+
IntOrganizationId[OptInt],
|
|
69
|
+
IntUserId[int],
|
|
70
|
+
SimpleDataStatusMixin[DataStatusEnum],
|
|
71
|
+
DataTimestamp,
|
|
72
|
+
DataIdentifier,
|
|
73
|
+
):
|
|
74
|
+
pass
|
|
75
|
+
|
|
76
|
+
|
|
77
|
+
class PatientSchema(
|
|
78
|
+
RhesusMixin[OptRhesus],
|
|
79
|
+
FullBloodTypeMixin[OptKeyOrStandardBloodTypeSchema],
|
|
80
|
+
FullGenderMixin[KeyOrStandardGenderSchema],
|
|
81
|
+
DateOfBirth[date],
|
|
82
|
+
PlaceOfBirth[OptStr],
|
|
83
|
+
FullName[str],
|
|
84
|
+
Passport[OptStr],
|
|
85
|
+
IdCard[OptStr],
|
|
86
|
+
IntOrganizationId[int],
|
|
87
|
+
SimpleDataStatusMixin[DataStatusEnum],
|
|
88
|
+
DataTimestamp,
|
|
89
|
+
DataIdentifier,
|
|
90
|
+
):
|
|
91
|
+
@model_validator(mode="after")
|
|
92
|
+
def chk_id_card_or_passport(self) -> Self:
|
|
93
|
+
validate_id_card_or_passport(self.id_card, self.passport)
|
|
94
|
+
return self
|
|
33
95
|
|
|
34
96
|
|
|
35
97
|
class OrganizationRegistrationCodeSchema(
|
|
@@ -54,10 +116,36 @@ class OrganizationRegistrationCodeSchemaMixin(BaseModel):
|
|
|
54
116
|
] = None
|
|
55
117
|
|
|
56
118
|
|
|
57
|
-
class
|
|
119
|
+
class StandardOrganizationSchema(
|
|
58
120
|
OrganizationName[str],
|
|
59
121
|
OrganizationKey[str],
|
|
60
|
-
FullOrganizationTypeMixin[
|
|
122
|
+
FullOrganizationTypeMixin[KeyOrStandardOrganizationTypeSchema],
|
|
123
|
+
SimpleDataStatusMixin[DataStatusEnum],
|
|
124
|
+
DataTimestamp,
|
|
125
|
+
DataIdentifier,
|
|
126
|
+
):
|
|
127
|
+
pass
|
|
128
|
+
|
|
129
|
+
|
|
130
|
+
class SourceOrganizationSchemaMixin(BaseModel):
|
|
131
|
+
source: Annotated[
|
|
132
|
+
StandardOrganizationSchema, Field(..., description="Source organization")
|
|
133
|
+
]
|
|
134
|
+
|
|
135
|
+
|
|
136
|
+
class TargetOrganizationSchemaMixin(BaseModel):
|
|
137
|
+
target: Annotated[
|
|
138
|
+
StandardOrganizationSchema, Field(..., description="Target organization")
|
|
139
|
+
]
|
|
140
|
+
|
|
141
|
+
|
|
142
|
+
class OrganizationRelationSchema(
|
|
143
|
+
Metadata,
|
|
144
|
+
IsBidirectional[bool],
|
|
145
|
+
TargetOrganizationSchemaMixin,
|
|
146
|
+
IntTargetId[int],
|
|
147
|
+
SourceOrganizationSchemaMixin,
|
|
148
|
+
IntSourceId[int],
|
|
61
149
|
SimpleDataStatusMixin[DataStatusEnum],
|
|
62
150
|
DataTimestamp,
|
|
63
151
|
DataIdentifier,
|
|
@@ -65,30 +153,35 @@ class StandardOrganizationCoreSchema(
|
|
|
65
153
|
pass
|
|
66
154
|
|
|
67
155
|
|
|
68
|
-
class
|
|
156
|
+
class OrganizationRelationsSchemaMixin(BaseModel):
|
|
157
|
+
relations: Annotated[
|
|
158
|
+
list[OrganizationRelationSchema],
|
|
159
|
+
Field(list[OrganizationRelationSchema](), description="Relations"),
|
|
160
|
+
] = list[OrganizationRelationSchema]()
|
|
161
|
+
|
|
162
|
+
|
|
163
|
+
class FullOrganizationSchema(
|
|
69
164
|
OrganizationRegistrationCodeSchemaMixin,
|
|
70
|
-
|
|
165
|
+
StandardOrganizationSchema,
|
|
71
166
|
):
|
|
72
167
|
pass
|
|
73
168
|
|
|
74
169
|
|
|
75
|
-
|
|
76
|
-
Type[
|
|
77
|
-
)
|
|
78
|
-
AnyOrganizationCoreSchema = StandardOrganizationCoreSchema | FullOrganizationCoreSchema
|
|
79
|
-
AnyOrganizationCoreSchemaT = TypeVar(
|
|
80
|
-
"AnyOrganizationCoreSchemaT", bound=AnyOrganizationCoreSchema
|
|
170
|
+
AnyOrganizationSchemaType = (
|
|
171
|
+
Type[StandardOrganizationSchema] | Type[FullOrganizationSchema]
|
|
81
172
|
)
|
|
173
|
+
AnyOrganizationSchema = StandardOrganizationSchema | FullOrganizationSchema
|
|
174
|
+
AnyOrganizationSchemaT = TypeVar("AnyOrganizationSchemaT", bound=AnyOrganizationSchema)
|
|
82
175
|
|
|
83
176
|
|
|
84
|
-
class
|
|
177
|
+
class OrganizationSchemaMixin(BaseModel, Generic[AnyOrganizationSchemaT]):
|
|
85
178
|
organization: Annotated[
|
|
86
|
-
|
|
179
|
+
AnyOrganizationSchemaT, Field(..., description="Organization")
|
|
87
180
|
]
|
|
88
181
|
|
|
89
182
|
|
|
90
183
|
class UserMedicalRoleSchema(
|
|
91
|
-
FullMedicalRoleMixin[
|
|
184
|
+
FullMedicalRoleMixin[KeyOrStandardMedicalRoleSchema],
|
|
92
185
|
IntOrganizationId[int],
|
|
93
186
|
IntUserId[int],
|
|
94
187
|
SimpleDataStatusMixin[DataStatusEnum],
|
|
@@ -106,7 +199,7 @@ class UserMedicalRolesSchemaMixin(BaseModel):
|
|
|
106
199
|
|
|
107
200
|
|
|
108
201
|
class UserOrganizationRoleSchema(
|
|
109
|
-
FullOrganizationRoleMixin[
|
|
202
|
+
FullOrganizationRoleMixin[KeyOrStandardOrganizationRoleSchema],
|
|
110
203
|
IntOrganizationId[int],
|
|
111
204
|
IntUserId[int],
|
|
112
205
|
SimpleDataStatusMixin[DataStatusEnum],
|
|
@@ -123,10 +216,10 @@ class UserOrganizationRolesSchemaMixin(BaseModel):
|
|
|
123
216
|
] = list[UserOrganizationRoleSchema]()
|
|
124
217
|
|
|
125
218
|
|
|
126
|
-
class
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
219
|
+
class UserProfileSchema(
|
|
220
|
+
AvatarUrl[str],
|
|
221
|
+
FullBloodTypeMixin[OptKeyOrStandardBloodTypeSchema],
|
|
222
|
+
FullGenderMixin[OptKeyOrStandardGenderSchema],
|
|
130
223
|
BirthDate[OptDate],
|
|
131
224
|
BirthPlace[OptStr],
|
|
132
225
|
FullName[str],
|
|
@@ -144,17 +237,17 @@ class UserProfileCoreSchema(
|
|
|
144
237
|
pass
|
|
145
238
|
|
|
146
239
|
|
|
147
|
-
|
|
240
|
+
OptUserProfileSchema = UserProfileSchema | None
|
|
148
241
|
|
|
149
242
|
|
|
150
|
-
class
|
|
243
|
+
class UserProfileSchemaMixin(BaseModel):
|
|
151
244
|
profile: Annotated[
|
|
152
|
-
|
|
245
|
+
OptUserProfileSchema, Field(None, description="User's Profile")
|
|
153
246
|
] = None
|
|
154
247
|
|
|
155
248
|
|
|
156
|
-
class
|
|
157
|
-
FullSystemRoleMixin[
|
|
249
|
+
class UserSystemRoleSchema(
|
|
250
|
+
FullSystemRoleMixin[KeyOrStandardSystemRoleSchema],
|
|
158
251
|
IntUserId[int],
|
|
159
252
|
SimpleDataStatusMixin[DataStatusEnum],
|
|
160
253
|
DataTimestamp,
|
|
@@ -163,23 +256,23 @@ class UserSystemRoleCoreSchema(
|
|
|
163
256
|
pass
|
|
164
257
|
|
|
165
258
|
|
|
166
|
-
class
|
|
259
|
+
class UserSystemRolesSchemaMixin(BaseModel):
|
|
167
260
|
system_roles: Annotated[
|
|
168
|
-
list[
|
|
261
|
+
list[UserSystemRoleSchema],
|
|
169
262
|
Field(
|
|
170
|
-
list[
|
|
263
|
+
list[UserSystemRoleSchema](),
|
|
171
264
|
description="User's system roles",
|
|
172
265
|
min_length=1,
|
|
173
266
|
),
|
|
174
|
-
] = list[
|
|
267
|
+
] = list[UserSystemRoleSchema]()
|
|
175
268
|
|
|
176
269
|
|
|
177
|
-
class
|
|
178
|
-
|
|
270
|
+
class StandardUserSchema(
|
|
271
|
+
UserProfileSchemaMixin,
|
|
179
272
|
Phone[str],
|
|
180
273
|
Email[str],
|
|
181
274
|
Username[str],
|
|
182
|
-
FullUserTypeMixin[
|
|
275
|
+
FullUserTypeMixin[KeyOrStandardUserTypeSchema],
|
|
183
276
|
SimpleDataStatusMixin[DataStatusEnum],
|
|
184
277
|
DataTimestamp,
|
|
185
278
|
DataIdentifier,
|
|
@@ -187,29 +280,10 @@ class StandardUserCoreSchema(
|
|
|
187
280
|
pass
|
|
188
281
|
|
|
189
282
|
|
|
190
|
-
class
|
|
191
|
-
pass
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
AnyUserCoreSchemaType = Type[StandardUserCoreSchema] | Type[FullUserCoreSchema]
|
|
195
|
-
AnyUserCoreSchema = StandardUserCoreSchema | FullUserCoreSchema
|
|
196
|
-
AnyUserCoreSchemaT = TypeVar("AnyUserCoreSchemaT", bound=AnyUserCoreSchema)
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
class UserCoreSchemaMixin(BaseModel, Generic[AnyUserCoreSchemaT]):
|
|
200
|
-
user: Annotated[AnyUserCoreSchemaT, Field(..., description="User")]
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
class UserAndOrganizationSchema(
|
|
283
|
+
class UserOrganizationSchema(
|
|
204
284
|
UserMedicalRolesSchemaMixin,
|
|
205
285
|
UserOrganizationRolesSchemaMixin,
|
|
206
|
-
|
|
207
|
-
pass
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
class UserOrganizationSchema(
|
|
211
|
-
UserAndOrganizationSchema,
|
|
212
|
-
OrganizationCoreSchemaMixin[StandardOrganizationCoreSchema],
|
|
286
|
+
OrganizationSchemaMixin[StandardOrganizationSchema],
|
|
213
287
|
SimpleDataStatusMixin[DataStatusEnum],
|
|
214
288
|
DataTimestamp,
|
|
215
289
|
DataIdentifier,
|
|
@@ -224,68 +298,26 @@ class UserOrganizationsSchemaMixin(BaseModel):
|
|
|
224
298
|
] = list[UserOrganizationSchema]()
|
|
225
299
|
|
|
226
300
|
|
|
227
|
-
class
|
|
301
|
+
class FullUserSchema(UserSystemRolesSchemaMixin, StandardUserSchema):
|
|
228
302
|
pass
|
|
229
303
|
|
|
230
304
|
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
305
|
+
AnyUserSchemaType = Type[StandardUserSchema] | Type[FullUserSchema]
|
|
306
|
+
AnyUserSchema = StandardUserSchema | FullUserSchema
|
|
307
|
+
AnyUserSchemaT = TypeVar("AnyUserSchemaT", bound=AnyUserSchema)
|
|
234
308
|
|
|
235
|
-
AnyUserCompleteSchemaType = (
|
|
236
|
-
Type[StandardUserCompleteSchema] | Type[FullUserCompleteSchema]
|
|
237
|
-
)
|
|
238
|
-
AnyUserCompleteSchema = StandardUserCompleteSchema | FullUserCompleteSchema
|
|
239
|
-
AnyUserCompleteSchemaT = TypeVar("AnyUserCompleteSchemaT", bound=AnyUserCompleteSchema)
|
|
240
309
|
|
|
310
|
+
class UserSchemaMixin(BaseModel, Generic[AnyUserSchemaT]):
|
|
311
|
+
user: Annotated[AnyUserSchemaT, Field(..., description="User")]
|
|
241
312
|
|
|
242
|
-
AnyUserSchemaType = AnyUserCoreSchemaType | AnyUserCompleteSchemaType
|
|
243
|
-
AnyUserSchema = AnyUserCoreSchema | AnyUserCompleteSchema
|
|
244
|
-
AnyUserSchemaT = TypeVar("AnyUserSchemaT", bound=AnyUserSchema)
|
|
245
313
|
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
314
|
+
class UserAndOrganizationSchema(
|
|
315
|
+
UserMedicalRolesSchemaMixin,
|
|
316
|
+
UserOrganizationRolesSchemaMixin,
|
|
317
|
+
OrganizationSchemaMixin[StandardOrganizationSchema],
|
|
318
|
+
UserSchemaMixin[StandardUserSchema],
|
|
250
319
|
SimpleDataStatusMixin[DataStatusEnum],
|
|
251
320
|
DataTimestamp,
|
|
252
321
|
DataIdentifier,
|
|
253
322
|
):
|
|
254
323
|
pass
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
class OrganizationUsersSchemaMixin(BaseModel):
|
|
258
|
-
users: Annotated[
|
|
259
|
-
list[OrganizationUserSchema],
|
|
260
|
-
Field(list[OrganizationUserSchema](), description="Users"),
|
|
261
|
-
] = list[OrganizationUserSchema]()
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
class StandardOrganizationCompleteSchema(
|
|
265
|
-
OrganizationUsersSchemaMixin, StandardOrganizationCoreSchema
|
|
266
|
-
):
|
|
267
|
-
pass
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
class FullOrganizationCompleteSchema(
|
|
271
|
-
OrganizationUsersSchemaMixin, FullOrganizationCoreSchema
|
|
272
|
-
):
|
|
273
|
-
pass
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
AnyOrganizationCompleteSchemaType = (
|
|
277
|
-
Type[StandardOrganizationCompleteSchema] | Type[FullOrganizationCompleteSchema]
|
|
278
|
-
)
|
|
279
|
-
AnyOrganizationCompleteSchema = (
|
|
280
|
-
StandardOrganizationCompleteSchema | FullOrganizationCompleteSchema
|
|
281
|
-
)
|
|
282
|
-
AnyOrganizationCompleteSchemaT = TypeVar(
|
|
283
|
-
"AnyOrganizationCompleteSchemaT", bound=AnyOrganizationCompleteSchema
|
|
284
|
-
)
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
AnyOrganizationSchemaType = (
|
|
288
|
-
AnyOrganizationCoreSchemaType | AnyOrganizationCompleteSchemaType
|
|
289
|
-
)
|
|
290
|
-
AnyOrganizationSchema = AnyOrganizationCoreSchema | AnyOrganizationCompleteSchema
|
|
291
|
-
AnyOrganizationSchemaT = TypeVar("AnyOrganizationSchemaT", bound=AnyOrganizationSchema)
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
from pydantic import BaseModel, Field
|
|
2
|
-
from typing import Generic, Literal, TypeVar, overload
|
|
2
|
+
from typing import Annotated, Generic, Literal, TypeVar, overload
|
|
3
3
|
from uuid import UUID
|
|
4
4
|
from maleo.enums.organization import (
|
|
5
|
+
OptOrganizationRelation,
|
|
5
6
|
OrganizationType,
|
|
6
7
|
OptOrganizationType,
|
|
7
8
|
FullOrganizationTypeMixin,
|
|
@@ -28,19 +29,41 @@ from maleo.schemas.parameter import (
|
|
|
28
29
|
DeleteSingleParameter as BaseDeleteSingleParameter,
|
|
29
30
|
)
|
|
30
31
|
from maleo.types.dict import StrToAnyDict
|
|
31
|
-
from maleo.types.integer import OptListOfInts
|
|
32
|
+
from maleo.types.integer import OptInt, OptListOfInts
|
|
32
33
|
from maleo.types.string import OptStr, OptListOfStrs
|
|
33
34
|
from maleo.types.uuid import OptListOfUUIDs
|
|
34
|
-
from ..enums.organization import IdentifierType
|
|
35
|
+
from ..enums.organization import IdentifierType, OptListOfExpandableFields
|
|
35
36
|
from ..mixins.organization import Key, Name
|
|
36
37
|
from ..types.organization import IdentifierValueType
|
|
37
38
|
|
|
38
39
|
|
|
39
|
-
class
|
|
40
|
+
class Expand(BaseModel):
|
|
41
|
+
expand: Annotated[
|
|
42
|
+
OptListOfExpandableFields, Field(None, description="Expand", min_length=1)
|
|
43
|
+
] = None
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
class CreateQuery(Expand):
|
|
47
|
+
pass
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
class InsertData(Name[str], Key[str], FullOrganizationTypeMixin[OrganizationType]):
|
|
51
|
+
pass
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
class CreateData(InsertData):
|
|
55
|
+
related_to: Annotated[OptInt, Field(None, description="Related to", ge=1)] = None
|
|
56
|
+
relation: Annotated[
|
|
57
|
+
OptOrganizationRelation, Field(None, description="Relation")
|
|
58
|
+
] = None
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
class CreateParameter(CreateQuery, CreateData):
|
|
40
62
|
pass
|
|
41
63
|
|
|
42
64
|
|
|
43
65
|
class ReadMultipleParameter(
|
|
66
|
+
Expand,
|
|
44
67
|
ReadPaginatedMultipleParameter,
|
|
45
68
|
Names[OptListOfStrs],
|
|
46
69
|
Keys[OptListOfStrs],
|
|
@@ -61,6 +84,7 @@ class ReadMultipleParameter(
|
|
|
61
84
|
"page",
|
|
62
85
|
"limit",
|
|
63
86
|
"use_cache",
|
|
87
|
+
"expand",
|
|
64
88
|
}
|
|
65
89
|
|
|
66
90
|
def to_query_params(self) -> StrToAnyDict:
|
|
@@ -73,7 +97,9 @@ class ReadMultipleParameter(
|
|
|
73
97
|
return params
|
|
74
98
|
|
|
75
99
|
|
|
76
|
-
class ReadSingleParameter(
|
|
100
|
+
class ReadSingleParameter(
|
|
101
|
+
Expand, BaseReadSingleParameter[IdentifierType, IdentifierValueType]
|
|
102
|
+
):
|
|
77
103
|
@overload
|
|
78
104
|
@classmethod
|
|
79
105
|
def new(
|
|
@@ -82,6 +108,7 @@ class ReadSingleParameter(BaseReadSingleParameter[IdentifierType, IdentifierValu
|
|
|
82
108
|
identifier_value: int,
|
|
83
109
|
statuses: ListOfDataStatuses = list(FULL_DATA_STATUSES),
|
|
84
110
|
use_cache: bool = True,
|
|
111
|
+
expand: OptListOfExpandableFields = None,
|
|
85
112
|
) -> "ReadSingleParameter": ...
|
|
86
113
|
@overload
|
|
87
114
|
@classmethod
|
|
@@ -91,6 +118,7 @@ class ReadSingleParameter(BaseReadSingleParameter[IdentifierType, IdentifierValu
|
|
|
91
118
|
identifier_value: UUID,
|
|
92
119
|
statuses: ListOfDataStatuses = list(FULL_DATA_STATUSES),
|
|
93
120
|
use_cache: bool = True,
|
|
121
|
+
expand: OptListOfExpandableFields = None,
|
|
94
122
|
) -> "ReadSingleParameter": ...
|
|
95
123
|
@overload
|
|
96
124
|
@classmethod
|
|
@@ -100,6 +128,7 @@ class ReadSingleParameter(BaseReadSingleParameter[IdentifierType, IdentifierValu
|
|
|
100
128
|
identifier_value: str,
|
|
101
129
|
statuses: ListOfDataStatuses = list(FULL_DATA_STATUSES),
|
|
102
130
|
use_cache: bool = True,
|
|
131
|
+
expand: OptListOfExpandableFields = None,
|
|
103
132
|
) -> "ReadSingleParameter": ...
|
|
104
133
|
@classmethod
|
|
105
134
|
def new(
|
|
@@ -108,17 +137,19 @@ class ReadSingleParameter(BaseReadSingleParameter[IdentifierType, IdentifierValu
|
|
|
108
137
|
identifier_value: IdentifierValueType,
|
|
109
138
|
statuses: ListOfDataStatuses = list(FULL_DATA_STATUSES),
|
|
110
139
|
use_cache: bool = True,
|
|
140
|
+
expand: OptListOfExpandableFields = None,
|
|
111
141
|
) -> "ReadSingleParameter":
|
|
112
142
|
return cls(
|
|
113
143
|
identifier_type=identifier_type,
|
|
114
144
|
identifier_value=identifier_value,
|
|
115
145
|
statuses=statuses,
|
|
116
146
|
use_cache=use_cache,
|
|
147
|
+
expand=expand,
|
|
117
148
|
)
|
|
118
149
|
|
|
119
150
|
def to_query_params(self) -> StrToAnyDict:
|
|
120
151
|
return self.model_dump(
|
|
121
|
-
mode="json", include={"statuses", "use_cache"}, exclude_none=True
|
|
152
|
+
mode="json", include={"statuses", "use_cache", "expand"}, exclude_none=True
|
|
122
153
|
)
|
|
123
154
|
|
|
124
155
|
|
|
@@ -140,6 +171,7 @@ class UpdateDataMixin(BaseModel, Generic[UpdateDataT]):
|
|
|
140
171
|
|
|
141
172
|
|
|
142
173
|
class UpdateParameter(
|
|
174
|
+
Expand,
|
|
143
175
|
UpdateDataMixin[UpdateDataT],
|
|
144
176
|
IdentifierTypeValue[
|
|
145
177
|
IdentifierType,
|
|
@@ -151,6 +183,7 @@ class UpdateParameter(
|
|
|
151
183
|
|
|
152
184
|
|
|
153
185
|
class StatusUpdateParameter(
|
|
186
|
+
Expand,
|
|
154
187
|
BaseStatusUpdateParameter[IdentifierType, IdentifierValueType],
|
|
155
188
|
):
|
|
156
189
|
pass
|
|
@@ -11,8 +11,8 @@ from maleo.schemas.mixins.identity import (
|
|
|
11
11
|
IdentifierTypeValue,
|
|
12
12
|
Ids,
|
|
13
13
|
IntOrganizationId,
|
|
14
|
+
IntOrganizationIds,
|
|
14
15
|
UUIDs,
|
|
15
|
-
UUIDOrganizationIds,
|
|
16
16
|
)
|
|
17
17
|
from maleo.schemas.mixins.sort import convert as convert_sort
|
|
18
18
|
from maleo.schemas.parameter import (
|
|
@@ -30,15 +30,15 @@ from ..mixins.organization_registration_code import Code, MaxUses
|
|
|
30
30
|
from ..types.organization_registration_code import IdentifierValueType
|
|
31
31
|
|
|
32
32
|
|
|
33
|
-
class
|
|
33
|
+
class StandardCreateParameter(
|
|
34
34
|
MaxUses[int],
|
|
35
35
|
Code[OptStr],
|
|
36
36
|
):
|
|
37
37
|
pass
|
|
38
38
|
|
|
39
39
|
|
|
40
|
-
class
|
|
41
|
-
|
|
40
|
+
class FullCreateParameter(
|
|
41
|
+
StandardCreateParameter,
|
|
42
42
|
IntOrganizationId[int],
|
|
43
43
|
):
|
|
44
44
|
pass
|
|
@@ -47,7 +47,7 @@ class CreateParameter(
|
|
|
47
47
|
class ReadMultipleParameter(
|
|
48
48
|
ReadPaginatedMultipleParameter,
|
|
49
49
|
Codes[OptListOfStrs],
|
|
50
|
-
|
|
50
|
+
IntOrganizationIds[OptListOfInts],
|
|
51
51
|
UUIDs[OptListOfUUIDs],
|
|
52
52
|
Ids[OptListOfInts],
|
|
53
53
|
):
|
|
@@ -103,6 +103,15 @@ class ReadSingleParameter(BaseReadSingleParameter[IdentifierType, IdentifierValu
|
|
|
103
103
|
statuses: ListOfDataStatuses = list(FULL_DATA_STATUSES),
|
|
104
104
|
use_cache: bool = True,
|
|
105
105
|
) -> "ReadSingleParameter": ...
|
|
106
|
+
@overload
|
|
107
|
+
@classmethod
|
|
108
|
+
def new(
|
|
109
|
+
cls,
|
|
110
|
+
identifier_type: IdentifierType,
|
|
111
|
+
identifier_value: IdentifierValueType,
|
|
112
|
+
statuses: ListOfDataStatuses = list(FULL_DATA_STATUSES),
|
|
113
|
+
use_cache: bool = True,
|
|
114
|
+
) -> "ReadSingleParameter": ...
|
|
106
115
|
@classmethod
|
|
107
116
|
def new(
|
|
108
117
|
cls,
|