maleo-identity 0.1.27__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.
Files changed (65) hide show
  1. maleo/identity/constants/api_key.py +1 -1
  2. maleo/identity/constants/organization.py +1 -1
  3. maleo/identity/constants/organization_registration_code.py +1 -1
  4. maleo/identity/constants/organization_relation.py +1 -1
  5. maleo/identity/constants/patient.py +1 -1
  6. maleo/identity/constants/user.py +1 -1
  7. maleo/identity/constants/user_medical_role.py +1 -1
  8. maleo/identity/constants/user_organization.py +13 -0
  9. maleo/identity/constants/user_organization_role.py +1 -1
  10. maleo/identity/constants/user_profile.py +16 -1
  11. maleo/identity/constants/user_system_role.py +2 -2
  12. maleo/identity/enums/api_key.py +1 -1
  13. maleo/identity/enums/organization.py +14 -10
  14. maleo/identity/enums/organization_registration_code.py +1 -1
  15. maleo/identity/enums/organization_relation.py +14 -1
  16. maleo/identity/enums/patient.py +1 -1
  17. maleo/identity/enums/user.py +16 -1
  18. maleo/identity/enums/user_medical_role.py +14 -1
  19. maleo/identity/enums/user_organization.py +40 -0
  20. maleo/identity/enums/user_organization_role.py +14 -1
  21. maleo/identity/enums/user_profile.py +1 -1
  22. maleo/identity/enums/user_system_role.py +1 -1
  23. maleo/identity/mixins/api_key.py +19 -3
  24. maleo/identity/mixins/common.py +2 -2
  25. maleo/identity/mixins/organization.py +10 -4
  26. maleo/identity/mixins/organization_registration_code.py +4 -4
  27. maleo/identity/mixins/organization_relation.py +12 -6
  28. maleo/identity/mixins/patient.py +2 -2
  29. maleo/identity/mixins/user.py +9 -3
  30. maleo/identity/mixins/user_medical_role.py +11 -5
  31. maleo/identity/mixins/user_organization.py +76 -0
  32. maleo/identity/mixins/user_organization_role.py +11 -5
  33. maleo/identity/mixins/user_profile.py +3 -5
  34. maleo/identity/mixins/user_system_role.py +3 -3
  35. maleo/identity/schemas/api_key.py +22 -8
  36. maleo/identity/schemas/common.py +33 -77
  37. maleo/identity/schemas/organization.py +59 -25
  38. maleo/identity/schemas/organization_registration_code.py +11 -11
  39. maleo/identity/schemas/organization_relation.py +81 -21
  40. maleo/identity/schemas/patient.py +12 -12
  41. maleo/identity/schemas/user.py +104 -22
  42. maleo/identity/schemas/user_medical_role.py +66 -16
  43. maleo/identity/schemas/user_organization.py +334 -0
  44. maleo/identity/schemas/user_organization_role.py +68 -16
  45. maleo/identity/schemas/user_profile.py +15 -26
  46. maleo/identity/schemas/user_system_role.py +10 -10
  47. maleo/identity/types/api_key.py +3 -2
  48. maleo/identity/types/organization.py +1 -1
  49. maleo/identity/types/organization_registration_code.py +1 -1
  50. maleo/identity/types/organization_relation.py +3 -3
  51. maleo/identity/types/user.py +1 -1
  52. maleo/identity/types/user_medical_role.py +3 -2
  53. maleo/identity/types/user_organization.py +7 -0
  54. maleo/identity/types/user_organization_role.py +3 -2
  55. maleo/identity/types/user_profile.py +1 -1
  56. maleo/identity/types/user_system_role.py +1 -1
  57. {maleo_identity-0.1.27.dist-info → maleo_identity-0.1.59.dist-info}/METADATA +10 -9
  58. maleo_identity-0.1.59.dist-info/RECORD +68 -0
  59. maleo/identity/utils/__init__.py +0 -0
  60. maleo/identity/utils/organization.py +0 -32
  61. maleo/identity/utils/user.py +0 -32
  62. maleo_identity-0.1.27.dist-info/RECORD +0 -66
  63. {maleo_identity-0.1.27.dist-info → maleo_identity-0.1.59.dist-info}/WHEEL +0 -0
  64. {maleo_identity-0.1.27.dist-info → maleo_identity-0.1.59.dist-info}/licenses/LICENSE +0 -0
  65. {maleo_identity-0.1.27.dist-info → maleo_identity-0.1.59.dist-info}/top_level.txt +0 -0
@@ -1,4 +1,4 @@
1
- from maleo.schemas.resource import Resource, ResourceIdentifier
1
+ from nexo.schemas.resource import Resource, ResourceIdentifier
2
2
 
3
3
 
4
4
  API_KEY_RESOURCE = Resource(
@@ -1,4 +1,4 @@
1
- from maleo.schemas.resource import Resource, ResourceIdentifier
1
+ from nexo.schemas.resource import Resource, ResourceIdentifier
2
2
 
3
3
 
4
4
  ORGANIZATION_RESOURCE = Resource(
@@ -1,4 +1,4 @@
1
- from maleo.schemas.resource import Resource, ResourceIdentifier
1
+ from nexo.schemas.resource import Resource, ResourceIdentifier
2
2
 
3
3
 
4
4
  ORGANIZATION_REGISTRATION_CODE_RESOURCE = Resource(
@@ -1,4 +1,4 @@
1
- from maleo.schemas.resource import Resource, ResourceIdentifier
1
+ from nexo.schemas.resource import Resource, ResourceIdentifier
2
2
 
3
3
 
4
4
  ORGANIZATION_RELATION_RESOURCE = Resource(
@@ -1,4 +1,4 @@
1
- from maleo.schemas.resource import Resource, ResourceIdentifier
1
+ from nexo.schemas.resource import Resource, ResourceIdentifier
2
2
 
3
3
 
4
4
  PATIENT_RESOURCE = Resource(
@@ -1,4 +1,4 @@
1
- from maleo.schemas.resource import Resource, ResourceIdentifier
1
+ from nexo.schemas.resource import Resource, ResourceIdentifier
2
2
 
3
3
 
4
4
  USER_RESOURCE = Resource(
@@ -1,4 +1,4 @@
1
- from maleo.schemas.resource import Resource, ResourceIdentifier
1
+ from nexo.schemas.resource import Resource, ResourceIdentifier
2
2
 
3
3
 
4
4
  USER_MEDICAL_ROLE_RESOURCE = Resource(
@@ -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
+ )
@@ -1,4 +1,4 @@
1
- from maleo.schemas.resource import Resource, ResourceIdentifier
1
+ from nexo.schemas.resource import Resource, ResourceIdentifier
2
2
 
3
3
 
4
4
  USER_ORGANIZATION_ROLE_RESOURCE = Resource(
@@ -1,4 +1,5 @@
1
- from maleo.schemas.resource import Resource, ResourceIdentifier
1
+ from nexo.schemas.resource import Resource, ResourceIdentifier
2
+ from nexo.types.string import SeqOfStrs
2
3
 
3
4
 
4
5
  USER_PROFILE_RESOURCE = Resource(
@@ -9,3 +10,17 @@ USER_PROFILE_RESOURCE = Resource(
9
10
  ],
10
11
  details=None,
11
12
  )
13
+
14
+
15
+ VALID_EXTENSIONS: SeqOfStrs = (
16
+ ".jpeg",
17
+ ".jpg",
18
+ ".png",
19
+ )
20
+
21
+
22
+ VALID_MIME_TYPES: SeqOfStrs = (
23
+ "image/jpeg",
24
+ "image/jpg",
25
+ "image/png",
26
+ )
@@ -1,5 +1,5 @@
1
- from maleo.schemas.resource import Resource, ResourceIdentifier
2
- from maleo.types.string import DoubleStrs
1
+ from nexo.schemas.resource import Resource, ResourceIdentifier
2
+ from nexo.types.string import DoubleStrs
3
3
 
4
4
 
5
5
  USER_SYSTEM_ROLE_RESOURCE = Resource(
@@ -1,5 +1,5 @@
1
1
  from enum import StrEnum
2
- from maleo.types.string import ListOfStrs, ManyStrs
2
+ from nexo.types.string import ListOfStrs, ManyStrs
3
3
 
4
4
 
5
5
  class IdentifierType(StrEnum):
@@ -1,14 +1,5 @@
1
1
  from enum import StrEnum
2
- from maleo.types.string import ListOfStrs
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
@@ -1,5 +1,5 @@
1
1
  from enum import StrEnum
2
- from maleo.types.string import ListOfStrs
2
+ from nexo.types.string import ListOfStrs
3
3
 
4
4
 
5
5
  class IdentifierType(StrEnum):
@@ -1,5 +1,5 @@
1
1
  from enum import StrEnum
2
- from maleo.types.string import ListOfStrs, ManyStrs
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 ("source_id", "target_id", "relation")
22
22
  raise ValueError(f"Unknown column(s) for identifier type: {self}")
23
+
24
+
25
+ class ExpandableField(StrEnum):
26
+ ORGANIZATION_TYPE = "organization_type"
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
@@ -1,5 +1,5 @@
1
1
  from enum import StrEnum
2
- from maleo.types.string import ListOfStrs
2
+ from nexo.types.string import ListOfStrs
3
3
 
4
4
 
5
5
  class IdentifierType(StrEnum):
@@ -1,5 +1,5 @@
1
1
  from enum import StrEnum
2
- from maleo.types.string import ListOfStrs
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 maleo.types.string import ListOfStrs, ManyStrs
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 maleo.types.string import ListOfStrs, ManyStrs
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
@@ -1,5 +1,5 @@
1
1
  from enum import StrEnum
2
- from maleo.types.string import ListOfStrs
2
+ from nexo.types.string import ListOfStrs
3
3
 
4
4
 
5
5
  class IdentifierType(StrEnum):
@@ -1,5 +1,5 @@
1
1
  from enum import StrEnum
2
- from maleo.types.string import ListOfStrs, ManyStrs
2
+ from nexo.types.string import ListOfStrs, ManyStrs
3
3
 
4
4
 
5
5
  class IdentifierType(StrEnum):
@@ -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 maleo.schemas.mixins.identity import Identifier
5
- from maleo.types.any import ManyAny
6
- from maleo.types.string import ManyStrs
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]:
@@ -1,12 +1,12 @@
1
1
  from pydantic import Field
2
2
  from typing import Annotated, Generic
3
- from maleo.schemas.mixins.identity import (
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 maleo.types.string import OptStrT
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 maleo.schemas.mixins.identity import Identifier, Key as BaseKey, Name as BaseName
5
- from maleo.types.string import OptStrT
6
- from maleo.types.uuid import OptUUIDT
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 maleo.schemas.mixins.identity import Identifier
5
- from maleo.types.integer import OptIntT
6
- from maleo.types.misc import OptIntOrStr
7
- from maleo.types.string import OptStrT
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,12 +1,12 @@
1
1
  from pydantic import BaseModel, Field
2
2
  from typing import Annotated, Generic, Literal, TypeGuard
3
3
  from uuid import UUID
4
- from maleo.schemas.mixins.identity import Identifier
5
- from maleo.types.any import ManyAny
6
- from maleo.types.boolean import OptBoolT
7
- from maleo.types.misc import OptListOfAnyOrStrToAnyDict
8
- from maleo.types.string import ManyStrs
9
- from ..enums.organization_relation import IdentifierType
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
+ from ..enums.organization_relation import IdentifierType, OptListOfExpandableFields
10
10
  from ..types.organization_relation import CompositeIdentifierType, IdentifierValueType
11
11
 
12
12
 
@@ -18,6 +18,12 @@ class Meta(BaseModel):
18
18
  meta: Annotated[OptListOfAnyOrStrToAnyDict, Field(None, description="Meta")] = None
19
19
 
20
20
 
21
+ class Expand(BaseModel):
22
+ expand: Annotated[
23
+ OptListOfExpandableFields, Field(None, description="Expanded field(s)")
24
+ ] = None
25
+
26
+
21
27
  class OrganizationRelationIdentifier(Identifier[IdentifierType, IdentifierValueType]):
22
28
  @property
23
29
  def columns_and_values(self) -> tuple[ManyStrs, ManyAny]:
@@ -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 maleo.schemas.mixins.identity import Identifier, Passport as BasePassport
5
- from maleo.types.string import OptStr, OptStrT
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
@@ -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 maleo.schemas.mixins.identity import Identifier
5
- from maleo.types.string import OptStrT, OptListOfStrsT
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 maleo.schemas.mixins.identity import Identifier
5
- from maleo.types.any import ManyAny
6
- from maleo.types.string import ManyStrs
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 maleo.schemas.mixins.identity import Identifier
5
- from maleo.types.any import ManyAny
6
- from maleo.types.string import ManyStrs
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 maleo.schemas.mixins.identity import Identifier
5
- from maleo.types.string import OptStr, OptStrT
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
 
@@ -39,9 +39,7 @@ class EndingTitle(BaseModel, Generic[OptStrT]):
39
39
 
40
40
  class Avatar(BaseModel):
41
41
  content: Annotated[bytes, Field(..., description="Avatar's content")]
42
- content_type: Annotated[
43
- OptStr, Field(None, description="Avatar's content type")
44
- ] = None
42
+ content_type: Annotated[str, Field(..., description="Avatar's content type")]
45
43
  filename: Annotated[str, Field(..., description="Avatar's filename")]
46
44
 
47
45
 
@@ -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 maleo.schemas.mixins.identity import Identifier
5
- from maleo.types.any import ManyAny
6
- from maleo.types.string import ManyStrs
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