maleo-identity 0.1.9__tar.gz → 0.1.11__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.
Potentially problematic release.
This version of maleo-identity might be problematic. Click here for more details.
- {maleo_identity-0.1.9 → maleo_identity-0.1.11}/PKG-INFO +7 -8
- {maleo_identity-0.1.9 → maleo_identity-0.1.11}/maleo_identity.egg-info/PKG-INFO +7 -8
- {maleo_identity-0.1.9 → maleo_identity-0.1.11}/maleo_identity.egg-info/SOURCES.txt +3 -0
- {maleo_identity-0.1.9 → maleo_identity-0.1.11}/maleo_identity.egg-info/requires.txt +6 -7
- {maleo_identity-0.1.9 → maleo_identity-0.1.11}/pyproject.toml +7 -8
- maleo_identity-0.1.11/src/mixins/api_key.py +67 -0
- maleo_identity-0.1.11/src/mixins/organization.py +73 -0
- maleo_identity-0.1.11/src/mixins/organization_registration_code.py +100 -0
- maleo_identity-0.1.11/src/mixins/organization_relation.py +75 -0
- maleo_identity-0.1.11/src/mixins/patient.py +96 -0
- maleo_identity-0.1.11/src/mixins/user.py +107 -0
- maleo_identity-0.1.11/src/mixins/user_medical_role.py +63 -0
- maleo_identity-0.1.11/src/mixins/user_organization_role.py +65 -0
- maleo_identity-0.1.11/src/mixins/user_profile.py +117 -0
- maleo_identity-0.1.11/src/mixins/user_system_role.py +63 -0
- {maleo_identity-0.1.9 → maleo_identity-0.1.11}/src/models.py +5 -0
- {maleo_identity-0.1.9 → maleo_identity-0.1.11}/src/schemas/api_key.py +36 -10
- {maleo_identity-0.1.9 → maleo_identity-0.1.11}/src/schemas/common.py +2 -2
- {maleo_identity-0.1.9 → maleo_identity-0.1.11}/src/schemas/organization.py +131 -16
- maleo_identity-0.1.11/src/schemas/organization_registration_code.py +297 -0
- maleo_identity-0.1.11/src/schemas/organization_relation.py +297 -0
- {maleo_identity-0.1.9 → maleo_identity-0.1.11}/src/schemas/patient.py +129 -19
- {maleo_identity-0.1.9 → maleo_identity-0.1.11}/src/schemas/user.py +126 -15
- maleo_identity-0.1.11/src/schemas/user_medical_role.py +297 -0
- maleo_identity-0.1.11/src/schemas/user_organization_role.py +298 -0
- {maleo_identity-0.1.9 → maleo_identity-0.1.11}/src/schemas/user_profile.py +134 -15
- maleo_identity-0.1.11/src/schemas/user_system_role.py +298 -0
- maleo_identity-0.1.9/src/mixins/api_key.py +0 -6
- maleo_identity-0.1.9/src/mixins/organization.py +0 -17
- maleo_identity-0.1.9/src/mixins/organization_registration_code.py +0 -16
- maleo_identity-0.1.9/src/mixins/organization_relation.py +0 -12
- maleo_identity-0.1.9/src/mixins/patient.py +0 -20
- maleo_identity-0.1.9/src/mixins/user.py +0 -33
- maleo_identity-0.1.9/src/mixins/user_profile.py +0 -41
- maleo_identity-0.1.9/src/schemas/organization_registration_code.py +0 -172
- maleo_identity-0.1.9/src/schemas/organization_relation.py +0 -178
- maleo_identity-0.1.9/src/schemas/user_medical_role.py +0 -181
- maleo_identity-0.1.9/src/schemas/user_organization_role.py +0 -181
- maleo_identity-0.1.9/src/schemas/user_system_role.py +0 -182
- {maleo_identity-0.1.9 → maleo_identity-0.1.11}/LICENSE +0 -0
- {maleo_identity-0.1.9 → maleo_identity-0.1.11}/README.md +0 -0
- {maleo_identity-0.1.9 → maleo_identity-0.1.11}/maleo_identity.egg-info/dependency_links.txt +0 -0
- {maleo_identity-0.1.9 → maleo_identity-0.1.11}/maleo_identity.egg-info/top_level.txt +0 -0
- {maleo_identity-0.1.9 → maleo_identity-0.1.11}/setup.cfg +0 -0
- {maleo_identity-0.1.9 → maleo_identity-0.1.11}/src/__init__.py +0 -0
- {maleo_identity-0.1.9 → maleo_identity-0.1.11}/src/constants/__init__.py +0 -0
- {maleo_identity-0.1.9 → maleo_identity-0.1.11}/src/constants/api_key.py +0 -0
- {maleo_identity-0.1.9 → maleo_identity-0.1.11}/src/constants/organization.py +0 -0
- {maleo_identity-0.1.9 → maleo_identity-0.1.11}/src/constants/organization_registration_code.py +0 -0
- {maleo_identity-0.1.9 → maleo_identity-0.1.11}/src/constants/organization_relation.py +0 -0
- {maleo_identity-0.1.9 → maleo_identity-0.1.11}/src/constants/patient.py +0 -0
- {maleo_identity-0.1.9 → maleo_identity-0.1.11}/src/constants/user.py +0 -0
- {maleo_identity-0.1.9 → maleo_identity-0.1.11}/src/constants/user_medical_role.py +0 -0
- {maleo_identity-0.1.9 → maleo_identity-0.1.11}/src/constants/user_organization_role.py +0 -0
- {maleo_identity-0.1.9 → maleo_identity-0.1.11}/src/constants/user_profile.py +0 -0
- {maleo_identity-0.1.9 → maleo_identity-0.1.11}/src/constants/user_system_role.py +0 -0
- {maleo_identity-0.1.9 → maleo_identity-0.1.11}/src/enums/__init__.py +0 -0
- {maleo_identity-0.1.9 → maleo_identity-0.1.11}/src/enums/api_key.py +0 -0
- {maleo_identity-0.1.9 → maleo_identity-0.1.11}/src/enums/organization.py +0 -0
- {maleo_identity-0.1.9 → maleo_identity-0.1.11}/src/enums/organization_registration_code.py +0 -0
- {maleo_identity-0.1.9 → maleo_identity-0.1.11}/src/enums/organization_relation.py +0 -0
- {maleo_identity-0.1.9 → maleo_identity-0.1.11}/src/enums/patient.py +0 -0
- {maleo_identity-0.1.9 → maleo_identity-0.1.11}/src/enums/user.py +0 -0
- {maleo_identity-0.1.9 → maleo_identity-0.1.11}/src/enums/user_medical_role.py +0 -0
- {maleo_identity-0.1.9 → maleo_identity-0.1.11}/src/enums/user_organization_role.py +0 -0
- {maleo_identity-0.1.9 → maleo_identity-0.1.11}/src/enums/user_profile.py +0 -0
- {maleo_identity-0.1.9 → maleo_identity-0.1.11}/src/enums/user_system_role.py +0 -0
- {maleo_identity-0.1.9 → maleo_identity-0.1.11}/src/mixins/__init__.py +0 -0
- {maleo_identity-0.1.9 → maleo_identity-0.1.11}/src/mixins/common.py +0 -0
- {maleo_identity-0.1.9 → maleo_identity-0.1.11}/src/schemas/__init__.py +0 -0
- {maleo_identity-0.1.9 → maleo_identity-0.1.11}/src/types/__init__.py +0 -0
- {maleo_identity-0.1.9 → maleo_identity-0.1.11}/src/types/api_key.py +0 -0
- {maleo_identity-0.1.9 → maleo_identity-0.1.11}/src/types/organization.py +0 -0
- {maleo_identity-0.1.9 → maleo_identity-0.1.11}/src/types/organization_registration_code.py +0 -0
- {maleo_identity-0.1.9 → maleo_identity-0.1.11}/src/types/organization_relation.py +0 -0
- {maleo_identity-0.1.9 → maleo_identity-0.1.11}/src/types/patient.py +0 -0
- {maleo_identity-0.1.9 → maleo_identity-0.1.11}/src/types/user.py +0 -0
- {maleo_identity-0.1.9 → maleo_identity-0.1.11}/src/types/user_medical_role.py +0 -0
- {maleo_identity-0.1.9 → maleo_identity-0.1.11}/src/types/user_organization_role.py +0 -0
- {maleo_identity-0.1.9 → maleo_identity-0.1.11}/src/types/user_profile.py +0 -0
- {maleo_identity-0.1.9 → maleo_identity-0.1.11}/src/types/user_system_role.py +0 -0
- {maleo_identity-0.1.9 → maleo_identity-0.1.11}/src/utils/__init__.py +0 -0
- {maleo_identity-0.1.9 → maleo_identity-0.1.11}/src/utils/organization.py +0 -0
- {maleo_identity-0.1.9 → maleo_identity-0.1.11}/src/utils/user.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: maleo-identity
|
|
3
|
-
Version: 0.1.
|
|
3
|
+
Version: 0.1.11
|
|
4
4
|
Summary: MaleoIdentity service package
|
|
5
5
|
Author-email: Agra Bima Yuda <agra@nexmedis.com>
|
|
6
6
|
License: Proprietary
|
|
@@ -41,13 +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.
|
|
45
|
-
Requires-Dist: maleo-enums>=0.0.
|
|
46
|
-
Requires-Dist: maleo-logging>=0.0.
|
|
47
|
-
Requires-Dist: maleo-
|
|
48
|
-
Requires-Dist: maleo-
|
|
49
|
-
Requires-Dist: maleo-
|
|
50
|
-
Requires-Dist: maleo-utils>=0.0.46
|
|
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.1.80
|
|
48
|
+
Requires-Dist: maleo-types>=0.0.50
|
|
49
|
+
Requires-Dist: maleo-utils>=0.0.50
|
|
51
50
|
Requires-Dist: mypy_extensions>=1.1.0
|
|
52
51
|
Requires-Dist: nodeenv>=1.9.1
|
|
53
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.1.
|
|
3
|
+
Version: 0.1.11
|
|
4
4
|
Summary: MaleoIdentity service package
|
|
5
5
|
Author-email: Agra Bima Yuda <agra@nexmedis.com>
|
|
6
6
|
License: Proprietary
|
|
@@ -41,13 +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.
|
|
45
|
-
Requires-Dist: maleo-enums>=0.0.
|
|
46
|
-
Requires-Dist: maleo-logging>=0.0.
|
|
47
|
-
Requires-Dist: maleo-
|
|
48
|
-
Requires-Dist: maleo-
|
|
49
|
-
Requires-Dist: maleo-
|
|
50
|
-
Requires-Dist: maleo-utils>=0.0.46
|
|
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.1.80
|
|
48
|
+
Requires-Dist: maleo-types>=0.0.50
|
|
49
|
+
Requires-Dist: maleo-utils>=0.0.50
|
|
51
50
|
Requires-Dist: mypy_extensions>=1.1.0
|
|
52
51
|
Requires-Dist: nodeenv>=1.9.1
|
|
53
52
|
Requires-Dist: opentelemetry-api>=1.37.0
|
|
@@ -38,7 +38,10 @@ src/mixins/organization_registration_code.py
|
|
|
38
38
|
src/mixins/organization_relation.py
|
|
39
39
|
src/mixins/patient.py
|
|
40
40
|
src/mixins/user.py
|
|
41
|
+
src/mixins/user_medical_role.py
|
|
42
|
+
src/mixins/user_organization_role.py
|
|
41
43
|
src/mixins/user_profile.py
|
|
44
|
+
src/mixins/user_system_role.py
|
|
42
45
|
src/schemas/__init__.py
|
|
43
46
|
src/schemas/api_key.py
|
|
44
47
|
src/schemas/common.py
|
|
@@ -32,13 +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.
|
|
36
|
-
maleo-enums>=0.0.
|
|
37
|
-
maleo-logging>=0.0.
|
|
38
|
-
maleo-
|
|
39
|
-
maleo-
|
|
40
|
-
maleo-
|
|
41
|
-
maleo-utils>=0.0.46
|
|
35
|
+
maleo-crypto>=0.0.50
|
|
36
|
+
maleo-enums>=0.0.50
|
|
37
|
+
maleo-logging>=0.0.50
|
|
38
|
+
maleo-schemas>=0.1.80
|
|
39
|
+
maleo-types>=0.0.50
|
|
40
|
+
maleo-utils>=0.0.50
|
|
42
41
|
mypy_extensions>=1.1.0
|
|
43
42
|
nodeenv>=1.9.1
|
|
44
43
|
opentelemetry-api>=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.
|
|
7
|
+
version = "0.1.11"
|
|
8
8
|
description = "MaleoIdentity service package"
|
|
9
9
|
authors = [
|
|
10
10
|
{ name = "Agra Bima Yuda", email = "agra@nexmedis.com" }
|
|
@@ -47,13 +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.
|
|
51
|
-
"maleo-enums>=0.0.
|
|
52
|
-
"maleo-logging>=0.0.
|
|
53
|
-
"maleo-
|
|
54
|
-
"maleo-
|
|
55
|
-
"maleo-
|
|
56
|
-
"maleo-utils>=0.0.46",
|
|
50
|
+
"maleo-crypto>=0.0.50",
|
|
51
|
+
"maleo-enums>=0.0.50",
|
|
52
|
+
"maleo-logging>=0.0.50",
|
|
53
|
+
"maleo-schemas>=0.1.80",
|
|
54
|
+
"maleo-types>=0.0.50",
|
|
55
|
+
"maleo-utils>=0.0.50",
|
|
57
56
|
"mypy_extensions>=1.1.0",
|
|
58
57
|
"nodeenv>=1.9.1",
|
|
59
58
|
"opentelemetry-api>=1.37.0",
|
|
@@ -0,0 +1,67 @@
|
|
|
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 ..enums.api_key import IdentifierType
|
|
6
|
+
from ..types.api_key import CompositeIdentifier, IdentifierValueType
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
class APIKey(BaseModel):
|
|
10
|
+
api_key: Annotated[str, Field(..., description="API Key", max_length=255)]
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
class APIKeyIdentifier(Identifier[IdentifierType, IdentifierValueType]):
|
|
14
|
+
pass
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
class IdAPIKeyIdentifier(Identifier[Literal[IdentifierType.ID], int]):
|
|
18
|
+
type: Annotated[
|
|
19
|
+
Literal[IdentifierType.ID],
|
|
20
|
+
Field(IdentifierType.ID, description="Identifier's type"),
|
|
21
|
+
] = IdentifierType.ID
|
|
22
|
+
value: Annotated[int, Field(..., description="Identifier's value", ge=1)]
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
class UUIDAPIKeyIdentifier(Identifier[Literal[IdentifierType.UUID], UUID]):
|
|
26
|
+
type: Annotated[
|
|
27
|
+
Literal[IdentifierType.UUID],
|
|
28
|
+
Field(IdentifierType.UUID, description="Identifier's type"),
|
|
29
|
+
] = IdentifierType.UUID
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
class CompositeAPIKeyIdentifier(
|
|
33
|
+
Identifier[Literal[IdentifierType.COMPOSITE], CompositeIdentifier]
|
|
34
|
+
):
|
|
35
|
+
type: Annotated[
|
|
36
|
+
Literal[IdentifierType.COMPOSITE],
|
|
37
|
+
Field(IdentifierType.COMPOSITE, description="Identifier's type"),
|
|
38
|
+
] = IdentifierType.COMPOSITE
|
|
39
|
+
value: Annotated[CompositeIdentifier, Field(..., description="Identifier's value")]
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
AnyAPIKeyIdentifier = (
|
|
43
|
+
APIKeyIdentifier
|
|
44
|
+
| IdAPIKeyIdentifier
|
|
45
|
+
| UUIDAPIKeyIdentifier
|
|
46
|
+
| CompositeAPIKeyIdentifier
|
|
47
|
+
)
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
def is_id_identifier(
|
|
51
|
+
identifier: AnyAPIKeyIdentifier,
|
|
52
|
+
) -> TypeGuard[IdAPIKeyIdentifier]:
|
|
53
|
+
return identifier.type is IdentifierType.ID and isinstance(identifier.value, int)
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
def is_uuid_identifier(
|
|
57
|
+
identifier: AnyAPIKeyIdentifier,
|
|
58
|
+
) -> TypeGuard[UUIDAPIKeyIdentifier]:
|
|
59
|
+
return identifier.type is IdentifierType.UUID and isinstance(identifier.value, UUID)
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
def is_composite_identifier(
|
|
63
|
+
identifier: AnyAPIKeyIdentifier,
|
|
64
|
+
) -> TypeGuard[CompositeAPIKeyIdentifier]:
|
|
65
|
+
return identifier.type is IdentifierType.COMPOSITE and isinstance(
|
|
66
|
+
identifier.value, tuple
|
|
67
|
+
)
|
|
@@ -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)
|
|
@@ -0,0 +1,100 @@
|
|
|
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
|
|
5
|
+
from maleo.types.integer import OptIntT
|
|
6
|
+
from maleo.types.string import OptStrT
|
|
7
|
+
from ..enums.organization_registration_code import IdentifierType
|
|
8
|
+
from ..types.organization_registration_code import IdentifierValueType
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
class Code(BaseModel, Generic[OptStrT]):
|
|
12
|
+
code: Annotated[OptStrT, Field(..., description="Code", max_length=36)]
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
class MaxUses(BaseModel, Generic[OptIntT]):
|
|
16
|
+
max_uses: Annotated[OptIntT, Field(..., description="Max Uses", ge=1)]
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
class CurrentUses(BaseModel):
|
|
20
|
+
current_uses: Annotated[int, Field(0, description="Current Uses", ge=0)] = 0
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
class OrganizationRegistrationCodeIdentifier(
|
|
24
|
+
Identifier[IdentifierType, IdentifierValueType]
|
|
25
|
+
):
|
|
26
|
+
pass
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
class IdOrganizationRegistrationCodeIdentifier(
|
|
30
|
+
Identifier[Literal[IdentifierType.ID], int]
|
|
31
|
+
):
|
|
32
|
+
type: Annotated[
|
|
33
|
+
Literal[IdentifierType.ID],
|
|
34
|
+
Field(IdentifierType.ID, description="Identifier's type"),
|
|
35
|
+
] = IdentifierType.ID
|
|
36
|
+
value: Annotated[int, Field(..., description="Identifier's value", ge=1)]
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
class OrgIdOrganizationRegistrationCodeIdentifier(
|
|
40
|
+
Identifier[Literal[IdentifierType.ORGANIZATION_ID], int]
|
|
41
|
+
):
|
|
42
|
+
type: Annotated[
|
|
43
|
+
Literal[IdentifierType.ORGANIZATION_ID],
|
|
44
|
+
Field(IdentifierType.ORGANIZATION_ID, description="Identifier's type"),
|
|
45
|
+
] = IdentifierType.ORGANIZATION_ID
|
|
46
|
+
value: Annotated[int, Field(..., description="Identifier's value", ge=1)]
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
class UUIDOrganizationRegistrationCodeIdentifier(
|
|
50
|
+
Identifier[Literal[IdentifierType.UUID], UUID]
|
|
51
|
+
):
|
|
52
|
+
type: Annotated[
|
|
53
|
+
Literal[IdentifierType.UUID],
|
|
54
|
+
Field(IdentifierType.UUID, description="Identifier's type"),
|
|
55
|
+
] = IdentifierType.UUID
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
class CodeOrganizationRegistrationCodeIdentifier(
|
|
59
|
+
Identifier[Literal[IdentifierType.CODE], str]
|
|
60
|
+
):
|
|
61
|
+
type: Annotated[
|
|
62
|
+
Literal[IdentifierType.CODE],
|
|
63
|
+
Field(IdentifierType.CODE, description="Identifier's type"),
|
|
64
|
+
] = IdentifierType.CODE
|
|
65
|
+
value: Annotated[str, Field(..., description="Identifier's value", max_length=36)]
|
|
66
|
+
|
|
67
|
+
|
|
68
|
+
AnyOrganizationRegistrationCodeIdentifier = (
|
|
69
|
+
OrganizationRegistrationCodeIdentifier
|
|
70
|
+
| IdOrganizationRegistrationCodeIdentifier
|
|
71
|
+
| OrgIdOrganizationRegistrationCodeIdentifier
|
|
72
|
+
| UUIDOrganizationRegistrationCodeIdentifier
|
|
73
|
+
| CodeOrganizationRegistrationCodeIdentifier
|
|
74
|
+
)
|
|
75
|
+
|
|
76
|
+
|
|
77
|
+
def is_id_identifier(
|
|
78
|
+
identifier: AnyOrganizationRegistrationCodeIdentifier,
|
|
79
|
+
) -> TypeGuard[IdOrganizationRegistrationCodeIdentifier]:
|
|
80
|
+
return identifier.type is IdentifierType.ID and isinstance(identifier.value, int)
|
|
81
|
+
|
|
82
|
+
|
|
83
|
+
def is_org_id_identifier(
|
|
84
|
+
identifier: AnyOrganizationRegistrationCodeIdentifier,
|
|
85
|
+
) -> TypeGuard[OrgIdOrganizationRegistrationCodeIdentifier]:
|
|
86
|
+
return identifier.type is IdentifierType.ORGANIZATION_ID and isinstance(
|
|
87
|
+
identifier.value, int
|
|
88
|
+
)
|
|
89
|
+
|
|
90
|
+
|
|
91
|
+
def is_uuid_identifier(
|
|
92
|
+
identifier: AnyOrganizationRegistrationCodeIdentifier,
|
|
93
|
+
) -> TypeGuard[UUIDOrganizationRegistrationCodeIdentifier]:
|
|
94
|
+
return identifier.type is IdentifierType.UUID and isinstance(identifier.value, UUID)
|
|
95
|
+
|
|
96
|
+
|
|
97
|
+
def is_code_identifier(
|
|
98
|
+
identifier: AnyOrganizationRegistrationCodeIdentifier,
|
|
99
|
+
) -> TypeGuard[CodeOrganizationRegistrationCodeIdentifier]:
|
|
100
|
+
return identifier.type is IdentifierType.CODE and isinstance(identifier.value, str)
|
|
@@ -0,0 +1,75 @@
|
|
|
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
|
|
5
|
+
from maleo.types.boolean import OptBoolT
|
|
6
|
+
from maleo.types.misc import OptListOfAnyOrStrToAnyDict
|
|
7
|
+
from ..enums.organization_relation import IdentifierType
|
|
8
|
+
from ..types.organization_relation import CompositeIdentifier, IdentifierValueType
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
class IsBidirectional(BaseModel, Generic[OptBoolT]):
|
|
12
|
+
is_bidirectional: Annotated[OptBoolT, Field(..., description="Is Bidirectional")]
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
class Meta(BaseModel):
|
|
16
|
+
meta: Annotated[OptListOfAnyOrStrToAnyDict, Field(None, description="Meta")] = None
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
class OrganizationRelationIdentifier(Identifier[IdentifierType, IdentifierValueType]):
|
|
20
|
+
pass
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
class IdOrganizationRelationIdentifier(Identifier[Literal[IdentifierType.ID], int]):
|
|
24
|
+
type: Annotated[
|
|
25
|
+
Literal[IdentifierType.ID],
|
|
26
|
+
Field(IdentifierType.ID, description="Identifier's type"),
|
|
27
|
+
] = IdentifierType.ID
|
|
28
|
+
value: Annotated[int, Field(..., description="Identifier's value", ge=1)]
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
class UUIDOrganizationRelationIdentifier(
|
|
32
|
+
Identifier[Literal[IdentifierType.UUID], UUID]
|
|
33
|
+
):
|
|
34
|
+
type: Annotated[
|
|
35
|
+
Literal[IdentifierType.UUID],
|
|
36
|
+
Field(IdentifierType.UUID, description="Identifier's type"),
|
|
37
|
+
] = IdentifierType.UUID
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
class CompositeOrganizationRelationIdentifier(
|
|
41
|
+
Identifier[Literal[IdentifierType.COMPOSITE], CompositeIdentifier]
|
|
42
|
+
):
|
|
43
|
+
type: Annotated[
|
|
44
|
+
Literal[IdentifierType.COMPOSITE],
|
|
45
|
+
Field(IdentifierType.COMPOSITE, description="Identifier's type"),
|
|
46
|
+
] = IdentifierType.COMPOSITE
|
|
47
|
+
value: Annotated[CompositeIdentifier, Field(..., description="Identifier's value")]
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
AnyOrganizationRelationIdentifier = (
|
|
51
|
+
OrganizationRelationIdentifier
|
|
52
|
+
| IdOrganizationRelationIdentifier
|
|
53
|
+
| UUIDOrganizationRelationIdentifier
|
|
54
|
+
| CompositeOrganizationRelationIdentifier
|
|
55
|
+
)
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
def is_id_identifier(
|
|
59
|
+
identifier: AnyOrganizationRelationIdentifier,
|
|
60
|
+
) -> TypeGuard[IdOrganizationRelationIdentifier]:
|
|
61
|
+
return identifier.type is IdentifierType.ID and isinstance(identifier.value, int)
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
def is_uuid_identifier(
|
|
65
|
+
identifier: AnyOrganizationRelationIdentifier,
|
|
66
|
+
) -> TypeGuard[UUIDOrganizationRelationIdentifier]:
|
|
67
|
+
return identifier.type is IdentifierType.UUID and isinstance(identifier.value, UUID)
|
|
68
|
+
|
|
69
|
+
|
|
70
|
+
def is_composite_identifier(
|
|
71
|
+
identifier: AnyOrganizationRelationIdentifier,
|
|
72
|
+
) -> TypeGuard[CompositeOrganizationRelationIdentifier]:
|
|
73
|
+
return identifier.type is IdentifierType.COMPOSITE and isinstance(
|
|
74
|
+
identifier.value, tuple
|
|
75
|
+
)
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
from pydantic import Field, model_validator
|
|
2
|
+
from typing import Annotated, Generic, Literal, Self, TypeGuard
|
|
3
|
+
from uuid import UUID
|
|
4
|
+
from maleo.schemas.mixins.identity import Identifier
|
|
5
|
+
from maleo.schemas.mixins.identity import Passport as BasePassport
|
|
6
|
+
from maleo.types.string import OptStr, OptStrT
|
|
7
|
+
from ..enums.patient import IdentifierType
|
|
8
|
+
from ..types.patient import IdentifierValueType
|
|
9
|
+
from .common import IdCard
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
class Passport(BasePassport, Generic[OptStrT]):
|
|
13
|
+
passport: Annotated[OptStrT, Field(..., description="Passport", max_length=9)]
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
class PatientIdentity(
|
|
17
|
+
Passport[OptStr],
|
|
18
|
+
IdCard[OptStr],
|
|
19
|
+
):
|
|
20
|
+
@model_validator(mode="after")
|
|
21
|
+
def chk_id_card_or_passport(self) -> Self:
|
|
22
|
+
if self.id_card is None and self.passport is None:
|
|
23
|
+
raise ValueError("Either ID Card or Passport must exist")
|
|
24
|
+
return self
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
class PatientIdentifier(Identifier[IdentifierType, IdentifierValueType]):
|
|
28
|
+
pass
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
class IdPatientIdentifier(Identifier[Literal[IdentifierType.ID], int]):
|
|
32
|
+
type: Annotated[
|
|
33
|
+
Literal[IdentifierType.ID],
|
|
34
|
+
Field(IdentifierType.ID, description="Identifier's type"),
|
|
35
|
+
] = IdentifierType.ID
|
|
36
|
+
value: Annotated[int, Field(..., description="Identifier's value", ge=1)]
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
class UUIDPatientIdentifier(Identifier[Literal[IdentifierType.UUID], UUID]):
|
|
40
|
+
type: Annotated[
|
|
41
|
+
Literal[IdentifierType.UUID],
|
|
42
|
+
Field(IdentifierType.UUID, description="Identifier's type"),
|
|
43
|
+
] = IdentifierType.UUID
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
class IdCardPatientIdentifier(Identifier[Literal[IdentifierType.ID_CARD], str]):
|
|
47
|
+
type: Annotated[
|
|
48
|
+
Literal[IdentifierType.ID_CARD],
|
|
49
|
+
Field(IdentifierType.ID_CARD, description="Identifier's type"),
|
|
50
|
+
] = IdentifierType.ID_CARD
|
|
51
|
+
value: Annotated[str, Field(..., description="Identifier's value", max_length=16)]
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
class PassportPatientIdentifier(Identifier[Literal[IdentifierType.PASSPORT], str]):
|
|
55
|
+
type: Annotated[
|
|
56
|
+
Literal[IdentifierType.PASSPORT],
|
|
57
|
+
Field(IdentifierType.PASSPORT, description="Identifier's type"),
|
|
58
|
+
] = IdentifierType.PASSPORT
|
|
59
|
+
value: Annotated[str, Field(..., description="Identifier's value", max_length=9)]
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
AnyPatientIdentifier = (
|
|
63
|
+
PatientIdentifier
|
|
64
|
+
| IdPatientIdentifier
|
|
65
|
+
| UUIDPatientIdentifier
|
|
66
|
+
| IdCardPatientIdentifier
|
|
67
|
+
| PassportPatientIdentifier
|
|
68
|
+
)
|
|
69
|
+
|
|
70
|
+
|
|
71
|
+
def is_id_identifier(
|
|
72
|
+
identifier: AnyPatientIdentifier,
|
|
73
|
+
) -> TypeGuard[IdPatientIdentifier]:
|
|
74
|
+
return identifier.type is IdentifierType.ID and isinstance(identifier.value, int)
|
|
75
|
+
|
|
76
|
+
|
|
77
|
+
def is_uuid_identifier(
|
|
78
|
+
identifier: AnyPatientIdentifier,
|
|
79
|
+
) -> TypeGuard[UUIDPatientIdentifier]:
|
|
80
|
+
return identifier.type is IdentifierType.UUID and isinstance(identifier.value, UUID)
|
|
81
|
+
|
|
82
|
+
|
|
83
|
+
def is_id_card_identifier(
|
|
84
|
+
identifier: AnyPatientIdentifier,
|
|
85
|
+
) -> TypeGuard[IdCardPatientIdentifier]:
|
|
86
|
+
return identifier.type is IdentifierType.ID_CARD and isinstance(
|
|
87
|
+
identifier.value, str
|
|
88
|
+
)
|
|
89
|
+
|
|
90
|
+
|
|
91
|
+
def is_passport_identifier(
|
|
92
|
+
identifier: AnyPatientIdentifier,
|
|
93
|
+
) -> TypeGuard[PassportPatientIdentifier]:
|
|
94
|
+
return identifier.type is IdentifierType.PASSPORT and isinstance(
|
|
95
|
+
identifier.value, str
|
|
96
|
+
)
|
|
@@ -0,0 +1,107 @@
|
|
|
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
|
|
5
|
+
from maleo.types.string import OptStrT, OptListOfStrsT
|
|
6
|
+
from ..enums.user import IdentifierType
|
|
7
|
+
from ..types.user import IdentifierValueType
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
class Username(BaseModel, Generic[OptStrT]):
|
|
11
|
+
username: Annotated[
|
|
12
|
+
OptStrT, Field(..., description="User's username", max_length=50)
|
|
13
|
+
]
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
class Usernames(BaseModel, Generic[OptListOfStrsT]):
|
|
17
|
+
usernames: Annotated[OptListOfStrsT, Field(..., description="User's Usernames")]
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
class Email(BaseModel, Generic[OptStrT]):
|
|
21
|
+
email: Annotated[OptStrT, Field(..., description="User's email", max_length=255)]
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
class Emails(BaseModel, Generic[OptListOfStrsT]):
|
|
25
|
+
emails: Annotated[OptListOfStrsT, Field(..., description="User's Emails")]
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
class Phone(BaseModel, Generic[OptStrT]):
|
|
29
|
+
phone: Annotated[OptStrT, Field(..., description="User's phone", max_length=15)]
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
class Phones(BaseModel, Generic[OptListOfStrsT]):
|
|
33
|
+
phones: Annotated[OptListOfStrsT, Field(..., description="User's Phones")]
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
class Password(BaseModel):
|
|
37
|
+
password: Annotated[str, Field(..., description="Password", max_length=255)]
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
class UserIdentifier(Identifier[IdentifierType, IdentifierValueType]):
|
|
41
|
+
pass
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
class IdUserIdentifier(Identifier[Literal[IdentifierType.ID], int]):
|
|
45
|
+
type: Annotated[
|
|
46
|
+
Literal[IdentifierType.ID],
|
|
47
|
+
Field(IdentifierType.ID, description="Identifier's type"),
|
|
48
|
+
] = IdentifierType.ID
|
|
49
|
+
value: Annotated[int, Field(..., description="Identifier's value", ge=1)]
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
class UUIDUserIdentifier(Identifier[Literal[IdentifierType.UUID], UUID]):
|
|
53
|
+
type: Annotated[
|
|
54
|
+
Literal[IdentifierType.UUID],
|
|
55
|
+
Field(IdentifierType.UUID, description="Identifier's type"),
|
|
56
|
+
] = IdentifierType.UUID
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
class UsernameUserIdentifier(Identifier[Literal[IdentifierType.USERNAME], str]):
|
|
60
|
+
type: Annotated[
|
|
61
|
+
Literal[IdentifierType.USERNAME],
|
|
62
|
+
Field(IdentifierType.USERNAME, description="Identifier's type"),
|
|
63
|
+
] = IdentifierType.USERNAME
|
|
64
|
+
value: Annotated[str, Field(..., description="Identifier's value", max_length=50)]
|
|
65
|
+
|
|
66
|
+
|
|
67
|
+
class EmailUserIdentifier(Identifier[Literal[IdentifierType.EMAIL], str]):
|
|
68
|
+
type: Annotated[
|
|
69
|
+
Literal[IdentifierType.EMAIL],
|
|
70
|
+
Field(IdentifierType.EMAIL, description="Identifier's type"),
|
|
71
|
+
] = IdentifierType.EMAIL
|
|
72
|
+
value: Annotated[str, Field(..., description="Identifier's value", max_length=255)]
|
|
73
|
+
|
|
74
|
+
|
|
75
|
+
AnyUserIdentifier = (
|
|
76
|
+
UserIdentifier
|
|
77
|
+
| IdUserIdentifier
|
|
78
|
+
| UUIDUserIdentifier
|
|
79
|
+
| UsernameUserIdentifier
|
|
80
|
+
| EmailUserIdentifier
|
|
81
|
+
)
|
|
82
|
+
|
|
83
|
+
|
|
84
|
+
def is_id_identifier(
|
|
85
|
+
identifier: AnyUserIdentifier,
|
|
86
|
+
) -> TypeGuard[IdUserIdentifier]:
|
|
87
|
+
return identifier.type is IdentifierType.ID and isinstance(identifier.value, int)
|
|
88
|
+
|
|
89
|
+
|
|
90
|
+
def is_uuid_identifier(
|
|
91
|
+
identifier: AnyUserIdentifier,
|
|
92
|
+
) -> TypeGuard[UUIDUserIdentifier]:
|
|
93
|
+
return identifier.type is IdentifierType.UUID and isinstance(identifier.value, UUID)
|
|
94
|
+
|
|
95
|
+
|
|
96
|
+
def is_username_identifier(
|
|
97
|
+
identifier: AnyUserIdentifier,
|
|
98
|
+
) -> TypeGuard[UsernameUserIdentifier]:
|
|
99
|
+
return identifier.type is IdentifierType.USERNAME and isinstance(
|
|
100
|
+
identifier.value, str
|
|
101
|
+
)
|
|
102
|
+
|
|
103
|
+
|
|
104
|
+
def is_email_identifier(
|
|
105
|
+
identifier: AnyUserIdentifier,
|
|
106
|
+
) -> TypeGuard[EmailUserIdentifier]:
|
|
107
|
+
return identifier.type is IdentifierType.EMAIL and isinstance(identifier.value, str)
|