maleo-identity 0.1.31__py3-none-any.whl → 0.1.59__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/identity/constants/api_key.py +1 -1
- maleo/identity/constants/organization.py +1 -1
- maleo/identity/constants/organization_registration_code.py +1 -1
- maleo/identity/constants/organization_relation.py +1 -1
- maleo/identity/constants/patient.py +1 -1
- maleo/identity/constants/user.py +1 -1
- maleo/identity/constants/user_medical_role.py +1 -1
- maleo/identity/constants/user_organization.py +13 -0
- maleo/identity/constants/user_organization_role.py +1 -1
- maleo/identity/constants/user_profile.py +2 -2
- maleo/identity/constants/user_system_role.py +2 -2
- maleo/identity/enums/api_key.py +1 -1
- maleo/identity/enums/organization.py +14 -10
- maleo/identity/enums/organization_registration_code.py +1 -1
- maleo/identity/enums/organization_relation.py +1 -1
- maleo/identity/enums/patient.py +1 -1
- maleo/identity/enums/user.py +16 -1
- maleo/identity/enums/user_medical_role.py +14 -1
- maleo/identity/enums/user_organization.py +40 -0
- maleo/identity/enums/user_organization_role.py +14 -1
- maleo/identity/enums/user_profile.py +1 -1
- maleo/identity/enums/user_system_role.py +1 -1
- maleo/identity/mixins/api_key.py +19 -3
- maleo/identity/mixins/common.py +2 -2
- maleo/identity/mixins/organization.py +10 -4
- maleo/identity/mixins/organization_registration_code.py +4 -4
- maleo/identity/mixins/organization_relation.py +5 -5
- maleo/identity/mixins/patient.py +2 -2
- maleo/identity/mixins/user.py +9 -3
- maleo/identity/mixins/user_medical_role.py +11 -5
- maleo/identity/mixins/user_organization.py +76 -0
- maleo/identity/mixins/user_organization_role.py +11 -5
- maleo/identity/mixins/user_profile.py +2 -2
- maleo/identity/mixins/user_system_role.py +3 -3
- maleo/identity/schemas/api_key.py +22 -8
- maleo/identity/schemas/common.py +26 -82
- maleo/identity/schemas/organization.py +59 -25
- maleo/identity/schemas/organization_registration_code.py +11 -11
- maleo/identity/schemas/organization_relation.py +48 -22
- maleo/identity/schemas/patient.py +12 -12
- maleo/identity/schemas/user.py +104 -22
- maleo/identity/schemas/user_medical_role.py +66 -16
- maleo/identity/schemas/user_organization.py +334 -0
- maleo/identity/schemas/user_organization_role.py +68 -16
- maleo/identity/schemas/user_profile.py +12 -12
- maleo/identity/schemas/user_system_role.py +10 -10
- maleo/identity/types/api_key.py +3 -2
- maleo/identity/types/organization.py +1 -1
- maleo/identity/types/organization_registration_code.py +1 -1
- maleo/identity/types/organization_relation.py +1 -1
- maleo/identity/types/user.py +1 -1
- maleo/identity/types/user_medical_role.py +3 -2
- maleo/identity/types/user_organization.py +7 -0
- maleo/identity/types/user_organization_role.py +3 -2
- maleo/identity/types/user_profile.py +1 -1
- maleo/identity/types/user_system_role.py +1 -1
- {maleo_identity-0.1.31.dist-info → maleo_identity-0.1.59.dist-info}/METADATA +10 -9
- maleo_identity-0.1.59.dist-info/RECORD +68 -0
- maleo/identity/utils/__init__.py +0 -0
- maleo/identity/utils/organization.py +0 -32
- maleo/identity/utils/user.py +0 -32
- maleo_identity-0.1.31.dist-info/RECORD +0 -66
- {maleo_identity-0.1.31.dist-info → maleo_identity-0.1.59.dist-info}/WHEEL +0 -0
- {maleo_identity-0.1.31.dist-info → maleo_identity-0.1.59.dist-info}/licenses/LICENSE +0 -0
- {maleo_identity-0.1.31.dist-info → maleo_identity-0.1.59.dist-info}/top_level.txt +0 -0
maleo/identity/constants/user.py
CHANGED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
from nexo.schemas.resource import Resource, ResourceIdentifier
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
USER_ORGANIZATION_RESOURCE = Resource(
|
|
5
|
+
identifiers=[
|
|
6
|
+
ResourceIdentifier(
|
|
7
|
+
key="user_organization",
|
|
8
|
+
name="User Organization",
|
|
9
|
+
slug="user-organizations",
|
|
10
|
+
)
|
|
11
|
+
],
|
|
12
|
+
details=None,
|
|
13
|
+
)
|
maleo/identity/enums/api_key.py
CHANGED
|
@@ -1,14 +1,5 @@
|
|
|
1
1
|
from enum import StrEnum
|
|
2
|
-
from
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
class Granularity(StrEnum):
|
|
6
|
-
STANDARD = "standard"
|
|
7
|
-
FULL = "full"
|
|
8
|
-
|
|
9
|
-
@classmethod
|
|
10
|
-
def choices(cls) -> ListOfStrs:
|
|
11
|
-
return [e.value for e in cls]
|
|
2
|
+
from nexo.types.string import ListOfStrs
|
|
12
3
|
|
|
13
4
|
|
|
14
5
|
class IdentifierType(StrEnum):
|
|
@@ -23,3 +14,16 @@ class IdentifierType(StrEnum):
|
|
|
23
14
|
@property
|
|
24
15
|
def column(self) -> str:
|
|
25
16
|
return self.value
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
class ExpandableField(StrEnum):
|
|
20
|
+
ORGANIZATION_TYPE = "organization_type"
|
|
21
|
+
|
|
22
|
+
@classmethod
|
|
23
|
+
def choices(cls) -> ListOfStrs:
|
|
24
|
+
return [e.value for e in cls]
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
OptExpandableField = ExpandableField | None
|
|
28
|
+
ListOfExpandableFields = list[ExpandableField]
|
|
29
|
+
OptListOfExpandableFields = ListOfExpandableFields | None
|
maleo/identity/enums/patient.py
CHANGED
maleo/identity/enums/user.py
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
from enum import StrEnum
|
|
2
|
-
from
|
|
2
|
+
from nexo.types.string import ListOfStrs
|
|
3
3
|
|
|
4
4
|
|
|
5
5
|
class Granularity(StrEnum):
|
|
@@ -24,3 +24,18 @@ class IdentifierType(StrEnum):
|
|
|
24
24
|
@property
|
|
25
25
|
def column(self) -> str:
|
|
26
26
|
return self.value
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
class ExpandableField(StrEnum):
|
|
30
|
+
USER_TYPE = "user_type"
|
|
31
|
+
BLOOD_TYPE = "blood_type"
|
|
32
|
+
GENDER = "gender"
|
|
33
|
+
|
|
34
|
+
@classmethod
|
|
35
|
+
def choices(cls) -> ListOfStrs:
|
|
36
|
+
return [e.value for e in cls]
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
OptExpandableField = ExpandableField | None
|
|
40
|
+
ListOfExpandableFields = list[ExpandableField]
|
|
41
|
+
OptListOfExpandableFields = ListOfExpandableFields | None
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
from enum import StrEnum
|
|
2
|
-
from
|
|
2
|
+
from nexo.types.string import ListOfStrs, ManyStrs
|
|
3
3
|
|
|
4
4
|
|
|
5
5
|
class IdentifierType(StrEnum):
|
|
@@ -20,3 +20,16 @@ class IdentifierType(StrEnum):
|
|
|
20
20
|
elif self is IdentifierType.COMPOSITE:
|
|
21
21
|
return ("user_id", "organization_id", "medical_role")
|
|
22
22
|
raise ValueError(f"Unknown column(s) for identifier type: {self}")
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
class ExpandableField(StrEnum):
|
|
26
|
+
MEDICAL_ROLE = "medical_role"
|
|
27
|
+
|
|
28
|
+
@classmethod
|
|
29
|
+
def choices(cls) -> ListOfStrs:
|
|
30
|
+
return [e.value for e in cls]
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
OptExpandableField = ExpandableField | None
|
|
34
|
+
ListOfExpandableFields = list[ExpandableField]
|
|
35
|
+
OptListOfExpandableFields = ListOfExpandableFields | None
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
from enum import StrEnum
|
|
2
|
+
from nexo.types.string import ListOfStrs, ManyStrs
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
class IdentifierType(StrEnum):
|
|
6
|
+
ID = "id"
|
|
7
|
+
UUID = "uuid"
|
|
8
|
+
COMPOSITE = "composite"
|
|
9
|
+
|
|
10
|
+
@classmethod
|
|
11
|
+
def choices(cls) -> ListOfStrs:
|
|
12
|
+
return [e.value for e in cls]
|
|
13
|
+
|
|
14
|
+
@property
|
|
15
|
+
def columns(self) -> ManyStrs:
|
|
16
|
+
if self is IdentifierType.ID:
|
|
17
|
+
return ("id",)
|
|
18
|
+
elif self is IdentifierType.UUID:
|
|
19
|
+
return ("uuid",)
|
|
20
|
+
elif self is IdentifierType.COMPOSITE:
|
|
21
|
+
return ("user_id", "organization_id")
|
|
22
|
+
raise ValueError(f"Unknown column(s) for identifier type: {self}")
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
class ExpandableField(StrEnum):
|
|
26
|
+
USER_TYPE = "user_type"
|
|
27
|
+
BLOOD_TYPE = "blood_type"
|
|
28
|
+
GENDER = "gender"
|
|
29
|
+
ORGANIZATION_TYPE = "organization_type"
|
|
30
|
+
ORGANIZATION_ROLE = "organization_role"
|
|
31
|
+
MEDICAL_ROLE = "medical_role"
|
|
32
|
+
|
|
33
|
+
@classmethod
|
|
34
|
+
def choices(cls) -> ListOfStrs:
|
|
35
|
+
return [e.value for e in cls]
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
OptExpandableField = ExpandableField | None
|
|
39
|
+
ListOfExpandableFields = list[ExpandableField]
|
|
40
|
+
OptListOfExpandableFields = ListOfExpandableFields | None
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
from enum import StrEnum
|
|
2
|
-
from
|
|
2
|
+
from nexo.types.string import ListOfStrs, ManyStrs
|
|
3
3
|
|
|
4
4
|
|
|
5
5
|
class IdentifierType(StrEnum):
|
|
@@ -20,3 +20,16 @@ class IdentifierType(StrEnum):
|
|
|
20
20
|
elif self is IdentifierType.COMPOSITE:
|
|
21
21
|
return ("user_id", "organization_id", "organization_role")
|
|
22
22
|
raise ValueError(f"Unknown column(s) for identifier type: {self}")
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
class ExpandableField(StrEnum):
|
|
26
|
+
ORGANIZATION_ROLE = "organization_role"
|
|
27
|
+
|
|
28
|
+
@classmethod
|
|
29
|
+
def choices(cls) -> ListOfStrs:
|
|
30
|
+
return [e.value for e in cls]
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
OptExpandableField = ExpandableField | None
|
|
34
|
+
ListOfExpandableFields = list[ExpandableField]
|
|
35
|
+
OptListOfExpandableFields = ListOfExpandableFields | None
|
maleo/identity/mixins/api_key.py
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
from pydantic import BaseModel, Field
|
|
2
2
|
from typing import Annotated, Literal, TypeGuard
|
|
3
3
|
from uuid import UUID
|
|
4
|
-
from
|
|
5
|
-
from
|
|
6
|
-
from
|
|
4
|
+
from nexo.schemas.mixins.identity import Identifier
|
|
5
|
+
from nexo.types.any import ManyAny
|
|
6
|
+
from nexo.types.string import ManyStrs
|
|
7
7
|
from ..enums.api_key import IdentifierType
|
|
8
8
|
from ..types.api_key import CompositeIdentifierType, IdentifierValueType
|
|
9
9
|
|
|
@@ -34,6 +34,13 @@ class UUIDAPIKeyIdentifier(Identifier[Literal[IdentifierType.UUID], UUID]):
|
|
|
34
34
|
] = IdentifierType.UUID
|
|
35
35
|
|
|
36
36
|
|
|
37
|
+
class APIKeyAPIKeyIdentifier(Identifier[Literal[IdentifierType.API_KEY], str]):
|
|
38
|
+
type: Annotated[
|
|
39
|
+
Literal[IdentifierType.API_KEY],
|
|
40
|
+
Field(IdentifierType.API_KEY, description="Identifier's type"),
|
|
41
|
+
] = IdentifierType.API_KEY
|
|
42
|
+
|
|
43
|
+
|
|
37
44
|
class CompositeAPIKeyIdentifier(
|
|
38
45
|
Identifier[Literal[IdentifierType.COMPOSITE], CompositeIdentifierType]
|
|
39
46
|
):
|
|
@@ -50,6 +57,7 @@ AnyAPIKeyIdentifier = (
|
|
|
50
57
|
APIKeyIdentifier
|
|
51
58
|
| IdAPIKeyIdentifier
|
|
52
59
|
| UUIDAPIKeyIdentifier
|
|
60
|
+
| APIKeyAPIKeyIdentifier
|
|
53
61
|
| CompositeAPIKeyIdentifier
|
|
54
62
|
)
|
|
55
63
|
|
|
@@ -60,6 +68,14 @@ def is_id_identifier(
|
|
|
60
68
|
return identifier.type is IdentifierType.ID and isinstance(identifier.value, int)
|
|
61
69
|
|
|
62
70
|
|
|
71
|
+
def is_api_key_identifier(
|
|
72
|
+
identifier: AnyAPIKeyIdentifier,
|
|
73
|
+
) -> TypeGuard[APIKeyAPIKeyIdentifier]:
|
|
74
|
+
return identifier.type is IdentifierType.API_KEY and isinstance(
|
|
75
|
+
identifier.value, str
|
|
76
|
+
)
|
|
77
|
+
|
|
78
|
+
|
|
63
79
|
def is_uuid_identifier(
|
|
64
80
|
identifier: AnyAPIKeyIdentifier,
|
|
65
81
|
) -> TypeGuard[UUIDAPIKeyIdentifier]:
|
maleo/identity/mixins/common.py
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
from pydantic import Field
|
|
2
2
|
from typing import Annotated, Generic
|
|
3
|
-
from
|
|
3
|
+
from nexo.schemas.mixins.identity import (
|
|
4
4
|
IdCard as BaseIdCard,
|
|
5
5
|
FullName as BaseFullName,
|
|
6
6
|
BirthPlace as BaseBirthPlace,
|
|
7
7
|
PlaceOfBirth as BasePlaceOfBirth,
|
|
8
8
|
)
|
|
9
|
-
from
|
|
9
|
+
from nexo.types.string import OptStrT
|
|
10
10
|
|
|
11
11
|
|
|
12
12
|
class IdCard(BaseIdCard[OptStrT], Generic[OptStrT]):
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
from pydantic import BaseModel, Field
|
|
2
2
|
from typing import Annotated, Generic, Literal, TypeGuard
|
|
3
3
|
from uuid import UUID
|
|
4
|
-
from
|
|
5
|
-
from
|
|
6
|
-
from
|
|
7
|
-
from ..enums.organization import IdentifierType
|
|
4
|
+
from nexo.schemas.mixins.identity import Identifier, Key as BaseKey, Name as BaseName
|
|
5
|
+
from nexo.types.string import OptStrT
|
|
6
|
+
from nexo.types.uuid import OptUUIDT
|
|
7
|
+
from ..enums.organization import IdentifierType, OptListOfExpandableFields
|
|
8
8
|
from ..types.organization import IdentifierValueType
|
|
9
9
|
|
|
10
10
|
|
|
@@ -20,6 +20,12 @@ class Secret(BaseModel, Generic[OptUUIDT]):
|
|
|
20
20
|
secret: Annotated[OptUUIDT, Field(..., description="Secret")]
|
|
21
21
|
|
|
22
22
|
|
|
23
|
+
class Expand(BaseModel):
|
|
24
|
+
expand: Annotated[
|
|
25
|
+
OptListOfExpandableFields, Field(None, description="Expanded field(s)")
|
|
26
|
+
] = None
|
|
27
|
+
|
|
28
|
+
|
|
23
29
|
class OrganizationIdentifier(Identifier[IdentifierType, IdentifierValueType]):
|
|
24
30
|
@property
|
|
25
31
|
def column_and_value(self) -> tuple[str, IdentifierValueType]:
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
from pydantic import BaseModel, Field, model_validator
|
|
2
2
|
from typing import Annotated, Generic, Literal, Self, TypeGuard
|
|
3
3
|
from uuid import UUID
|
|
4
|
-
from
|
|
5
|
-
from
|
|
6
|
-
from
|
|
7
|
-
from
|
|
4
|
+
from nexo.schemas.mixins.identity import Identifier
|
|
5
|
+
from nexo.types.integer import OptIntT
|
|
6
|
+
from nexo.types.misc import OptIntOrStr
|
|
7
|
+
from nexo.types.string import OptStrT
|
|
8
8
|
from ..enums.organization_registration_code import IdentifierType
|
|
9
9
|
from ..types.organization_registration_code import IdentifierValueType
|
|
10
10
|
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
from pydantic import BaseModel, Field
|
|
2
2
|
from typing import Annotated, Generic, Literal, TypeGuard
|
|
3
3
|
from uuid import UUID
|
|
4
|
-
from
|
|
5
|
-
from
|
|
6
|
-
from
|
|
7
|
-
from
|
|
8
|
-
from
|
|
4
|
+
from nexo.schemas.mixins.identity import Identifier
|
|
5
|
+
from nexo.types.any import ManyAny
|
|
6
|
+
from nexo.types.boolean import OptBoolT
|
|
7
|
+
from nexo.types.misc import OptListOfAnyOrStrToAnyDict
|
|
8
|
+
from nexo.types.string import ManyStrs
|
|
9
9
|
from ..enums.organization_relation import IdentifierType, OptListOfExpandableFields
|
|
10
10
|
from ..types.organization_relation import CompositeIdentifierType, IdentifierValueType
|
|
11
11
|
|
maleo/identity/mixins/patient.py
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
from pydantic import BaseModel, Field, model_validator
|
|
2
2
|
from typing import Annotated, Generic, Literal, Self, TypeGuard
|
|
3
3
|
from uuid import UUID
|
|
4
|
-
from
|
|
5
|
-
from
|
|
4
|
+
from nexo.schemas.mixins.identity import Identifier, Passport as BasePassport
|
|
5
|
+
from nexo.types.string import OptStr, OptStrT
|
|
6
6
|
from ..enums.patient import IdentifierType, OptListOfExpandableFields
|
|
7
7
|
from ..types.patient import IdentifierValueType
|
|
8
8
|
from .common import IdCard
|
maleo/identity/mixins/user.py
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
from pydantic import BaseModel, Field
|
|
2
2
|
from typing import Annotated, Generic, Literal, TypeGuard
|
|
3
3
|
from uuid import UUID
|
|
4
|
-
from
|
|
5
|
-
from
|
|
6
|
-
from ..enums.user import IdentifierType
|
|
4
|
+
from nexo.schemas.mixins.identity import Identifier
|
|
5
|
+
from nexo.types.string import OptStrT, OptListOfStrsT
|
|
6
|
+
from ..enums.user import IdentifierType, OptListOfExpandableFields
|
|
7
7
|
from ..types.user import IdentifierValueType
|
|
8
8
|
|
|
9
9
|
|
|
@@ -37,6 +37,12 @@ class Password(BaseModel):
|
|
|
37
37
|
password: Annotated[str, Field(..., description="Password", max_length=255)]
|
|
38
38
|
|
|
39
39
|
|
|
40
|
+
class Expand(BaseModel):
|
|
41
|
+
expand: Annotated[
|
|
42
|
+
OptListOfExpandableFields, Field(None, description="Expanded field(s)")
|
|
43
|
+
] = None
|
|
44
|
+
|
|
45
|
+
|
|
40
46
|
class UserIdentifier(Identifier[IdentifierType, IdentifierValueType]):
|
|
41
47
|
@property
|
|
42
48
|
def column_and_value(self) -> tuple[str, IdentifierValueType]:
|
|
@@ -1,13 +1,19 @@
|
|
|
1
|
-
from pydantic import Field
|
|
1
|
+
from pydantic import BaseModel, Field
|
|
2
2
|
from typing import Annotated, Literal, TypeGuard
|
|
3
3
|
from uuid import UUID
|
|
4
|
-
from
|
|
5
|
-
from
|
|
6
|
-
from
|
|
7
|
-
from ..enums.user_medical_role import IdentifierType
|
|
4
|
+
from nexo.schemas.mixins.identity import Identifier
|
|
5
|
+
from nexo.types.any import ManyAny
|
|
6
|
+
from nexo.types.string import ManyStrs
|
|
7
|
+
from ..enums.user_medical_role import IdentifierType, OptListOfExpandableFields
|
|
8
8
|
from ..types.user_medical_role import CompositeIdentifierType, IdentifierValueType
|
|
9
9
|
|
|
10
10
|
|
|
11
|
+
class Expand(BaseModel):
|
|
12
|
+
expand: Annotated[
|
|
13
|
+
OptListOfExpandableFields, Field(None, description="Expanded field(s)")
|
|
14
|
+
] = None
|
|
15
|
+
|
|
16
|
+
|
|
11
17
|
class UserMedicalRoleIdentifier(Identifier[IdentifierType, IdentifierValueType]):
|
|
12
18
|
@property
|
|
13
19
|
def columns_and_values(self) -> tuple[ManyStrs, ManyAny]:
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
from pydantic import BaseModel, Field
|
|
2
|
+
from typing import Annotated, Literal, TypeGuard
|
|
3
|
+
from uuid import UUID
|
|
4
|
+
from nexo.schemas.mixins.identity import Identifier
|
|
5
|
+
from nexo.types.any import ManyAny
|
|
6
|
+
from nexo.types.string import ManyStrs
|
|
7
|
+
from ..enums.user_organization import IdentifierType, OptListOfExpandableFields
|
|
8
|
+
from ..types.user_organization import CompositeIdentifierType, IdentifierValueType
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
class Expand(BaseModel):
|
|
12
|
+
expand: Annotated[
|
|
13
|
+
OptListOfExpandableFields, Field(None, description="Expanded field(s)")
|
|
14
|
+
] = None
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
class UserOrganizationIdentifier(Identifier[IdentifierType, IdentifierValueType]):
|
|
18
|
+
@property
|
|
19
|
+
def columns_and_values(self) -> tuple[ManyStrs, ManyAny]:
|
|
20
|
+
values = self.value if isinstance(self.value, tuple) else (self.value,)
|
|
21
|
+
return self.type.columns, values
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
class IdUserOrganizationIdentifier(Identifier[Literal[IdentifierType.ID], int]):
|
|
25
|
+
type: Annotated[
|
|
26
|
+
Literal[IdentifierType.ID],
|
|
27
|
+
Field(IdentifierType.ID, description="Identifier's type"),
|
|
28
|
+
] = IdentifierType.ID
|
|
29
|
+
value: Annotated[int, Field(..., description="Identifier's value", ge=1)]
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
class UUIDUserOrganizationIdentifier(Identifier[Literal[IdentifierType.UUID], UUID]):
|
|
33
|
+
type: Annotated[
|
|
34
|
+
Literal[IdentifierType.UUID],
|
|
35
|
+
Field(IdentifierType.UUID, description="Identifier's type"),
|
|
36
|
+
] = IdentifierType.UUID
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
class CompositeUserOrganizationIdentifier(
|
|
40
|
+
Identifier[Literal[IdentifierType.COMPOSITE], CompositeIdentifierType]
|
|
41
|
+
):
|
|
42
|
+
type: Annotated[
|
|
43
|
+
Literal[IdentifierType.COMPOSITE],
|
|
44
|
+
Field(IdentifierType.COMPOSITE, description="Identifier's type"),
|
|
45
|
+
] = IdentifierType.COMPOSITE
|
|
46
|
+
value: Annotated[
|
|
47
|
+
CompositeIdentifierType, Field(..., description="Identifier's value")
|
|
48
|
+
]
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
AnyUserOrganizationIdentifier = (
|
|
52
|
+
UserOrganizationIdentifier
|
|
53
|
+
| IdUserOrganizationIdentifier
|
|
54
|
+
| UUIDUserOrganizationIdentifier
|
|
55
|
+
| CompositeUserOrganizationIdentifier
|
|
56
|
+
)
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
def is_id_identifier(
|
|
60
|
+
identifier: AnyUserOrganizationIdentifier,
|
|
61
|
+
) -> TypeGuard[IdUserOrganizationIdentifier]:
|
|
62
|
+
return identifier.type is IdentifierType.ID and isinstance(identifier.value, int)
|
|
63
|
+
|
|
64
|
+
|
|
65
|
+
def is_uuid_identifier(
|
|
66
|
+
identifier: AnyUserOrganizationIdentifier,
|
|
67
|
+
) -> TypeGuard[UUIDUserOrganizationIdentifier]:
|
|
68
|
+
return identifier.type is IdentifierType.UUID and isinstance(identifier.value, UUID)
|
|
69
|
+
|
|
70
|
+
|
|
71
|
+
def is_composite_identifier(
|
|
72
|
+
identifier: AnyUserOrganizationIdentifier,
|
|
73
|
+
) -> TypeGuard[CompositeUserOrganizationIdentifier]:
|
|
74
|
+
return identifier.type is IdentifierType.COMPOSITE and isinstance(
|
|
75
|
+
identifier.value, tuple
|
|
76
|
+
)
|
|
@@ -1,13 +1,19 @@
|
|
|
1
|
-
from pydantic import Field
|
|
1
|
+
from pydantic import BaseModel, Field
|
|
2
2
|
from typing import Annotated, Literal, TypeGuard
|
|
3
3
|
from uuid import UUID
|
|
4
|
-
from
|
|
5
|
-
from
|
|
6
|
-
from
|
|
7
|
-
from ..enums.user_organization_role import IdentifierType
|
|
4
|
+
from nexo.schemas.mixins.identity import Identifier
|
|
5
|
+
from nexo.types.any import ManyAny
|
|
6
|
+
from nexo.types.string import ManyStrs
|
|
7
|
+
from ..enums.user_organization_role import IdentifierType, OptListOfExpandableFields
|
|
8
8
|
from ..types.user_organization_role import CompositeIdentifierType, IdentifierValueType
|
|
9
9
|
|
|
10
10
|
|
|
11
|
+
class Expand(BaseModel):
|
|
12
|
+
expand: Annotated[
|
|
13
|
+
OptListOfExpandableFields, Field(None, description="Expanded field(s)")
|
|
14
|
+
] = None
|
|
15
|
+
|
|
16
|
+
|
|
11
17
|
class UserOrganizationRoleIdentifier(Identifier[IdentifierType, IdentifierValueType]):
|
|
12
18
|
@property
|
|
13
19
|
def columns_and_values(self) -> tuple[ManyStrs, ManyAny]:
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
from pydantic import BaseModel, Field
|
|
2
2
|
from typing import Annotated, Generic, Literal, TypeGuard
|
|
3
3
|
from uuid import UUID
|
|
4
|
-
from
|
|
5
|
-
from
|
|
4
|
+
from nexo.schemas.mixins.identity import Identifier
|
|
5
|
+
from nexo.types.string import OptStrT
|
|
6
6
|
from ..enums.user_profile import IdentifierType, OptListOfExpandableFields
|
|
7
7
|
from ..types.user_profile import IdentifierValueType
|
|
8
8
|
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
from pydantic import BaseModel, Field
|
|
2
2
|
from typing import Annotated, Literal, TypeGuard
|
|
3
3
|
from uuid import UUID
|
|
4
|
-
from
|
|
5
|
-
from
|
|
6
|
-
from
|
|
4
|
+
from nexo.schemas.mixins.identity import Identifier
|
|
5
|
+
from nexo.types.any import ManyAny
|
|
6
|
+
from nexo.types.string import ManyStrs
|
|
7
7
|
from ..enums.user_system_role import IdentifierType, OptListOfExpandableFields
|
|
8
8
|
from ..types.user_system_role import CompositeIdentifierType, IdentifierValueType
|
|
9
9
|
|