maleo-identity 0.0.97__tar.gz → 0.1.14__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 (88) hide show
  1. {maleo_identity-0.0.97 → maleo_identity-0.1.14}/PKG-INFO +7 -7
  2. {maleo_identity-0.0.97 → maleo_identity-0.1.14}/maleo_identity.egg-info/PKG-INFO +7 -7
  3. {maleo_identity-0.0.97 → maleo_identity-0.1.14}/maleo_identity.egg-info/SOURCES.txt +31 -0
  4. {maleo_identity-0.0.97 → maleo_identity-0.1.14}/maleo_identity.egg-info/requires.txt +6 -6
  5. {maleo_identity-0.0.97 → maleo_identity-0.1.14}/pyproject.toml +8 -8
  6. maleo_identity-0.1.14/src/constants/api_key.py +13 -0
  7. maleo_identity-0.1.14/src/constants/organization.py +11 -0
  8. maleo_identity-0.1.14/src/constants/organization_registration_code.py +13 -0
  9. maleo_identity-0.1.14/src/constants/organization_relation.py +13 -0
  10. maleo_identity-0.1.14/src/constants/patient.py +7 -0
  11. maleo_identity-0.1.14/src/constants/user.py +7 -0
  12. maleo_identity-0.1.14/src/constants/user_medical_role.py +13 -0
  13. maleo_identity-0.1.14/src/constants/user_organization_role.py +13 -0
  14. maleo_identity-0.1.14/src/constants/user_profile.py +11 -0
  15. maleo_identity-0.1.14/src/constants/user_system_role.py +17 -0
  16. maleo_identity-0.1.14/src/enums/api_key.py +25 -0
  17. {maleo_identity-0.0.97 → maleo_identity-0.1.14}/src/enums/organization.py +0 -9
  18. maleo_identity-0.1.14/src/enums/organization_relation.py +22 -0
  19. maleo_identity-0.1.14/src/enums/patient.py +13 -0
  20. {maleo_identity-0.0.97 → maleo_identity-0.1.14}/src/enums/user.py +0 -9
  21. maleo_identity-0.1.14/src/enums/user_medical_role.py +22 -0
  22. maleo_identity-0.1.14/src/enums/user_organization_role.py +22 -0
  23. maleo_identity-0.1.14/src/enums/user_system_role.py +22 -0
  24. maleo_identity-0.1.14/src/mixins/api_key.py +72 -0
  25. maleo_identity-0.1.14/src/mixins/common.py +29 -0
  26. maleo_identity-0.1.14/src/mixins/organization.py +73 -0
  27. maleo_identity-0.1.14/src/mixins/organization_registration_code.py +100 -0
  28. maleo_identity-0.1.14/src/mixins/organization_relation.py +80 -0
  29. maleo_identity-0.1.14/src/mixins/patient.py +96 -0
  30. maleo_identity-0.1.14/src/mixins/user.py +107 -0
  31. maleo_identity-0.1.14/src/mixins/user_medical_role.py +68 -0
  32. maleo_identity-0.1.14/src/mixins/user_organization_role.py +70 -0
  33. maleo_identity-0.1.14/src/mixins/user_profile.py +117 -0
  34. maleo_identity-0.1.14/src/mixins/user_system_role.py +68 -0
  35. {maleo_identity-0.0.97 → maleo_identity-0.1.14}/src/models.py +95 -97
  36. maleo_identity-0.0.97/src/schemas/organization_registration_code.py → maleo_identity-0.1.14/src/schemas/api_key.py +57 -65
  37. {maleo_identity-0.0.97 → maleo_identity-0.1.14}/src/schemas/common.py +144 -114
  38. maleo_identity-0.1.14/src/schemas/organization.py +285 -0
  39. maleo_identity-0.1.14/src/schemas/organization_registration_code.py +297 -0
  40. maleo_identity-0.1.14/src/schemas/organization_relation.py +297 -0
  41. maleo_identity-0.1.14/src/schemas/patient.py +324 -0
  42. {maleo_identity-0.0.97 → maleo_identity-0.1.14}/src/schemas/user.py +130 -16
  43. maleo_identity-0.1.14/src/schemas/user_medical_role.py +297 -0
  44. maleo_identity-0.1.14/src/schemas/user_organization_role.py +298 -0
  45. maleo_identity-0.1.14/src/schemas/user_profile.py +330 -0
  46. maleo_identity-0.1.14/src/schemas/user_system_role.py +298 -0
  47. maleo_identity-0.1.14/src/types/api_key.py +7 -0
  48. maleo_identity-0.1.14/src/types/organization.py +4 -0
  49. maleo_identity-0.1.14/src/types/organization_registration_code.py +4 -0
  50. maleo_identity-0.1.14/src/types/organization_relation.py +7 -0
  51. maleo_identity-0.1.14/src/types/patient.py +4 -0
  52. maleo_identity-0.1.14/src/types/user.py +4 -0
  53. maleo_identity-0.1.14/src/types/user_medical_role.py +7 -0
  54. maleo_identity-0.1.14/src/types/user_organization_role.py +7 -0
  55. maleo_identity-0.1.14/src/types/user_profile.py +4 -0
  56. maleo_identity-0.1.14/src/types/user_system_role.py +7 -0
  57. maleo_identity-0.1.14/src/utils/organization.py +32 -0
  58. maleo_identity-0.1.14/src/utils/user.py +32 -0
  59. maleo_identity-0.0.97/src/constants/organization.py +0 -25
  60. maleo_identity-0.0.97/src/constants/organization_registration_code.py +0 -28
  61. maleo_identity-0.0.97/src/constants/user.py +0 -22
  62. maleo_identity-0.0.97/src/constants/user_profile.py +0 -26
  63. maleo_identity-0.0.97/src/mixins/organization.py +0 -17
  64. maleo_identity-0.0.97/src/mixins/organization_registration_code.py +0 -16
  65. maleo_identity-0.0.97/src/mixins/user.py +0 -33
  66. maleo_identity-0.0.97/src/mixins/user_profile.py +0 -58
  67. maleo_identity-0.0.97/src/schemas/organization.py +0 -162
  68. maleo_identity-0.0.97/src/schemas/user_profile.py +0 -212
  69. maleo_identity-0.0.97/src/types/organization.py +0 -5
  70. maleo_identity-0.0.97/src/types/organization_registration_code.py +0 -5
  71. maleo_identity-0.0.97/src/types/user.py +0 -5
  72. maleo_identity-0.0.97/src/types/user_profile.py +0 -5
  73. maleo_identity-0.0.97/src/utils/organization.py +0 -56
  74. maleo_identity-0.0.97/src/utils/user.py +0 -56
  75. {maleo_identity-0.0.97 → maleo_identity-0.1.14}/LICENSE +0 -0
  76. {maleo_identity-0.0.97 → maleo_identity-0.1.14}/README.md +0 -0
  77. {maleo_identity-0.0.97 → maleo_identity-0.1.14}/maleo_identity.egg-info/dependency_links.txt +0 -0
  78. {maleo_identity-0.0.97 → maleo_identity-0.1.14}/maleo_identity.egg-info/top_level.txt +0 -0
  79. {maleo_identity-0.0.97 → maleo_identity-0.1.14}/setup.cfg +0 -0
  80. {maleo_identity-0.0.97 → maleo_identity-0.1.14}/src/__init__.py +0 -0
  81. {maleo_identity-0.0.97 → maleo_identity-0.1.14}/src/constants/__init__.py +0 -0
  82. {maleo_identity-0.0.97 → maleo_identity-0.1.14}/src/enums/__init__.py +0 -0
  83. {maleo_identity-0.0.97 → maleo_identity-0.1.14}/src/enums/organization_registration_code.py +0 -0
  84. {maleo_identity-0.0.97 → maleo_identity-0.1.14}/src/enums/user_profile.py +0 -0
  85. {maleo_identity-0.0.97 → maleo_identity-0.1.14}/src/mixins/__init__.py +0 -0
  86. {maleo_identity-0.0.97 → maleo_identity-0.1.14}/src/schemas/__init__.py +0 -0
  87. {maleo_identity-0.0.97 → maleo_identity-0.1.14}/src/types/__init__.py +0 -0
  88. {maleo_identity-0.0.97 → maleo_identity-0.1.14}/src/utils/__init__.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: maleo-identity
3
- Version: 0.0.97
3
+ Version: 0.1.14
4
4
  Summary: MaleoIdentity service package
5
5
  Author-email: Agra Bima Yuda <agra@nexmedis.com>
6
6
  License: Proprietary
@@ -41,12 +41,12 @@ Requires-Dist: identify>=2.6.15
41
41
  Requires-Dist: idna>=3.10
42
42
  Requires-Dist: importlib_metadata>=8.7.0
43
43
  Requires-Dist: iniconfig>=2.1.0
44
- Requires-Dist: maleo-crypto>=0.0.40
45
- Requires-Dist: maleo-enums>=0.0.40
46
- Requires-Dist: maleo-logging>=0.0.40
47
- Requires-Dist: maleo-schemas>=0.1.50
48
- Requires-Dist: maleo-types>=0.0.20
49
- Requires-Dist: maleo-utils>=0.0.40
44
+ Requires-Dist: maleo-crypto>=0.0.50
45
+ Requires-Dist: maleo-enums>=0.0.50
46
+ Requires-Dist: maleo-logging>=0.0.50
47
+ Requires-Dist: maleo-schemas>=0.4.30
48
+ Requires-Dist: maleo-types>=0.0.50
49
+ Requires-Dist: maleo-utils>=0.0.50
50
50
  Requires-Dist: mypy_extensions>=1.1.0
51
51
  Requires-Dist: nodeenv>=1.9.1
52
52
  Requires-Dist: opentelemetry-api>=1.37.0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: maleo-identity
3
- Version: 0.0.97
3
+ Version: 0.1.14
4
4
  Summary: MaleoIdentity service package
5
5
  Author-email: Agra Bima Yuda <agra@nexmedis.com>
6
6
  License: Proprietary
@@ -41,12 +41,12 @@ Requires-Dist: identify>=2.6.15
41
41
  Requires-Dist: idna>=3.10
42
42
  Requires-Dist: importlib_metadata>=8.7.0
43
43
  Requires-Dist: iniconfig>=2.1.0
44
- Requires-Dist: maleo-crypto>=0.0.40
45
- Requires-Dist: maleo-enums>=0.0.40
46
- Requires-Dist: maleo-logging>=0.0.40
47
- Requires-Dist: maleo-schemas>=0.1.50
48
- Requires-Dist: maleo-types>=0.0.20
49
- Requires-Dist: maleo-utils>=0.0.40
44
+ Requires-Dist: maleo-crypto>=0.0.50
45
+ Requires-Dist: maleo-enums>=0.0.50
46
+ Requires-Dist: maleo-logging>=0.0.50
47
+ Requires-Dist: maleo-schemas>=0.4.30
48
+ Requires-Dist: maleo-types>=0.0.50
49
+ Requires-Dist: maleo-utils>=0.0.50
50
50
  Requires-Dist: mypy_extensions>=1.1.0
51
51
  Requires-Dist: nodeenv>=1.9.1
52
52
  Requires-Dist: opentelemetry-api>=1.37.0
@@ -9,31 +9,62 @@ maleo_identity.egg-info/top_level.txt
9
9
  src/__init__.py
10
10
  src/models.py
11
11
  src/constants/__init__.py
12
+ src/constants/api_key.py
12
13
  src/constants/organization.py
13
14
  src/constants/organization_registration_code.py
15
+ src/constants/organization_relation.py
16
+ src/constants/patient.py
14
17
  src/constants/user.py
18
+ src/constants/user_medical_role.py
19
+ src/constants/user_organization_role.py
15
20
  src/constants/user_profile.py
21
+ src/constants/user_system_role.py
16
22
  src/enums/__init__.py
23
+ src/enums/api_key.py
17
24
  src/enums/organization.py
18
25
  src/enums/organization_registration_code.py
26
+ src/enums/organization_relation.py
27
+ src/enums/patient.py
19
28
  src/enums/user.py
29
+ src/enums/user_medical_role.py
30
+ src/enums/user_organization_role.py
20
31
  src/enums/user_profile.py
32
+ src/enums/user_system_role.py
21
33
  src/mixins/__init__.py
34
+ src/mixins/api_key.py
35
+ src/mixins/common.py
22
36
  src/mixins/organization.py
23
37
  src/mixins/organization_registration_code.py
38
+ src/mixins/organization_relation.py
39
+ src/mixins/patient.py
24
40
  src/mixins/user.py
41
+ src/mixins/user_medical_role.py
42
+ src/mixins/user_organization_role.py
25
43
  src/mixins/user_profile.py
44
+ src/mixins/user_system_role.py
26
45
  src/schemas/__init__.py
46
+ src/schemas/api_key.py
27
47
  src/schemas/common.py
28
48
  src/schemas/organization.py
29
49
  src/schemas/organization_registration_code.py
50
+ src/schemas/organization_relation.py
51
+ src/schemas/patient.py
30
52
  src/schemas/user.py
53
+ src/schemas/user_medical_role.py
54
+ src/schemas/user_organization_role.py
31
55
  src/schemas/user_profile.py
56
+ src/schemas/user_system_role.py
32
57
  src/types/__init__.py
58
+ src/types/api_key.py
33
59
  src/types/organization.py
34
60
  src/types/organization_registration_code.py
61
+ src/types/organization_relation.py
62
+ src/types/patient.py
35
63
  src/types/user.py
64
+ src/types/user_medical_role.py
65
+ src/types/user_organization_role.py
36
66
  src/types/user_profile.py
67
+ src/types/user_system_role.py
37
68
  src/utils/__init__.py
38
69
  src/utils/organization.py
39
70
  src/utils/user.py
@@ -32,12 +32,12 @@ identify>=2.6.15
32
32
  idna>=3.10
33
33
  importlib_metadata>=8.7.0
34
34
  iniconfig>=2.1.0
35
- maleo-crypto>=0.0.40
36
- maleo-enums>=0.0.40
37
- maleo-logging>=0.0.40
38
- maleo-schemas>=0.1.50
39
- maleo-types>=0.0.20
40
- maleo-utils>=0.0.40
35
+ maleo-crypto>=0.0.50
36
+ maleo-enums>=0.0.50
37
+ maleo-logging>=0.0.50
38
+ maleo-schemas>=0.4.30
39
+ maleo-types>=0.0.50
40
+ maleo-utils>=0.0.50
41
41
  mypy_extensions>=1.1.0
42
42
  nodeenv>=1.9.1
43
43
  opentelemetry-api>=1.37.0
@@ -3,8 +3,8 @@ requires = ["setuptools", "wheel"]
3
3
  build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
- name = "maleo-identity" # PyPI package name
7
- version = "0.0.97"
6
+ name = "maleo-identity"
7
+ version = "0.1.14"
8
8
  description = "MaleoIdentity service package"
9
9
  authors = [
10
10
  { name = "Agra Bima Yuda", email = "agra@nexmedis.com" }
@@ -47,12 +47,12 @@ dependencies = [
47
47
  "idna>=3.10",
48
48
  "importlib_metadata>=8.7.0",
49
49
  "iniconfig>=2.1.0",
50
- "maleo-crypto>=0.0.40",
51
- "maleo-enums>=0.0.40",
52
- "maleo-logging>=0.0.40",
53
- "maleo-schemas>=0.1.50",
54
- "maleo-types>=0.0.20",
55
- "maleo-utils>=0.0.40",
50
+ "maleo-crypto>=0.0.50",
51
+ "maleo-enums>=0.0.50",
52
+ "maleo-logging>=0.0.50",
53
+ "maleo-schemas>=0.4.30",
54
+ "maleo-types>=0.0.50",
55
+ "maleo-utils>=0.0.50",
56
56
  "mypy_extensions>=1.1.0",
57
57
  "nodeenv>=1.9.1",
58
58
  "opentelemetry-api>=1.37.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
+ )
@@ -0,0 +1,11 @@
1
+ from maleo.schemas.resource import Resource, ResourceIdentifier
2
+
3
+
4
+ ORGANIZATION_RESOURCE = Resource(
5
+ identifiers=[
6
+ ResourceIdentifier(
7
+ key="organization", name="Organization", slug="organizations"
8
+ )
9
+ ],
10
+ details=None,
11
+ )
@@ -0,0 +1,13 @@
1
+ from maleo.schemas.resource import Resource, ResourceIdentifier
2
+
3
+
4
+ ORGANIZATION_REGISTRATION_CODE_RESOURCE = Resource(
5
+ identifiers=[
6
+ ResourceIdentifier(
7
+ key="organization_registration_code",
8
+ name="Organization Registration Code",
9
+ slug="organization-registration-codes",
10
+ )
11
+ ],
12
+ details=None,
13
+ )
@@ -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
+ )
@@ -0,0 +1,7 @@
1
+ from maleo.schemas.resource import Resource, ResourceIdentifier
2
+
3
+
4
+ USER_RESOURCE = Resource(
5
+ identifiers=[ResourceIdentifier(key="user", name="User", slug="users")],
6
+ details=None,
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
+ )
@@ -0,0 +1,13 @@
1
+ from maleo.schemas.resource import Resource, ResourceIdentifier
2
+
3
+
4
+ USER_ORGANIZATION_ROLE_RESOURCE = Resource(
5
+ identifiers=[
6
+ ResourceIdentifier(
7
+ key="user_organization_role",
8
+ name="User Organization Role",
9
+ slug="user-organization-roles",
10
+ )
11
+ ],
12
+ details=None,
13
+ )
@@ -0,0 +1,11 @@
1
+ from maleo.schemas.resource import Resource, ResourceIdentifier
2
+
3
+
4
+ USER_PROFILE_RESOURCE = Resource(
5
+ identifiers=[
6
+ ResourceIdentifier(
7
+ key="user_profile", name="User Profile", slug="user-profiles"
8
+ )
9
+ ],
10
+ details=None,
11
+ )
@@ -0,0 +1,17 @@
1
+ from maleo.schemas.resource import Resource, ResourceIdentifier
2
+ from maleo.types.string import DoubleStrs
3
+
4
+
5
+ USER_SYSTEM_ROLE_RESOURCE = Resource(
6
+ identifiers=[
7
+ ResourceIdentifier(
8
+ key="user_system_role",
9
+ name="User System Role",
10
+ slug="user-system-roles",
11
+ )
12
+ ],
13
+ details=None,
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}")
@@ -19,12 +19,3 @@ class IdentifierType(StrEnum):
19
19
  @classmethod
20
20
  def choices(cls) -> ListOfStrs:
21
21
  return [e.value for e in cls]
22
-
23
-
24
- class SchemaType(StrEnum):
25
- CORE = "core"
26
- COMPLETE = "complete"
27
-
28
- @classmethod
29
- def choices(cls) -> ListOfStrs:
30
- return [e.value for e in cls]
@@ -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,13 @@
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
+ ID_CARD = "id_card"
9
+ PASSPORT = "passport"
10
+
11
+ @classmethod
12
+ def choices(cls) -> ListOfStrs:
13
+ return [e.value for e in cls]
@@ -20,12 +20,3 @@ class IdentifierType(StrEnum):
20
20
  @classmethod
21
21
  def choices(cls) -> ListOfStrs:
22
22
  return [e.value for e in cls]
23
-
24
-
25
- class SchemaType(StrEnum):
26
- CORE = "core"
27
- COMPLETE = "complete"
28
-
29
- @classmethod
30
- def choices(cls) -> ListOfStrs:
31
- return [e.value for e in cls]
@@ -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}")
@@ -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", "organization_role")
22
+ raise ValueError(f"Unknown column(s) for identifier type: {self}")
@@ -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", "system_role")
22
+ raise ValueError(f"Unknown column(s) for identifier type: {self}")
@@ -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 CompositeIdentifier, 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], CompositeIdentifier]
39
+ ):
40
+ type: Annotated[
41
+ Literal[IdentifierType.COMPOSITE],
42
+ Field(IdentifierType.COMPOSITE, description="Identifier's type"),
43
+ ] = IdentifierType.COMPOSITE
44
+ value: Annotated[CompositeIdentifier, 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
+ ]
@@ -0,0 +1,73 @@
1
+ from pydantic import BaseModel, Field
2
+ from typing import Annotated, Generic, Literal, TypeGuard
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
8
+ from ..types.organization import IdentifierValueType
9
+
10
+
11
+ class Key(BaseKey, Generic[OptStrT]):
12
+ key: Annotated[OptStrT, Field(..., description="Key", max_length=255)]
13
+
14
+
15
+ class Name(BaseName, Generic[OptStrT]):
16
+ name: Annotated[OptStrT, Field(..., description="Name", max_length=255)]
17
+
18
+
19
+ class Secret(BaseModel, Generic[OptUUIDT]):
20
+ secret: Annotated[OptUUIDT, Field(..., description="Secret")]
21
+
22
+
23
+ class OrganizationIdentifier(Identifier[IdentifierType, IdentifierValueType]):
24
+ pass
25
+
26
+
27
+ class IdOrganizationIdentifier(Identifier[Literal[IdentifierType.ID], int]):
28
+ type: Annotated[
29
+ Literal[IdentifierType.ID],
30
+ Field(IdentifierType.ID, description="Identifier's type"),
31
+ ] = IdentifierType.ID
32
+ value: Annotated[int, Field(..., description="Identifier's value", ge=1)]
33
+
34
+
35
+ class UUIDOrganizationIdentifier(Identifier[Literal[IdentifierType.UUID], UUID]):
36
+ type: Annotated[
37
+ Literal[IdentifierType.UUID],
38
+ Field(IdentifierType.UUID, description="Identifier's type"),
39
+ ] = IdentifierType.UUID
40
+
41
+
42
+ class KeyOrganizationIdentifier(Identifier[Literal[IdentifierType.KEY], str]):
43
+ type: Annotated[
44
+ Literal[IdentifierType.KEY],
45
+ Field(IdentifierType.KEY, description="Identifier's type"),
46
+ ] = IdentifierType.KEY
47
+ value: Annotated[str, Field(..., description="Identifier's value", max_length=255)]
48
+
49
+
50
+ AnyOrganizationIdentifier = (
51
+ OrganizationIdentifier
52
+ | IdOrganizationIdentifier
53
+ | UUIDOrganizationIdentifier
54
+ | KeyOrganizationIdentifier
55
+ )
56
+
57
+
58
+ def is_id_identifier(
59
+ identifier: AnyOrganizationIdentifier,
60
+ ) -> TypeGuard[IdOrganizationIdentifier]:
61
+ return identifier.type is IdentifierType.ID and isinstance(identifier.value, int)
62
+
63
+
64
+ def is_uuid_identifier(
65
+ identifier: AnyOrganizationIdentifier,
66
+ ) -> TypeGuard[UUIDOrganizationIdentifier]:
67
+ return identifier.type is IdentifierType.UUID and isinstance(identifier.value, UUID)
68
+
69
+
70
+ def is_key_identifier(
71
+ identifier: AnyOrganizationIdentifier,
72
+ ) -> TypeGuard[KeyOrganizationIdentifier]:
73
+ return identifier.type is IdentifierType.KEY and isinstance(identifier.value, str)