maleo-identity 0.1.45__tar.gz → 0.1.60__tar.gz

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 (75) hide show
  1. {maleo_identity-0.1.45 → maleo_identity-0.1.60}/PKG-INFO +9 -9
  2. {maleo_identity-0.1.45 → maleo_identity-0.1.60}/maleo_identity.egg-info/PKG-INFO +9 -9
  3. {maleo_identity-0.1.45 → maleo_identity-0.1.60}/maleo_identity.egg-info/SOURCES.txt +6 -3
  4. {maleo_identity-0.1.45 → maleo_identity-0.1.60}/maleo_identity.egg-info/requires.txt +8 -8
  5. {maleo_identity-0.1.45 → maleo_identity-0.1.60}/pyproject.toml +10 -13
  6. maleo_identity-0.1.60/src/constants/user_organization.py +13 -0
  7. {maleo_identity-0.1.45 → maleo_identity-0.1.60}/src/enums/organization.py +13 -9
  8. maleo_identity-0.1.60/src/enums/user_organization.py +40 -0
  9. {maleo_identity-0.1.45 → maleo_identity-0.1.60}/src/mixins/organization.py +7 -1
  10. maleo_identity-0.1.60/src/mixins/user_organization.py +76 -0
  11. {maleo_identity-0.1.45 → maleo_identity-0.1.60}/src/schemas/common.py +9 -31
  12. {maleo_identity-0.1.45 → maleo_identity-0.1.60}/src/schemas/organization.py +48 -14
  13. {maleo_identity-0.1.45 → maleo_identity-0.1.60}/src/schemas/user.py +64 -10
  14. {maleo_identity-0.1.45 → maleo_identity-0.1.60}/src/schemas/user_medical_role.py +14 -2
  15. maleo_identity-0.1.60/src/schemas/user_organization.py +334 -0
  16. {maleo_identity-0.1.45 → maleo_identity-0.1.60}/src/schemas/user_organization_role.py +14 -2
  17. maleo_identity-0.1.60/src/types/user_organization.py +7 -0
  18. maleo_identity-0.1.45/src/utils/__init__.py +0 -0
  19. maleo_identity-0.1.45/src/utils/organization.py +0 -32
  20. {maleo_identity-0.1.45 → maleo_identity-0.1.60}/LICENSE +0 -0
  21. {maleo_identity-0.1.45 → maleo_identity-0.1.60}/README.md +0 -0
  22. {maleo_identity-0.1.45 → maleo_identity-0.1.60}/maleo_identity.egg-info/dependency_links.txt +0 -0
  23. {maleo_identity-0.1.45 → maleo_identity-0.1.60}/maleo_identity.egg-info/top_level.txt +0 -0
  24. {maleo_identity-0.1.45 → maleo_identity-0.1.60}/setup.cfg +0 -0
  25. {maleo_identity-0.1.45 → maleo_identity-0.1.60}/src/__init__.py +0 -0
  26. {maleo_identity-0.1.45 → maleo_identity-0.1.60}/src/constants/__init__.py +0 -0
  27. {maleo_identity-0.1.45 → maleo_identity-0.1.60}/src/constants/api_key.py +0 -0
  28. {maleo_identity-0.1.45 → maleo_identity-0.1.60}/src/constants/organization.py +0 -0
  29. {maleo_identity-0.1.45 → maleo_identity-0.1.60}/src/constants/organization_registration_code.py +0 -0
  30. {maleo_identity-0.1.45 → maleo_identity-0.1.60}/src/constants/organization_relation.py +0 -0
  31. {maleo_identity-0.1.45 → maleo_identity-0.1.60}/src/constants/patient.py +0 -0
  32. {maleo_identity-0.1.45 → maleo_identity-0.1.60}/src/constants/user.py +0 -0
  33. {maleo_identity-0.1.45 → maleo_identity-0.1.60}/src/constants/user_medical_role.py +0 -0
  34. {maleo_identity-0.1.45 → maleo_identity-0.1.60}/src/constants/user_organization_role.py +0 -0
  35. {maleo_identity-0.1.45 → maleo_identity-0.1.60}/src/constants/user_profile.py +0 -0
  36. {maleo_identity-0.1.45 → maleo_identity-0.1.60}/src/constants/user_system_role.py +0 -0
  37. {maleo_identity-0.1.45 → maleo_identity-0.1.60}/src/enums/__init__.py +0 -0
  38. {maleo_identity-0.1.45 → maleo_identity-0.1.60}/src/enums/api_key.py +0 -0
  39. {maleo_identity-0.1.45 → maleo_identity-0.1.60}/src/enums/organization_registration_code.py +0 -0
  40. {maleo_identity-0.1.45 → maleo_identity-0.1.60}/src/enums/organization_relation.py +0 -0
  41. {maleo_identity-0.1.45 → maleo_identity-0.1.60}/src/enums/patient.py +0 -0
  42. {maleo_identity-0.1.45 → maleo_identity-0.1.60}/src/enums/user.py +0 -0
  43. {maleo_identity-0.1.45 → maleo_identity-0.1.60}/src/enums/user_medical_role.py +0 -0
  44. {maleo_identity-0.1.45 → maleo_identity-0.1.60}/src/enums/user_organization_role.py +0 -0
  45. {maleo_identity-0.1.45 → maleo_identity-0.1.60}/src/enums/user_profile.py +0 -0
  46. {maleo_identity-0.1.45 → maleo_identity-0.1.60}/src/enums/user_system_role.py +0 -0
  47. {maleo_identity-0.1.45 → maleo_identity-0.1.60}/src/mixins/__init__.py +0 -0
  48. {maleo_identity-0.1.45 → maleo_identity-0.1.60}/src/mixins/api_key.py +0 -0
  49. {maleo_identity-0.1.45 → maleo_identity-0.1.60}/src/mixins/common.py +0 -0
  50. {maleo_identity-0.1.45 → maleo_identity-0.1.60}/src/mixins/organization_registration_code.py +0 -0
  51. {maleo_identity-0.1.45 → maleo_identity-0.1.60}/src/mixins/organization_relation.py +0 -0
  52. {maleo_identity-0.1.45 → maleo_identity-0.1.60}/src/mixins/patient.py +0 -0
  53. {maleo_identity-0.1.45 → maleo_identity-0.1.60}/src/mixins/user.py +0 -0
  54. {maleo_identity-0.1.45 → maleo_identity-0.1.60}/src/mixins/user_medical_role.py +0 -0
  55. {maleo_identity-0.1.45 → maleo_identity-0.1.60}/src/mixins/user_organization_role.py +0 -0
  56. {maleo_identity-0.1.45 → maleo_identity-0.1.60}/src/mixins/user_profile.py +0 -0
  57. {maleo_identity-0.1.45 → maleo_identity-0.1.60}/src/mixins/user_system_role.py +0 -0
  58. {maleo_identity-0.1.45 → maleo_identity-0.1.60}/src/schemas/__init__.py +0 -0
  59. {maleo_identity-0.1.45 → maleo_identity-0.1.60}/src/schemas/api_key.py +0 -0
  60. {maleo_identity-0.1.45 → maleo_identity-0.1.60}/src/schemas/organization_registration_code.py +0 -0
  61. {maleo_identity-0.1.45 → maleo_identity-0.1.60}/src/schemas/organization_relation.py +0 -0
  62. {maleo_identity-0.1.45 → maleo_identity-0.1.60}/src/schemas/patient.py +0 -0
  63. {maleo_identity-0.1.45 → maleo_identity-0.1.60}/src/schemas/user_profile.py +0 -0
  64. {maleo_identity-0.1.45 → maleo_identity-0.1.60}/src/schemas/user_system_role.py +0 -0
  65. {maleo_identity-0.1.45 → maleo_identity-0.1.60}/src/types/__init__.py +0 -0
  66. {maleo_identity-0.1.45 → maleo_identity-0.1.60}/src/types/api_key.py +0 -0
  67. {maleo_identity-0.1.45 → maleo_identity-0.1.60}/src/types/organization.py +0 -0
  68. {maleo_identity-0.1.45 → maleo_identity-0.1.60}/src/types/organization_registration_code.py +0 -0
  69. {maleo_identity-0.1.45 → maleo_identity-0.1.60}/src/types/organization_relation.py +0 -0
  70. {maleo_identity-0.1.45 → maleo_identity-0.1.60}/src/types/patient.py +0 -0
  71. {maleo_identity-0.1.45 → maleo_identity-0.1.60}/src/types/user.py +0 -0
  72. {maleo_identity-0.1.45 → maleo_identity-0.1.60}/src/types/user_medical_role.py +0 -0
  73. {maleo_identity-0.1.45 → maleo_identity-0.1.60}/src/types/user_organization_role.py +0 -0
  74. {maleo_identity-0.1.45 → maleo_identity-0.1.60}/src/types/user_profile.py +0 -0
  75. {maleo_identity-0.1.45 → maleo_identity-0.1.60}/src/types/user_system_role.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: maleo-identity
3
- Version: 0.1.45
3
+ Version: 0.1.60
4
4
  Summary: MaleoIdentity service package
5
5
  Author-email: Agra Bima Yuda <agra@nexmedis.com>
6
6
  License: Proprietary
@@ -41,15 +41,15 @@ Requires-Dist: identify>=2.6.15
41
41
  Requires-Dist: idna>=3.11
42
42
  Requires-Dist: importlib_metadata>=8.7.0
43
43
  Requires-Dist: iniconfig>=2.1.0
44
- Requires-Dist: maleo-enums>=0.0.81
45
- Requires-Dist: maleo-metadata>=0.7.75
44
+ Requires-Dist: maleo-enums>=0.0.85
45
+ Requires-Dist: maleo-metadata>=0.7.89
46
46
  Requires-Dist: mypy_extensions>=1.1.0
47
- Requires-Dist: nexo-crypto>=0.0.4
48
- Requires-Dist: nexo-enums>=0.0.4
49
- Requires-Dist: nexo-logging>=0.0.4
50
- Requires-Dist: nexo-schemas>=0.0.4
51
- Requires-Dist: nexo-types>=0.0.4
52
- Requires-Dist: nexo-utils>=0.0.4
47
+ Requires-Dist: nexo-crypto>=0.0.5
48
+ Requires-Dist: nexo-enums>=0.0.5
49
+ Requires-Dist: nexo-logging>=0.0.5
50
+ Requires-Dist: nexo-schemas>=0.0.9
51
+ Requires-Dist: nexo-types>=0.0.5
52
+ Requires-Dist: nexo-utils>=0.0.5
53
53
  Requires-Dist: nodeenv>=1.9.1
54
54
  Requires-Dist: opentelemetry-api>=1.37.0
55
55
  Requires-Dist: opentelemetry-sdk>=1.37.0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: maleo-identity
3
- Version: 0.1.45
3
+ Version: 0.1.60
4
4
  Summary: MaleoIdentity service package
5
5
  Author-email: Agra Bima Yuda <agra@nexmedis.com>
6
6
  License: Proprietary
@@ -41,15 +41,15 @@ Requires-Dist: identify>=2.6.15
41
41
  Requires-Dist: idna>=3.11
42
42
  Requires-Dist: importlib_metadata>=8.7.0
43
43
  Requires-Dist: iniconfig>=2.1.0
44
- Requires-Dist: maleo-enums>=0.0.81
45
- Requires-Dist: maleo-metadata>=0.7.75
44
+ Requires-Dist: maleo-enums>=0.0.85
45
+ Requires-Dist: maleo-metadata>=0.7.89
46
46
  Requires-Dist: mypy_extensions>=1.1.0
47
- Requires-Dist: nexo-crypto>=0.0.4
48
- Requires-Dist: nexo-enums>=0.0.4
49
- Requires-Dist: nexo-logging>=0.0.4
50
- Requires-Dist: nexo-schemas>=0.0.4
51
- Requires-Dist: nexo-types>=0.0.4
52
- Requires-Dist: nexo-utils>=0.0.4
47
+ Requires-Dist: nexo-crypto>=0.0.5
48
+ Requires-Dist: nexo-enums>=0.0.5
49
+ Requires-Dist: nexo-logging>=0.0.5
50
+ Requires-Dist: nexo-schemas>=0.0.9
51
+ Requires-Dist: nexo-types>=0.0.5
52
+ Requires-Dist: nexo-utils>=0.0.5
53
53
  Requires-Dist: nodeenv>=1.9.1
54
54
  Requires-Dist: opentelemetry-api>=1.37.0
55
55
  Requires-Dist: opentelemetry-sdk>=1.37.0
@@ -15,6 +15,7 @@ src/constants/organization_relation.py
15
15
  src/constants/patient.py
16
16
  src/constants/user.py
17
17
  src/constants/user_medical_role.py
18
+ src/constants/user_organization.py
18
19
  src/constants/user_organization_role.py
19
20
  src/constants/user_profile.py
20
21
  src/constants/user_system_role.py
@@ -26,6 +27,7 @@ src/enums/organization_relation.py
26
27
  src/enums/patient.py
27
28
  src/enums/user.py
28
29
  src/enums/user_medical_role.py
30
+ src/enums/user_organization.py
29
31
  src/enums/user_organization_role.py
30
32
  src/enums/user_profile.py
31
33
  src/enums/user_system_role.py
@@ -38,6 +40,7 @@ src/mixins/organization_relation.py
38
40
  src/mixins/patient.py
39
41
  src/mixins/user.py
40
42
  src/mixins/user_medical_role.py
43
+ src/mixins/user_organization.py
41
44
  src/mixins/user_organization_role.py
42
45
  src/mixins/user_profile.py
43
46
  src/mixins/user_system_role.py
@@ -50,6 +53,7 @@ src/schemas/organization_relation.py
50
53
  src/schemas/patient.py
51
54
  src/schemas/user.py
52
55
  src/schemas/user_medical_role.py
56
+ src/schemas/user_organization.py
53
57
  src/schemas/user_organization_role.py
54
58
  src/schemas/user_profile.py
55
59
  src/schemas/user_system_role.py
@@ -61,8 +65,7 @@ src/types/organization_relation.py
61
65
  src/types/patient.py
62
66
  src/types/user.py
63
67
  src/types/user_medical_role.py
68
+ src/types/user_organization.py
64
69
  src/types/user_organization_role.py
65
70
  src/types/user_profile.py
66
- src/types/user_system_role.py
67
- src/utils/__init__.py
68
- src/utils/organization.py
71
+ src/types/user_system_role.py
@@ -32,15 +32,15 @@ identify>=2.6.15
32
32
  idna>=3.11
33
33
  importlib_metadata>=8.7.0
34
34
  iniconfig>=2.1.0
35
- maleo-enums>=0.0.81
36
- maleo-metadata>=0.7.75
35
+ maleo-enums>=0.0.85
36
+ maleo-metadata>=0.7.89
37
37
  mypy_extensions>=1.1.0
38
- nexo-crypto>=0.0.4
39
- nexo-enums>=0.0.4
40
- nexo-logging>=0.0.4
41
- nexo-schemas>=0.0.4
42
- nexo-types>=0.0.4
43
- nexo-utils>=0.0.4
38
+ nexo-crypto>=0.0.5
39
+ nexo-enums>=0.0.5
40
+ nexo-logging>=0.0.5
41
+ nexo-schemas>=0.0.9
42
+ nexo-types>=0.0.5
43
+ nexo-utils>=0.0.5
44
44
  nodeenv>=1.9.1
45
45
  opentelemetry-api>=1.37.0
46
46
  opentelemetry-sdk>=1.37.0
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "maleo-identity"
7
- version = "0.1.45"
7
+ version = "0.1.60"
8
8
  description = "MaleoIdentity service package"
9
9
  authors = [
10
10
  { name = "Agra Bima Yuda", email = "agra@nexmedis.com" }
@@ -47,15 +47,15 @@ dependencies = [
47
47
  "idna>=3.11",
48
48
  "importlib_metadata>=8.7.0",
49
49
  "iniconfig>=2.1.0",
50
- "maleo-enums>=0.0.81",
51
- "maleo-metadata>=0.7.75",
50
+ "maleo-enums>=0.0.85",
51
+ "maleo-metadata>=0.7.89",
52
52
  "mypy_extensions>=1.1.0",
53
- "nexo-crypto>=0.0.4",
54
- "nexo-enums>=0.0.4",
55
- "nexo-logging>=0.0.4",
56
- "nexo-schemas>=0.0.4",
57
- "nexo-types>=0.0.4",
58
- "nexo-utils>=0.0.4",
53
+ "nexo-crypto>=0.0.5",
54
+ "nexo-enums>=0.0.5",
55
+ "nexo-logging>=0.0.5",
56
+ "nexo-schemas>=0.0.9",
57
+ "nexo-types>=0.0.5",
58
+ "nexo-utils>=0.0.5",
59
59
  "nodeenv>=1.9.1",
60
60
  "opentelemetry-api>=1.37.0",
61
61
  "opentelemetry-sdk>=1.37.0",
@@ -103,7 +103,6 @@ packages = [
103
103
  "maleo.identity.mixins",
104
104
  "maleo.identity.schemas",
105
105
  "maleo.identity.types",
106
- "maleo.identity.utils",
107
106
  ]
108
107
 
109
108
  [tool.setuptools.package-data]
@@ -113,7 +112,6 @@ packages = [
113
112
  "maleo.identity.mixins" = ["*.json", "*.yaml"]
114
113
  "maleo.identity.schemas" = ["*.json", "*.yaml"]
115
114
  "maleo.identity.types" = ["*.json", "*.yaml"]
116
- "maleo.identity.utils" = ["*.json", "*.yaml"]
117
115
 
118
116
  [tool.setuptools.package-dir]
119
117
  "maleo.identity" = "src"
@@ -121,5 +119,4 @@ packages = [
121
119
  "maleo.identity.enums" = "src/enums"
122
120
  "maleo.identity.mixins" = "src/mixins"
123
121
  "maleo.identity.schemas" = "src/schemas"
124
- "maleo.identity.types" = "src/types"
125
- "maleo.identity.utils" = "src/utils"
122
+ "maleo.identity.types" = "src/types"
@@ -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
+ )
@@ -2,15 +2,6 @@ from enum import StrEnum
2
2
  from nexo.types.string import ListOfStrs
3
3
 
4
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]
12
-
13
-
14
5
  class IdentifierType(StrEnum):
15
6
  ID = "id"
16
7
  UUID = "uuid"
@@ -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
@@ -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
@@ -4,7 +4,7 @@ from uuid import UUID
4
4
  from nexo.schemas.mixins.identity import Identifier, Key as BaseKey, Name as BaseName
5
5
  from nexo.types.string import OptStrT
6
6
  from nexo.types.uuid import OptUUIDT
7
- from ..enums.organization import IdentifierType
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]:
@@ -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,6 +1,6 @@
1
1
  from datetime import date
2
2
  from pydantic import BaseModel, Field
3
- from typing import Annotated, Generic, TypeVar, Type
3
+ from typing import Annotated
4
4
  from nexo.enums.identity import OptRhesus, RhesusMixin
5
5
  from nexo.enums.organization import (
6
6
  OrganizationRelation,
@@ -110,7 +110,7 @@ class OrganizationRegistrationCodeSchemaMixin(BaseModel):
110
110
  ] = None
111
111
 
112
112
 
113
- class StandardOrganizationSchema(
113
+ class OrganizationSchema(
114
114
  OrganizationName[str],
115
115
  OrganizationKey[str],
116
116
  FullOrganizationTypeMixin[OrganizationTypeKeyOrStandardSchema],
@@ -120,10 +120,12 @@ class StandardOrganizationSchema(
120
120
  pass
121
121
 
122
122
 
123
+ class OrganizationSchemaMixin(BaseModel):
124
+ organization: Annotated[OrganizationSchema, Field(..., description="Organization")]
125
+
126
+
123
127
  class SourceOrganizationSchemaMixin(BaseModel):
124
- source: Annotated[
125
- StandardOrganizationSchema, Field(..., description="Source organization")
126
- ]
128
+ source: Annotated[OrganizationSchema, Field(..., description="Source organization")]
127
129
 
128
130
 
129
131
  class SourceOrganizationRelationSchema(
@@ -145,9 +147,7 @@ class SourceOrganizationRelationsSchemaMixin(BaseModel):
145
147
 
146
148
 
147
149
  class TargetOrganizationSchemaMixin(BaseModel):
148
- target: Annotated[
149
- StandardOrganizationSchema, Field(..., description="Target organization")
150
- ]
150
+ target: Annotated[OrganizationSchema, Field(..., description="Target organization")]
151
151
 
152
152
 
153
153
  class TargetOrganizationRelationSchema(
@@ -168,28 +168,6 @@ class TargetOrganizationRelationsSchemaMixin(BaseModel):
168
168
  ] = list[TargetOrganizationRelationSchema]()
169
169
 
170
170
 
171
- class FullOrganizationSchema(
172
- TargetOrganizationRelationsSchemaMixin,
173
- SourceOrganizationRelationsSchemaMixin,
174
- OrganizationRegistrationCodeSchemaMixin,
175
- StandardOrganizationSchema,
176
- ):
177
- pass
178
-
179
-
180
- AnyOrganizationSchemaType = (
181
- Type[StandardOrganizationSchema] | Type[FullOrganizationSchema]
182
- )
183
- AnyOrganizationSchema = StandardOrganizationSchema | FullOrganizationSchema
184
- AnyOrganizationSchemaT = TypeVar("AnyOrganizationSchemaT", bound=AnyOrganizationSchema)
185
-
186
-
187
- class OrganizationSchemaMixin(BaseModel, Generic[AnyOrganizationSchemaT]):
188
- organization: Annotated[
189
- AnyOrganizationSchemaT, Field(..., description="Organization")
190
- ]
191
-
192
-
193
171
  class OrganizationRelationSchema(
194
172
  Meta,
195
173
  IsBidirectional[bool],
@@ -305,7 +283,7 @@ class UserSchemaMixin(BaseModel):
305
283
  class UserAndOrganizationSchema(
306
284
  UserMedicalRolesSchemaMixin,
307
285
  UserOrganizationRolesSchemaMixin,
308
- OrganizationSchemaMixin[StandardOrganizationSchema],
286
+ OrganizationSchemaMixin,
309
287
  UserSchemaMixin,
310
288
  SimpleDataStatusMixin[DataStatusEnum],
311
289
  DataIdentifier,