maleo-identity 0.0.85__py3-none-any.whl → 0.1.24__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 (138) hide show
  1. maleo/identity/constants/api_key.py +13 -0
  2. maleo/identity/constants/organization.py +3 -10
  3. maleo/identity/constants/organization_registration_code.py +5 -17
  4. maleo/identity/constants/organization_relation.py +13 -0
  5. maleo/identity/constants/patient.py +7 -0
  6. maleo/identity/constants/user.py +3 -20
  7. maleo/identity/constants/user_medical_role.py +13 -0
  8. maleo/identity/constants/user_organization_role.py +5 -39
  9. maleo/identity/constants/user_profile.py +3 -21
  10. maleo/identity/constants/user_system_role.py +9 -8
  11. maleo/identity/enums/api_key.py +25 -0
  12. maleo/identity/enums/organization.py +16 -3
  13. maleo/identity/enums/organization_registration_code.py +9 -0
  14. maleo/identity/enums/organization_relation.py +22 -0
  15. maleo/identity/enums/patient.py +29 -0
  16. maleo/identity/enums/user.py +16 -7
  17. maleo/identity/enums/user_medical_role.py +22 -0
  18. maleo/identity/enums/user_organization_role.py +19 -12
  19. maleo/identity/enums/user_profile.py +7 -9
  20. maleo/identity/enums/user_system_role.py +30 -0
  21. maleo/identity/mixins/api_key.py +72 -0
  22. maleo/identity/mixins/common.py +29 -0
  23. maleo/identity/mixins/organization.py +68 -8
  24. maleo/identity/mixins/organization_registration_code.py +126 -9
  25. maleo/identity/mixins/organization_relation.py +80 -0
  26. maleo/identity/mixins/patient.py +65 -0
  27. maleo/identity/mixins/user.py +86 -24
  28. maleo/identity/mixins/user_medical_role.py +68 -0
  29. maleo/identity/mixins/user_organization_role.py +68 -4
  30. maleo/identity/mixins/user_profile.py +84 -53
  31. maleo/identity/mixins/user_system_role.py +72 -4
  32. maleo/identity/schemas/api_key.py +171 -0
  33. maleo/identity/schemas/common.py +335 -0
  34. maleo/identity/schemas/organization.py +311 -0
  35. maleo/identity/schemas/organization_registration_code.py +314 -0
  36. maleo/identity/schemas/organization_relation.py +315 -0
  37. maleo/identity/schemas/patient.py +349 -0
  38. maleo/identity/schemas/user.py +318 -0
  39. maleo/identity/schemas/user_medical_role.py +316 -0
  40. maleo/identity/schemas/user_organization_role.py +317 -0
  41. maleo/identity/schemas/user_profile.py +362 -0
  42. maleo/identity/schemas/user_system_role.py +339 -0
  43. maleo/identity/types/api_key.py +7 -0
  44. maleo/identity/types/organization.py +4 -0
  45. maleo/identity/types/organization_registration_code.py +4 -0
  46. maleo/identity/types/organization_relation.py +7 -0
  47. maleo/identity/types/patient.py +4 -0
  48. maleo/identity/types/user.py +4 -0
  49. maleo/identity/types/user_medical_role.py +7 -0
  50. maleo/identity/types/user_organization_role.py +7 -0
  51. maleo/identity/types/user_profile.py +4 -0
  52. maleo/identity/types/user_system_role.py +8 -0
  53. maleo/identity/utils/organization.py +32 -0
  54. maleo/identity/utils/user.py +32 -0
  55. maleo_identity-0.1.24.dist-info/METADATA +119 -0
  56. maleo_identity-0.1.24.dist-info/RECORD +66 -0
  57. maleo_identity-0.1.24.dist-info/licenses/LICENSE +57 -0
  58. maleo/identity/client/manager.py +0 -157
  59. maleo/identity/client/services/__init__.py +0 -0
  60. maleo/identity/client/services/organization.py +0 -1944
  61. maleo/identity/client/services/organization_registration_code.py +0 -470
  62. maleo/identity/client/services/organization_role.py +0 -276
  63. maleo/identity/client/services/user.py +0 -1559
  64. maleo/identity/client/services/user_organization.py +0 -276
  65. maleo/identity/client/services/user_organization_role.py +0 -278
  66. maleo/identity/client/services/user_profile.py +0 -276
  67. maleo/identity/client/services/user_system_role.py +0 -276
  68. maleo/identity/constants/organization_role.py +0 -35
  69. maleo/identity/constants/user_organization.py +0 -58
  70. maleo/identity/db.py +0 -4
  71. maleo/identity/dtos/__init__.py +0 -0
  72. maleo/identity/dtos/configuration.py +0 -15
  73. maleo/identity/dtos/data/__init__.py +0 -0
  74. maleo/identity/dtos/data/organization_registration_code.py +0 -15
  75. maleo/identity/dtos/data/user_profile.py +0 -29
  76. maleo/identity/dtos/settings.py +0 -17
  77. maleo/identity/enums/general.py +0 -5
  78. maleo/identity/enums/organization_role.py +0 -7
  79. maleo/identity/enums/user_organization.py +0 -14
  80. maleo/identity/mixins/organization_role.py +0 -15
  81. maleo/identity/mixins/user_organization.py +0 -6
  82. maleo/identity/models/__init__.py +0 -0
  83. maleo/identity/models/organization.py +0 -62
  84. maleo/identity/models/organization_registration_code.py +0 -33
  85. maleo/identity/models/organization_role.py +0 -37
  86. maleo/identity/models/user.py +0 -39
  87. maleo/identity/models/user_organization.py +0 -48
  88. maleo/identity/models/user_organization_role.py +0 -61
  89. maleo/identity/models/user_profile.py +0 -33
  90. maleo/identity/models/user_system_role.py +0 -26
  91. maleo/identity/schemas/data/__init__.py +0 -0
  92. maleo/identity/schemas/data/organization.py +0 -36
  93. maleo/identity/schemas/data/organization_registration_code.py +0 -27
  94. maleo/identity/schemas/data/organization_role.py +0 -32
  95. maleo/identity/schemas/data/user.py +0 -33
  96. maleo/identity/schemas/data/user_organization.py +0 -23
  97. maleo/identity/schemas/data/user_organization_role.py +0 -13
  98. maleo/identity/schemas/data/user_profile.py +0 -59
  99. maleo/identity/schemas/data/user_system_role.py +0 -25
  100. maleo/identity/schemas/metadata/__init__.py +0 -0
  101. maleo/identity/schemas/metadata/user.py +0 -6
  102. maleo/identity/schemas/parameter/__init__.py +0 -0
  103. maleo/identity/schemas/parameter/client/__init__.py +0 -0
  104. maleo/identity/schemas/parameter/client/organization.py +0 -74
  105. maleo/identity/schemas/parameter/client/organization_registration_code.py +0 -24
  106. maleo/identity/schemas/parameter/client/organization_role.py +0 -42
  107. maleo/identity/schemas/parameter/client/user.py +0 -44
  108. maleo/identity/schemas/parameter/client/user_organization.py +0 -62
  109. maleo/identity/schemas/parameter/client/user_organization_role.py +0 -49
  110. maleo/identity/schemas/parameter/client/user_profile.py +0 -28
  111. maleo/identity/schemas/parameter/client/user_system_role.py +0 -43
  112. maleo/identity/schemas/parameter/general/__init__.py +0 -0
  113. maleo/identity/schemas/parameter/general/organization.py +0 -43
  114. maleo/identity/schemas/parameter/general/organization_registration_code.py +0 -54
  115. maleo/identity/schemas/parameter/general/organization_role.py +0 -14
  116. maleo/identity/schemas/parameter/general/user.py +0 -101
  117. maleo/identity/schemas/parameter/general/user_organization.py +0 -18
  118. maleo/identity/schemas/parameter/general/user_organization_role.py +0 -15
  119. maleo/identity/schemas/parameter/general/user_profile.py +0 -70
  120. maleo/identity/schemas/parameter/general/user_system_role.py +0 -30
  121. maleo/identity/schemas/parameter/service/__init__.py +0 -0
  122. maleo/identity/schemas/parameter/service/organization.py +0 -60
  123. maleo/identity/schemas/parameter/service/organization_registration_code.py +0 -24
  124. maleo/identity/schemas/parameter/service/organization_role.py +0 -35
  125. maleo/identity/schemas/parameter/service/user.py +0 -47
  126. maleo/identity/schemas/parameter/service/user_organization_role.py +0 -36
  127. maleo/identity/schemas/parameter/service/user_profile.py +0 -28
  128. maleo/identity/schemas/parameter/service/user_system_role.py +0 -31
  129. maleo/identity/types/base/__init__.py +0 -0
  130. maleo/identity/types/base/organization.py +0 -5
  131. maleo/identity/types/base/organization_registration_code.py +0 -4
  132. maleo/identity/types/base/user.py +0 -5
  133. maleo/identity/types/base/user_profile.py +0 -5
  134. maleo_identity-0.0.85.dist-info/METADATA +0 -40
  135. maleo_identity-0.0.85.dist-info/RECORD +0 -105
  136. /maleo/identity/{client → utils}/__init__.py +0 -0
  137. {maleo_identity-0.0.85.dist-info → maleo_identity-0.1.24.dist-info}/WHEEL +0 -0
  138. {maleo_identity-0.0.85.dist-info → maleo_identity-0.1.24.dist-info}/top_level.txt +0 -0
@@ -0,0 +1,13 @@
1
+ from maleo.schemas.resource import Resource, ResourceIdentifier
2
+
3
+
4
+ API_KEY_RESOURCE = Resource(
5
+ identifiers=[
6
+ ResourceIdentifier(
7
+ key="api_key",
8
+ name="API Key",
9
+ slug="api-keys",
10
+ )
11
+ ],
12
+ details=None,
13
+ )
@@ -1,17 +1,10 @@
1
- from typing import Callable, Dict
2
- from uuid import UUID
3
- from maleo.soma.schemas.resource import Resource, ResourceIdentifier
4
- from maleo.identity.enums.organization import IdentifierType
5
- from maleo.identity.types.base.organization import IdentifierValueType
1
+ from maleo.schemas.resource import Resource, ResourceIdentifier
6
2
 
7
- IDENTIFIER_TYPE_VALUE_TYPE_MAP: Dict[
8
- IdentifierType, Callable[..., IdentifierValueType]
9
- ] = {IdentifierType.ID: int, IdentifierType.UUID: UUID, IdentifierType.KEY: str}
10
3
 
11
- RESOURCE = Resource(
4
+ ORGANIZATION_RESOURCE = Resource(
12
5
  identifiers=[
13
6
  ResourceIdentifier(
14
- key="organizations", name="Organizations", url_slug="organizations"
7
+ key="organization", name="Organization", slug="organizations"
15
8
  )
16
9
  ],
17
10
  details=None,
@@ -1,24 +1,12 @@
1
- from typing import Callable, Dict
2
- from uuid import UUID
3
- from maleo.soma.schemas.resource import Resource, ResourceIdentifier
4
- from maleo.identity.enums.organization_registration_code import IdentifierType
5
- from maleo.identity.types.base.organization_registration_code import IdentifierValueType
1
+ from maleo.schemas.resource import Resource, ResourceIdentifier
6
2
 
7
- IDENTIFIER_TYPE_VALUE_TYPE_MAP: Dict[
8
- IdentifierType, Callable[..., IdentifierValueType]
9
- ] = {
10
- IdentifierType.ID: int,
11
- IdentifierType.UUID: UUID,
12
- IdentifierType.ORGANIZATION_ID: int,
13
- IdentifierType.CODE: UUID,
14
- }
15
3
 
16
- RESOURCE = Resource(
4
+ ORGANIZATION_REGISTRATION_CODE_RESOURCE = Resource(
17
5
  identifiers=[
18
6
  ResourceIdentifier(
19
- key="organization_registration_codes",
20
- name="Organization Registration Codes",
21
- url_slug="organization-registration-codes",
7
+ key="organization_registration_code",
8
+ name="Organization Registration Code",
9
+ slug="organization-registration-codes",
22
10
  )
23
11
  ],
24
12
  details=None,
@@ -0,0 +1,13 @@
1
+ from maleo.schemas.resource import Resource, ResourceIdentifier
2
+
3
+
4
+ ORGANIZATION_RELATION_RESOURCE = Resource(
5
+ identifiers=[
6
+ ResourceIdentifier(
7
+ key="organization_relation",
8
+ name="Organization Relation",
9
+ slug="organization-relations",
10
+ )
11
+ ],
12
+ details=None,
13
+ )
@@ -0,0 +1,7 @@
1
+ from maleo.schemas.resource import Resource, ResourceIdentifier
2
+
3
+
4
+ PATIENT_RESOURCE = Resource(
5
+ identifiers=[ResourceIdentifier(key="patient", name="Patient", slug="patients")],
6
+ details=None,
7
+ )
@@ -1,24 +1,7 @@
1
- from typing import Callable, Dict, List
2
- from uuid import UUID
3
- from maleo.soma.schemas.resource import Resource, ResourceIdentifier
4
- from maleo.identity.enums.user import IdentifierType, ExpandableField
5
- from maleo.identity.types.base.user import IdentifierValueType
1
+ from maleo.schemas.resource import Resource, ResourceIdentifier
6
2
 
7
- IDENTIFIER_TYPE_VALUE_TYPE_MAP: Dict[
8
- IdentifierType, Callable[..., IdentifierValueType]
9
- ] = {
10
- IdentifierType.ID: int,
11
- IdentifierType.UUID: UUID,
12
- IdentifierType.USERNAME: str,
13
- IdentifierType.EMAIL: str,
14
- }
15
3
 
16
- EXPANDABLE_FIELDS_DEPENDENCIES_MAP: Dict[ExpandableField, List[ExpandableField]] = {
17
- ExpandableField.PROFILE: [ExpandableField.GENDER, ExpandableField.BLOOD_TYPE],
18
- ExpandableField.SYSTEM_ROLES: [ExpandableField.SYSTEM_ROLE_DETAILS],
19
- }
20
-
21
- RESOURCE = Resource(
22
- identifiers=[ResourceIdentifier(key="users", name="Users", url_slug="users")],
4
+ USER_RESOURCE = Resource(
5
+ identifiers=[ResourceIdentifier(key="user", name="User", slug="users")],
23
6
  details=None,
24
7
  )
@@ -0,0 +1,13 @@
1
+ from maleo.schemas.resource import Resource, ResourceIdentifier
2
+
3
+
4
+ USER_MEDICAL_ROLE_RESOURCE = Resource(
5
+ identifiers=[
6
+ ResourceIdentifier(
7
+ key="user_medical_role",
8
+ name="User Medical Role",
9
+ slug="user-medical-roles",
10
+ )
11
+ ],
12
+ details=None,
13
+ )
@@ -1,46 +1,12 @@
1
- from typing import Dict, List
2
- from maleo.soma.schemas.resource import Resource, ResourceIdentifier
3
- from maleo.identity.enums.user import ExpandableField as UserExpandableField
4
- from maleo.identity.enums.organization import (
5
- ExpandableField as OrganizationExpandableField,
6
- )
7
- from maleo.identity.enums.user_organization_role import (
8
- ExpandableField as UserOrganizationRoleExpandableField,
9
- )
10
-
11
- EXPANDABLE_FIELDS_DEPENDENCIES_MAP: Dict[
12
- UserOrganizationRoleExpandableField, List[UserOrganizationRoleExpandableField]
13
- ] = {
14
- UserOrganizationRoleExpandableField.USER: [
15
- UserOrganizationRoleExpandableField.USER_TYPE,
16
- UserOrganizationRoleExpandableField.PROFILE,
17
- ],
18
- UserOrganizationRoleExpandableField.ORGANIZATION: [
19
- UserOrganizationRoleExpandableField.ORGANIZATION_TYPE,
20
- UserOrganizationRoleExpandableField.REGISTRATION_CODE,
21
- ],
22
- }
23
-
24
- USER_EXPANDABLE_FIELDS_MAP: Dict[
25
- UserOrganizationRoleExpandableField, UserExpandableField
26
- ] = {
27
- UserOrganizationRoleExpandableField.USER_TYPE: UserExpandableField.USER_TYPE,
28
- UserOrganizationRoleExpandableField.PROFILE: UserExpandableField.PROFILE,
29
- }
1
+ from maleo.schemas.resource import Resource, ResourceIdentifier
30
2
 
31
- ORGANIZATION_EXPANDABLE_FIELDS_MAP: Dict[
32
- UserOrganizationRoleExpandableField, OrganizationExpandableField
33
- ] = {
34
- UserOrganizationRoleExpandableField.ORGANIZATION_TYPE: OrganizationExpandableField.ORGANIZATION_TYPE,
35
- UserOrganizationRoleExpandableField.REGISTRATION_CODE: OrganizationExpandableField.REGISTRATION_CODE,
36
- }
37
3
 
38
- RESOURCE = Resource(
4
+ USER_ORGANIZATION_ROLE_RESOURCE = Resource(
39
5
  identifiers=[
40
6
  ResourceIdentifier(
41
- key="user_organization_roles",
42
- name="UserOrganization Roles",
43
- url_slug="user-organization-roles",
7
+ key="user_organization_role",
8
+ name="User Organization Role",
9
+ slug="user-organization-roles",
44
10
  )
45
11
  ],
46
12
  details=None,
@@ -1,28 +1,10 @@
1
- from typing import Callable, Dict
2
- from uuid import UUID
3
- from maleo.soma.schemas.resource import Resource, ResourceIdentifier
4
- from maleo.identity.enums.user_profile import IdentifierType, ValidImageMimeType
5
- from maleo.identity.types.base.user_profile import IdentifierValueType
1
+ from maleo.schemas.resource import Resource, ResourceIdentifier
6
2
 
7
- IDENTIFIER_TYPE_VALUE_TYPE_MAP: Dict[
8
- IdentifierType, Callable[..., IdentifierValueType]
9
- ] = {
10
- IdentifierType.ID: int,
11
- IdentifierType.UUID: UUID,
12
- IdentifierType.USER_ID: int,
13
- IdentifierType.ID_CARD: str,
14
- }
15
3
 
16
- MIME_TYPE_EXTENSION_MAP: Dict[ValidImageMimeType, str] = {
17
- ValidImageMimeType.JPEG: ".jpeg",
18
- ValidImageMimeType.JPG: ".jpg",
19
- ValidImageMimeType.PNG: ".png",
20
- }
21
-
22
- RESOURCE = Resource(
4
+ USER_PROFILE_RESOURCE = Resource(
23
5
  identifiers=[
24
6
  ResourceIdentifier(
25
- key="user_profiles", name="User Profiles", url_slug="user-profiles"
7
+ key="user_profile", name="User Profile", slug="user-profiles"
26
8
  )
27
9
  ],
28
10
  details=None,
@@ -1,16 +1,17 @@
1
- from typing import Dict, List
2
- from maleo.soma.schemas.resource import Resource, ResourceIdentifier
3
- from maleo.identity.enums.user_system_role import ExpandableField
1
+ from maleo.schemas.resource import Resource, ResourceIdentifier
2
+ from maleo.types.string import DoubleStrs
4
3
 
5
- EXPANDABLE_FIELDS_DEPENDENCIES_MAP: Dict[ExpandableField, List[ExpandableField]] = {}
6
4
 
7
- RESOURCE = Resource(
5
+ USER_SYSTEM_ROLE_RESOURCE = Resource(
8
6
  identifiers=[
9
7
  ResourceIdentifier(
10
- key="user_system_roles",
11
- name="User System Roles",
12
- url_slug="user-system-roles",
8
+ key="user_system_role",
9
+ name="User System Role",
10
+ slug="user-system-roles",
13
11
  )
14
12
  ],
15
13
  details=None,
16
14
  )
15
+
16
+
17
+ COMPOSITE_COLUMS: DoubleStrs = ("user_id", "system_role")
@@ -0,0 +1,25 @@
1
+ from enum import StrEnum
2
+ from maleo.types.string import ListOfStrs, ManyStrs
3
+
4
+
5
+ class IdentifierType(StrEnum):
6
+ ID = "id"
7
+ UUID = "uuid"
8
+ API_KEY = "api_key"
9
+ COMPOSITE = "composite"
10
+
11
+ @classmethod
12
+ def choices(cls) -> ListOfStrs:
13
+ return [e.value for e in cls]
14
+
15
+ @property
16
+ def columns(self) -> ManyStrs:
17
+ if self is IdentifierType.ID:
18
+ return ("id",)
19
+ elif self is IdentifierType.UUID:
20
+ return ("uuid",)
21
+ elif self is IdentifierType.API_KEY:
22
+ return ("api_key",)
23
+ elif self is IdentifierType.COMPOSITE:
24
+ return ("user_id", "organization_id")
25
+ raise ValueError(f"Unknown column(s) for identifier type: {self}")
@@ -1,4 +1,14 @@
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
12
 
3
13
 
4
14
  class IdentifierType(StrEnum):
@@ -6,7 +16,10 @@ class IdentifierType(StrEnum):
6
16
  UUID = "uuid"
7
17
  KEY = "key"
8
18
 
19
+ @classmethod
20
+ def choices(cls) -> ListOfStrs:
21
+ return [e.value for e in cls]
9
22
 
10
- class ExpandableField(StrEnum):
11
- ORGANIZATION_TYPE = "organization_type"
12
- REGISTRATION_CODE = "registration_code"
23
+ @property
24
+ def column(self) -> str:
25
+ return self.value
@@ -1,4 +1,5 @@
1
1
  from enum import StrEnum
2
+ from maleo.types.string import ListOfStrs
2
3
 
3
4
 
4
5
  class IdentifierType(StrEnum):
@@ -6,3 +7,11 @@ class IdentifierType(StrEnum):
6
7
  UUID = "uuid"
7
8
  ORGANIZATION_ID = "organization_id"
8
9
  CODE = "code"
10
+
11
+ @classmethod
12
+ def choices(cls) -> ListOfStrs:
13
+ return [e.value for e in cls]
14
+
15
+ @property
16
+ def column(self) -> str:
17
+ return self.value
@@ -0,0 +1,22 @@
1
+ from enum import StrEnum
2
+ from maleo.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 ("source_id", "target_id", "relation")
22
+ raise ValueError(f"Unknown column(s) for identifier type: {self}")
@@ -0,0 +1,29 @@
1
+ from enum import StrEnum
2
+ from maleo.types.string import ListOfStrs
3
+
4
+
5
+ class IdentifierType(StrEnum):
6
+ ID = "id"
7
+ UUID = "uuid"
8
+
9
+ @classmethod
10
+ def choices(cls) -> ListOfStrs:
11
+ return [e.value for e in cls]
12
+
13
+ @property
14
+ def column(self) -> str:
15
+ return self.value
16
+
17
+
18
+ class ExpandableField(StrEnum):
19
+ GENDER = "gender"
20
+ BLOOD_TYPE = "blood_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,4 +1,14 @@
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
12
 
3
13
 
4
14
  class IdentifierType(StrEnum):
@@ -7,11 +17,10 @@ class IdentifierType(StrEnum):
7
17
  USERNAME = "username"
8
18
  EMAIL = "email"
9
19
 
20
+ @classmethod
21
+ def choices(cls) -> ListOfStrs:
22
+ return [e.value for e in cls]
10
23
 
11
- class ExpandableField(StrEnum):
12
- USER_TYPE = "user_type"
13
- SYSTEM_ROLES = "system_roles"
14
- SYSTEM_ROLE_DETAILS = "system_roles.system_role_details"
15
- PROFILE = "profile"
16
- GENDER = "profile.gender"
17
- BLOOD_TYPE = "profile.blood_type"
24
+ @property
25
+ def column(self) -> str:
26
+ return self.value
@@ -0,0 +1,22 @@
1
+ from enum import StrEnum
2
+ from maleo.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", "medical_role")
22
+ raise ValueError(f"Unknown column(s) for identifier type: {self}")
@@ -1,15 +1,22 @@
1
1
  from enum import StrEnum
2
+ from maleo.types.string import ListOfStrs, ManyStrs
2
3
 
3
4
 
4
- class ExpandableField(StrEnum):
5
- USER = "user"
6
- USER_TYPE = "user.user_type"
7
- SYSTEM_ROLES = "system_roles"
8
- SYSTEM_ROLE_DETAILS = "system_roles.system_role_details"
9
- PROFILE = "user.profile"
10
- GENDER = "profile.gender"
11
- BLOOD_TYPE = "profile.blood_type"
12
- ORGANIZATION = "organization"
13
- ORGANIZATION_TYPE = "organization.organization_type"
14
- REGISTRATION_CODE = "organization.registration_code"
15
- USER_ORGANIZATION = "user_organization"
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", "organization_role")
22
+ raise ValueError(f"Unknown column(s) for identifier type: {self}")
@@ -1,4 +1,5 @@
1
1
  from enum import StrEnum
2
+ from maleo.types.string import ListOfStrs
2
3
 
3
4
 
4
5
  class IdentifierType(StrEnum):
@@ -7,13 +8,10 @@ class IdentifierType(StrEnum):
7
8
  USER_ID = "user_id"
8
9
  ID_CARD = "id_card"
9
10
 
11
+ @classmethod
12
+ def choices(cls) -> ListOfStrs:
13
+ return [e.value for e in cls]
10
14
 
11
- class ValidImageMimeType(StrEnum):
12
- JPEG = "image/jpeg"
13
- JPG = "image/jpg"
14
- PNG = "image/png"
15
-
16
-
17
- class ExpandableField(StrEnum):
18
- GENDER = "gender"
19
- BLOOD_TYPE = "blood_type"
15
+ @property
16
+ def column(self) -> str:
17
+ return self.value
@@ -1,5 +1,35 @@
1
1
  from enum import StrEnum
2
+ from maleo.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", "system_role")
22
+ raise ValueError(f"Unknown column(s) for identifier type: {self}")
2
23
 
3
24
 
4
25
  class ExpandableField(StrEnum):
5
26
  SYSTEM_ROLE = "system_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,72 @@
1
+ from pydantic import BaseModel, Field
2
+ from typing import Annotated, Literal, TypeGuard
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.api_key import IdentifierType
8
+ from ..types.api_key import CompositeIdentifierType, IdentifierValueType
9
+
10
+
11
+ class APIKey(BaseModel):
12
+ api_key: Annotated[str, Field(..., description="API Key", max_length=255)]
13
+
14
+
15
+ class APIKeyIdentifier(Identifier[IdentifierType, IdentifierValueType]):
16
+ @property
17
+ def columns_and_values(self) -> tuple[ManyStrs, ManyAny]:
18
+ values = self.value if isinstance(self.value, tuple) else (self.value,)
19
+ return self.type.columns, values
20
+
21
+
22
+ class IdAPIKeyIdentifier(Identifier[Literal[IdentifierType.ID], int]):
23
+ type: Annotated[
24
+ Literal[IdentifierType.ID],
25
+ Field(IdentifierType.ID, description="Identifier's type"),
26
+ ] = IdentifierType.ID
27
+ value: Annotated[int, Field(..., description="Identifier's value", ge=1)]
28
+
29
+
30
+ class UUIDAPIKeyIdentifier(Identifier[Literal[IdentifierType.UUID], UUID]):
31
+ type: Annotated[
32
+ Literal[IdentifierType.UUID],
33
+ Field(IdentifierType.UUID, description="Identifier's type"),
34
+ ] = IdentifierType.UUID
35
+
36
+
37
+ class CompositeAPIKeyIdentifier(
38
+ Identifier[Literal[IdentifierType.COMPOSITE], CompositeIdentifierType]
39
+ ):
40
+ type: Annotated[
41
+ Literal[IdentifierType.COMPOSITE],
42
+ Field(IdentifierType.COMPOSITE, description="Identifier's type"),
43
+ ] = IdentifierType.COMPOSITE
44
+ value: Annotated[CompositeIdentifierType, Field(..., description="Identifier's value")]
45
+
46
+
47
+ AnyAPIKeyIdentifier = (
48
+ APIKeyIdentifier
49
+ | IdAPIKeyIdentifier
50
+ | UUIDAPIKeyIdentifier
51
+ | CompositeAPIKeyIdentifier
52
+ )
53
+
54
+
55
+ def is_id_identifier(
56
+ identifier: AnyAPIKeyIdentifier,
57
+ ) -> TypeGuard[IdAPIKeyIdentifier]:
58
+ return identifier.type is IdentifierType.ID and isinstance(identifier.value, int)
59
+
60
+
61
+ def is_uuid_identifier(
62
+ identifier: AnyAPIKeyIdentifier,
63
+ ) -> TypeGuard[UUIDAPIKeyIdentifier]:
64
+ return identifier.type is IdentifierType.UUID and isinstance(identifier.value, UUID)
65
+
66
+
67
+ def is_composite_identifier(
68
+ identifier: AnyAPIKeyIdentifier,
69
+ ) -> TypeGuard[CompositeAPIKeyIdentifier]:
70
+ return identifier.type is IdentifierType.COMPOSITE and isinstance(
71
+ identifier.value, tuple
72
+ )
@@ -0,0 +1,29 @@
1
+ from pydantic import Field
2
+ from typing import Annotated, Generic
3
+ from maleo.schemas.mixins.identity import (
4
+ IdCard as BaseIdCard,
5
+ FullName as BaseFullName,
6
+ BirthPlace as BaseBirthPlace,
7
+ PlaceOfBirth as BasePlaceOfBirth,
8
+ )
9
+ from maleo.types.string import OptStrT
10
+
11
+
12
+ class IdCard(BaseIdCard[OptStrT], Generic[OptStrT]):
13
+ id_card: Annotated[OptStrT, Field(..., description="Id Card", max_length=16)]
14
+
15
+
16
+ class FullName(BaseFullName[OptStrT], Generic[OptStrT]):
17
+ full_name: Annotated[OptStrT, Field(..., description="Full Name", max_length=200)]
18
+
19
+
20
+ class BirthPlace(BaseBirthPlace[OptStrT], Generic[OptStrT]):
21
+ birth_place: Annotated[
22
+ OptStrT, Field(..., description="Birth Place", max_length=50)
23
+ ]
24
+
25
+
26
+ class PlaceOfBirth(BasePlaceOfBirth[OptStrT], Generic[OptStrT]):
27
+ place_of_birth: Annotated[
28
+ OptStrT, Field(..., description="Place of Birth", max_length=50)
29
+ ]