ipulse-shared-core-ftredge 3.2.2__tar.gz → 3.2.3__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 ipulse-shared-core-ftredge might be problematic. Click here for more details.

Files changed (25) hide show
  1. {ipulse_shared_core_ftredge-3.2.2/src/ipulse_shared_core_ftredge.egg-info → ipulse_shared_core_ftredge-3.2.3}/PKG-INFO +2 -2
  2. {ipulse_shared_core_ftredge-3.2.2 → ipulse_shared_core_ftredge-3.2.3}/setup.py +2 -2
  3. {ipulse_shared_core_ftredge-3.2.2 → ipulse_shared_core_ftredge-3.2.3}/src/ipulse_shared_core_ftredge/__init__.py +2 -1
  4. {ipulse_shared_core_ftredge-3.2.2 → ipulse_shared_core_ftredge-3.2.3}/src/ipulse_shared_core_ftredge/models/__init__.py +1 -0
  5. ipulse_shared_core_ftredge-3.2.3/src/ipulse_shared_core_ftredge/models/organisation.py +87 -0
  6. ipulse_shared_core_ftredge-3.2.3/src/ipulse_shared_core_ftredge/models/user_auth.py +9 -0
  7. ipulse_shared_core_ftredge-3.2.3/src/ipulse_shared_core_ftredge/models/user_profile.py +76 -0
  8. ipulse_shared_core_ftredge-3.2.3/src/ipulse_shared_core_ftredge/models/user_profile_update.py +45 -0
  9. ipulse_shared_core_ftredge-3.2.3/src/ipulse_shared_core_ftredge/models/user_status.py +93 -0
  10. {ipulse_shared_core_ftredge-3.2.2 → ipulse_shared_core_ftredge-3.2.3/src/ipulse_shared_core_ftredge.egg-info}/PKG-INFO +2 -2
  11. {ipulse_shared_core_ftredge-3.2.2 → ipulse_shared_core_ftredge-3.2.3}/src/ipulse_shared_core_ftredge.egg-info/requires.txt +1 -1
  12. ipulse_shared_core_ftredge-3.2.2/src/ipulse_shared_core_ftredge/models/organisation.py +0 -71
  13. ipulse_shared_core_ftredge-3.2.2/src/ipulse_shared_core_ftredge/models/user_auth.py +0 -6
  14. ipulse_shared_core_ftredge-3.2.2/src/ipulse_shared_core_ftredge/models/user_profile.py +0 -41
  15. ipulse_shared_core_ftredge-3.2.2/src/ipulse_shared_core_ftredge/models/user_profile_update.py +0 -36
  16. ipulse_shared_core_ftredge-3.2.2/src/ipulse_shared_core_ftredge/models/user_status.py +0 -51
  17. {ipulse_shared_core_ftredge-3.2.2 → ipulse_shared_core_ftredge-3.2.3}/LICENCE +0 -0
  18. {ipulse_shared_core_ftredge-3.2.2 → ipulse_shared_core_ftredge-3.2.3}/README.md +0 -0
  19. {ipulse_shared_core_ftredge-3.2.2 → ipulse_shared_core_ftredge-3.2.3}/pyproject.toml +0 -0
  20. {ipulse_shared_core_ftredge-3.2.2 → ipulse_shared_core_ftredge-3.2.3}/setup.cfg +0 -0
  21. {ipulse_shared_core_ftredge-3.2.2 → ipulse_shared_core_ftredge-3.2.3}/src/ipulse_shared_core_ftredge/models/resource_catalog_item.py +0 -0
  22. {ipulse_shared_core_ftredge-3.2.2 → ipulse_shared_core_ftredge-3.2.3}/src/ipulse_shared_core_ftredge.egg-info/SOURCES.txt +0 -0
  23. {ipulse_shared_core_ftredge-3.2.2 → ipulse_shared_core_ftredge-3.2.3}/src/ipulse_shared_core_ftredge.egg-info/dependency_links.txt +0 -0
  24. {ipulse_shared_core_ftredge-3.2.2 → ipulse_shared_core_ftredge-3.2.3}/src/ipulse_shared_core_ftredge.egg-info/top_level.txt +0 -0
  25. {ipulse_shared_core_ftredge-3.2.2 → ipulse_shared_core_ftredge-3.2.3}/tests/test_utils_gcp.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.2
2
2
  Name: ipulse_shared_core_ftredge
3
- Version: 3.2.2
3
+ Version: 3.2.3
4
4
  Summary: Shared Core models and Logger util for the Pulse platform project. Using AI for financial advisory and investment management.
5
5
  Home-page: https://github.com/TheFutureEdge/ipulse_shared_core
6
6
  Author: Russlan Ramdowar
@@ -8,7 +8,7 @@ License-File: LICENCE
8
8
  Requires-Dist: pydantic[email]~=2.5
9
9
  Requires-Dist: python-dateutil~=2.8
10
10
  Requires-Dist: pytest~=7.1
11
- Requires-Dist: ipulse_shared_base_ftredge>=2.2.2
11
+ Requires-Dist: ipulse_shared_base_ftredge>=3.4.2
12
12
  Dynamic: author
13
13
  Dynamic: home-page
14
14
  Dynamic: requires-dist
@@ -3,7 +3,7 @@ from setuptools import setup, find_packages
3
3
 
4
4
  setup(
5
5
  name='ipulse_shared_core_ftredge',
6
- version='3.2.2',
6
+ version='3.2.3',
7
7
  package_dir={'': 'src'}, # Specify the source directory
8
8
  packages=find_packages(where='src'), # Look for packages in 'src'
9
9
  install_requires=[
@@ -11,7 +11,7 @@ setup(
11
11
  'pydantic[email]~=2.5',
12
12
  'python-dateutil~=2.8',
13
13
  'pytest~=7.1',
14
- 'ipulse_shared_base_ftredge>=2.2.2',
14
+ 'ipulse_shared_base_ftredge>=3.4.2',
15
15
  ],
16
16
  author='Russlan Ramdowar',
17
17
  description='Shared Core models and Logger util for the Pulse platform project. Using AI for financial advisory and investment management.',
@@ -1,3 +1,4 @@
1
1
  # pylint: disable=missing-module-docstring
2
2
  from .models import ( UserAuth, UserProfile,
3
- UserStatus, UserProfileUpdate)
3
+ UserStatus, UserProfileUpdate,
4
+ Organisation)
@@ -2,6 +2,7 @@ from .user_profile import UserProfile
2
2
  from .user_status import UserStatus
3
3
  from .user_profile_update import UserProfileUpdate
4
4
  from .user_auth import UserAuth
5
+ from .organisation import Organisation
5
6
 
6
7
 
7
8
 
@@ -0,0 +1,87 @@
1
+ # pylint: disable=missing-module-docstring
2
+ # pylint: disable=missing-function-docstring
3
+ # pylint: disable=missing-class-docstring
4
+ # pylint: disable=broad-exception-caught
5
+ # pylint: disable=line-too-long
6
+ # pylint: disable=unused-variable
7
+ # pylint: disable=broad-exception-caught
8
+ # pylint: disable=no-self-argument # Added for Pydantic validators
9
+ from datetime import datetime
10
+ from typing import Set, Optional, ClassVar
11
+ from pydantic import BaseModel, field_validator, Field, ConfigDict
12
+ import uuid
13
+ import dateutil.parser
14
+ from ipulse_shared_base_ftredge import (
15
+ OrganizationRelation,
16
+ OrganizationIndustry
17
+ )
18
+
19
+ class Organisation(BaseModel):
20
+ """
21
+ Organisation model representing business entities in the system.
22
+ Supports both retail and non-retail customer types with different validation rules.
23
+ """
24
+ model_config = ConfigDict(frozen=True, extra="forbid")
25
+
26
+ # Class constants
27
+ VERSION: ClassVar[float] = 1.0
28
+ MODULE: ClassVar[str] = "core"
29
+ CLASS_REF: ClassVar[str] = "orgn"
30
+
31
+ # Required fields
32
+ puid: str = Field(
33
+ default_factory=lambda: f"{datetime.utcnow().strftime('%Y%m%d%H%M%S')}_{uuid.uuid4().hex[:8]}_{Organisation.MODULE}{Organisation.CLASS_REF}".lower(),
34
+ description="Unique identifier for the organisation"
35
+ )
36
+ name: str = Field(..., min_length=1, max_length=100)
37
+ relations: Set[OrganizationRelation] = Field(..., description="Organisation relations/types")
38
+
39
+ # Timestamps
40
+ creat_date: datetime = Field(default_factory=datetime.utcnow)
41
+ updt_date: datetime = Field(default_factory=datetime.utcnow)
42
+
43
+ # Optional fields
44
+ creat_by_user: Optional[str] = Field(None, max_length=100)
45
+ updt_by_user: Optional[str] = Field(None, max_length=100)
46
+ description: Optional[str] = Field(None, max_length=1000)
47
+ industries: Optional[Set[OrganizationIndustry]] = None
48
+ website: Optional[str] = Field(None, max_length=200)
49
+ org_admin_user_uids: Optional[Set[str]] = None
50
+
51
+ @field_validator('relations')
52
+ @classmethod
53
+ def validate_relations(cls, v: Set[OrganizationRelation]) -> Set[OrganizationRelation]:
54
+ return v
55
+
56
+ @field_validator('industries')
57
+ @classmethod
58
+ def validate_industries(cls, v: Optional[Set[OrganizationIndustry]], info) -> Optional[Set[OrganizationIndustry]]:
59
+ values = info.data
60
+ is_retail = values.get('relations') == {OrganizationRelation.RETAIL_CUSTOMER}
61
+ if is_retail and v is not None:
62
+ raise ValueError("Industries should not be set for retail customers")
63
+ elif not is_retail and v is None:
64
+ raise ValueError("Industries required for non-retail customers")
65
+ return v
66
+
67
+ @field_validator('website', 'description')
68
+ @classmethod
69
+ def validate_retail_fields(cls, v: Optional[str], info) -> Optional[str]:
70
+ values = info.data
71
+ field = info.field_name
72
+ is_retail = values.get('relations') == {OrganizationRelation.RETAIL_CUSTOMER}
73
+ if is_retail and v is not None:
74
+ raise ValueError(f"{field} should not be set for retail customers")
75
+ elif not is_retail and not v:
76
+ raise ValueError(f"{field} required for non-retail customers")
77
+ return v
78
+
79
+ @field_validator('creat_date', 'updt_date', mode='before')
80
+ @classmethod
81
+ def parse_datetime(cls, v: any) -> datetime:
82
+ if isinstance(v, datetime):
83
+ return v
84
+ try:
85
+ return dateutil.parser.isoparse(v)
86
+ except (TypeError, ValueError) as e:
87
+ raise ValueError(f"Invalid datetime format: {e}")
@@ -0,0 +1,9 @@
1
+ from pydantic import BaseModel, Field, EmailStr, ConfigDict
2
+
3
+ class UserAuth(BaseModel):
4
+ """Authentication model for user credentials"""
5
+ model_config = ConfigDict(extra="forbid")
6
+
7
+ email: EmailStr = Field(..., description="User's email address")
8
+ password: str = Field(..., min_length=6, description="User's password")
9
+ extra_fields: dict = Field(default_factory=dict, description="Additional authentication fields")
@@ -0,0 +1,76 @@
1
+ from datetime import datetime, date
2
+ from typing import Set, Optional, ClassVar
3
+ from pydantic import BaseModel, EmailStr, Field, ConfigDict
4
+
5
+ class UserProfile(BaseModel):
6
+ """
7
+ User Profile model representing user information and metadata.
8
+ Contains both system-managed and user-editable fields.
9
+ """
10
+ model_config = ConfigDict(frozen=True, extra="forbid")
11
+
12
+ # Metadata as class variables
13
+ VERSION: ClassVar[float] = 3.01
14
+ DOMAIN: ClassVar[str] = "user"
15
+ OBJ_REF: ClassVar[str] = "usprfl"
16
+
17
+ # System-managed fields (read-only)
18
+ schema_version: float = Field(
19
+ default=3.01,
20
+ description="Version of this Class == version of DB Schema",
21
+ frozen=True
22
+ )
23
+ email: EmailStr = Field(
24
+ ...,
25
+ description="Propagated from Firebase Auth",
26
+ frozen=True
27
+ )
28
+ organizations_uids: Set[str] = Field(
29
+ default_factory=set,
30
+ description="Depends on Subscription Plan, Regularly Updated",
31
+ frozen=True
32
+ )
33
+
34
+ # Timestamps and audit fields (read-only)
35
+ creat_date: datetime = Field(frozen=True)
36
+ creat_by_user: str = Field(frozen=True)
37
+ updt_date: datetime = Field(frozen=True)
38
+ updt_by_user: str = Field(frozen=True)
39
+
40
+ # System identification (read-only)
41
+ provider_id: str = Field(frozen=True)
42
+ aliases: Optional[Set[str]] = Field(
43
+ default=None,
44
+ frozen=True
45
+ )
46
+
47
+ # User-editable fields
48
+ username: Optional[str] = Field(
49
+ default=None,
50
+ max_length=50,
51
+ pattern="^[a-zA-Z0-9_-]+$"
52
+ )
53
+ dob: Optional[date] = Field(
54
+ default=None,
55
+ description="Date of Birth"
56
+ )
57
+ first_name: Optional[str] = Field(
58
+ default=None,
59
+ max_length=100
60
+ )
61
+ last_name: Optional[str] = Field(
62
+ default=None,
63
+ max_length=100
64
+ )
65
+ mobile: Optional[str] = Field(
66
+ default=None,
67
+ pattern=r"^\+?[1-9]\d{1,14}$", # Added 'r' prefix for raw string
68
+ description="E.164 format phone number"
69
+ )
70
+
71
+ # Revision history (as model metadata)
72
+ CLASS_ORIGIN_AUTHOR: ClassVar[str] = "Russlan Ramdowar;russlan@ftredge.com"
73
+ CLASS_ORGIN_DATE: ClassVar[datetime] = datetime(2024, 1, 16, 20, 5)
74
+ CLASS_REVISION_AUTHOR: ClassVar[str] = "Russlan Ramdowar;russlan@ftredge.com"
75
+ CLASS_REVISION_DATE: ClassVar[datetime] = datetime(2024, 2, 13, 20, 15)
76
+ LAST_MODIFICATION: ClassVar[str] = "Updated to Pydantic v2 with improved validation"
@@ -0,0 +1,45 @@
1
+ from typing import Optional, Set, ClassVar
2
+ from pydantic import BaseModel, Field, EmailStr, ConfigDict
3
+ from datetime import date, datetime
4
+
5
+ class UserProfileUpdate(BaseModel):
6
+ """
7
+ User Profile Update model for partial updates of user information.
8
+ All fields are optional to support partial updates.
9
+ """
10
+ model_config = ConfigDict(extra="forbid")
11
+
12
+ # Metadata as class variables
13
+ VERSION: ClassVar[float] = 2.01
14
+ CLASS_ORIGIN_AUTHOR: ClassVar[str] = "Russlan Ramdowar;russlan@ftredge.com"
15
+ CLASS_ORGIN_DATE: ClassVar[datetime] = datetime(2024, 3, 15, 20, 15)
16
+ CLASS_REVISION_DATE: ClassVar[datetime] = datetime(2024, 3, 15, 20, 15)
17
+
18
+ # System fields
19
+ schema_version: Optional[float] = Field(None, description="Version of this Class == version of DB Schema")
20
+ email: Optional[EmailStr] = Field(None, description="Propagated from Firebase Auth")
21
+ organizations_uids: Optional[Set[str]] = Field(None, description="Organization memberships")
22
+
23
+ # Timestamps and audit
24
+ creat_date: Optional[datetime] = None
25
+ creat_by_user: Optional[str] = None
26
+ updt_date: Optional[datetime] = None
27
+ updt_by_user: Optional[str] = None
28
+
29
+ # System identification
30
+ aliases: Optional[Set[str]] = None
31
+ provider_id: Optional[str] = None
32
+
33
+ # User-editable fields
34
+ username: Optional[str] = Field(None, max_length=50, pattern=r"^[a-zA-Z0-9_-]+$")
35
+ dob: Optional[date] = None
36
+ first_name: Optional[str] = Field(None, max_length=100)
37
+ last_name: Optional[str] = Field(None, max_length=100)
38
+ mobile: Optional[str] = Field(None, pattern=r"^\+?[1-9]\d{1,14}$")
39
+
40
+ def model_dump(self, **kwargs):
41
+ kwargs.setdefault('exclude_none', True)
42
+ return super().model_dump(**kwargs)
43
+
44
+
45
+
@@ -0,0 +1,93 @@
1
+ from datetime import datetime
2
+ from dateutil.relativedelta import relativedelta
3
+ from typing import Set, Optional, Dict, List, ClassVar
4
+ from pydantic import BaseModel, Field, ConfigDict
5
+
6
+ # ORIGINAL AUTHOR ="Russlan Ramdowar;russlan@ftredge.com"
7
+ CLASS_ORGIN_DATE=datetime(2024, 2, 12, 20, 5)
8
+
9
+ SCHEMA_VERSION = 2.3
10
+ CLASS_REVISION_AUTHOR="Russlan Ramdowar;russlan@ftredge.com"
11
+ CLASS_REVISION_DATE=datetime(2024, 2, 13, 20, 15)
12
+ LAST_MODIFICATION="Changed default IAM_GROUPS"
13
+
14
+ DOMAIN="user"
15
+ OBJ_REF = "usrsttus"
16
+
17
+ DEFAULT_IAM_GROUPS={"pulseroot":["full_open_read"]}
18
+ DEFAULT_SUBSCRIPTION_PLAN="subscription_free"
19
+ DEFAULT_SUBSCRIPTION_STATUS="active"
20
+ DEFAULT_SUBSCRIPTION_INSIGHT_CREDITS=10
21
+ DEFAULT_EXTRA_INSIGHT_CREDITS=0
22
+
23
+ ############################################ !!!!! ALWAYS UPDATE SCHEMA VERSION , IF SCHEMA IS BEING MODIFIED !!! ############################################
24
+ class UserStatus(BaseModel):
25
+ """
26
+ User Status model for tracking user subscription and access rights.
27
+ """
28
+ model_config = ConfigDict(frozen=True, extra="forbid")
29
+
30
+ # Class constants
31
+ VERSION: ClassVar[float] = 2.3
32
+ DOMAIN: ClassVar[str] = "user"
33
+ OBJ_REF: ClassVar[str] = "usrsttus"
34
+
35
+ # Default values as class variables
36
+ DEFAULT_IAM_GROUPS: ClassVar[Dict[str, List[str]]] = {"pulseroot": ["full_open_read"]}
37
+ DEFAULT_SUBSCRIPTION_PLAN: ClassVar[str] = "subscription_free"
38
+ DEFAULT_SUBSCRIPTION_STATUS: ClassVar[str] = "active"
39
+ DEFAULT_SUBSCRIPTION_INSIGHT_CREDITS: ClassVar[int] = 10
40
+ DEFAULT_EXTRA_INSIGHT_CREDITS: ClassVar[int] = 0
41
+
42
+ # System-managed fields
43
+ schema_version: float = Field(
44
+ default=2.3,
45
+ description="Version of this Class == version of DB Schema"
46
+ )
47
+
48
+ # IAM and subscription fields
49
+ iam_groups: Dict[str, List[str]] = Field(
50
+ default_factory=lambda: UserStatus.DEFAULT_IAM_GROUPS,
51
+ description="User's Groups, with a default one for all authenticated Pulse users"
52
+ )
53
+ sbscrptn_plan: str = Field(
54
+ default_factory=lambda: UserStatus.DEFAULT_SUBSCRIPTION_PLAN,
55
+ description="Subscription Plan"
56
+ )
57
+ sbscrptn_status: str = Field(
58
+ default_factory=lambda: UserStatus.DEFAULT_SUBSCRIPTION_STATUS,
59
+ description="Subscription Status"
60
+ )
61
+
62
+ # Subscription dates
63
+ sbscrptn_start_date: datetime = Field(
64
+ default_factory=datetime.utcnow,
65
+ description="Subscription Start Date"
66
+ )
67
+ sbscrptn_end_date: datetime = Field(
68
+ default_factory=lambda: datetime.utcnow() + relativedelta(years=1),
69
+ description="Subscription End Date"
70
+ )
71
+
72
+ # Credits management
73
+ sbscrptn_insight_credits: int = Field(
74
+ default_factory=lambda: UserStatus.DEFAULT_SUBSCRIPTION_INSIGHT_CREDITS,
75
+ description="Subscription-based insight credits"
76
+ )
77
+ sbscrptn_ins_crdts_updtd_since_datetime: datetime = Field(
78
+ default_factory=datetime.utcnow,
79
+ description="Last update timestamp for subscription credits"
80
+ )
81
+ extra_insight_credits: int = Field(
82
+ default_factory=lambda: UserStatus.DEFAULT_EXTRA_INSIGHT_CREDITS,
83
+ description="Additional purchased insight credits (non-expiring)"
84
+ )
85
+
86
+ # Optional fields
87
+ payment_refs_uids: Optional[Set[str]] = None
88
+
89
+ # Audit fields
90
+ creat_date: datetime
91
+ creat_by_user: str
92
+ updt_date: datetime
93
+ updt_by_user: str
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.2
2
2
  Name: ipulse_shared_core_ftredge
3
- Version: 3.2.2
3
+ Version: 3.2.3
4
4
  Summary: Shared Core models and Logger util for the Pulse platform project. Using AI for financial advisory and investment management.
5
5
  Home-page: https://github.com/TheFutureEdge/ipulse_shared_core
6
6
  Author: Russlan Ramdowar
@@ -8,7 +8,7 @@ License-File: LICENCE
8
8
  Requires-Dist: pydantic[email]~=2.5
9
9
  Requires-Dist: python-dateutil~=2.8
10
10
  Requires-Dist: pytest~=7.1
11
- Requires-Dist: ipulse_shared_base_ftredge>=2.2.2
11
+ Requires-Dist: ipulse_shared_base_ftredge>=3.4.2
12
12
  Dynamic: author
13
13
  Dynamic: home-page
14
14
  Dynamic: requires-dist
@@ -1,4 +1,4 @@
1
1
  pydantic[email]~=2.5
2
2
  python-dateutil~=2.8
3
3
  pytest~=7.1
4
- ipulse_shared_base_ftredge>=2.2.2
4
+ ipulse_shared_base_ftredge>=3.4.2
@@ -1,71 +0,0 @@
1
- # pylint: disable=missing-module-docstring
2
- # pylint: disable=missing-function-docstring
3
- # pylint: disable=missing-class-docstring
4
- # pylint: disable=broad-exception-caught
5
- # pylint: disable=line-too-long
6
- # pylint: disable=unused-variable
7
- # pylint: disable=broad-exception-caught
8
- # from pydantic import BaseModel, validator, ValidationError, Field
9
- # from typing import Set, Optional
10
- # import uuid
11
- # from datetime import datetime
12
- # import dateutil.parser
13
-
14
- # CLASS_VERSION= 1.0
15
- # MODULE= "core"
16
- # CLASS_REF="orgn"
17
-
18
-
19
- # class Organisation(BaseModel):
20
- # puid: str = Field(default_factory=f"{datetime.utcnow().strftime('%Y%m%d%H%M')}{uuid.uuid4().hex[:8]}_{MODULE}{CLASS_REF}".lower())
21
- # name: str
22
- # creat_date: datetime = Field(default_factory=datetime.utcnow())
23
- # updt_date: datetime = Field(default_factory=datetime.utcnow())
24
- # creat_by_user: Optional[str] = None
25
- # updt_by_user: Optional[str] = None
26
- # relations: Optional[Set[str]]=None
27
- # description: Optional[str] = None # Updated to use Optional
28
- # industries: Optional[Set[str]] = None # Updated to use Optional
29
- # website: Optional[str] = None # Updated to use Optional
30
- # org_admin_user_uids: Optional[Set[str]] = None # Updated to use Optional
31
- # class Config:
32
- # extra = "forbid"
33
-
34
-
35
- # @validator('relations', pre=True, always=True)
36
- # def validate_relations(cls, relations):
37
- # if not set(relations).issubset(enums.organisation_relations):
38
- # raise ValueError("Invalid relation values provided.")
39
- # return relations
40
-
41
-
42
- # @validator('industries', pre=True, always=True)
43
- # def validate_industries(cls, industries):
44
- # if industries is not None and not set(industries).issubset(enums.organisation_industries):
45
- # raise ValueError("Invalid industry values provided.")
46
- # return industries
47
-
48
- # @validator('creat_date', 'updt_date', pre=True)
49
- # def parse_date(cls, value):
50
- # if value is None:
51
- # return value
52
- # if isinstance(value, datetime):
53
- # return value
54
- # try:
55
- # # Assuming Firestore returns an ISO 8601 string, adjust if necessary
56
- # print("Putting Updt or Creat date in a valid format in a Validator when creating Organisation object")
57
- # return dateutil.parser.isoparse(value)
58
- # except (TypeError, ValueError):
59
- # raise ValidationError(f"Invalid datetime format inside Organisation: {value}")
60
-
61
-
62
- # ### Description, Industries, and Website are optional for Retail Customer and mandatory for Non Retail Customer
63
- # @validator('description', 'industries', 'website', pre=True, always=True)
64
- # def validate_optional_fields(cls, value, values):
65
- # if values.get('name') == 'Retail Customer' and values.get('relations') == {"retail_customer"} or values.get('relations') == ["retail_customer"]:
66
- # if value is not None:
67
- # raise ValueError("For 'Retail Customer' with only 'retail_customer' relations, description, industries, and website should not be provided.")
68
- # else:
69
- # if value is None:
70
- # raise ValueError("For Non Retail Customer, description, industries, and website are mandatory.")
71
- # return value
@@ -1,6 +0,0 @@
1
- from pydantic import BaseModel
2
-
3
- class UserAuth(BaseModel):
4
- email: str
5
- password: str
6
- extra_fields: dict = {}
@@ -1,41 +0,0 @@
1
- from pydantic import BaseModel, EmailStr , Field
2
- from datetime import datetime , date
3
-
4
- from typing import Set, Optional
5
- # import uuid
6
- # from . import pulse_enums as enums
7
-
8
- CLASS_ORIGIN_AUTHOR="Russlan Ramdowar;russlan@ftredge.com"
9
- CLASS_ORGIN_DATE=datetime(2024, 1, 16, 20, 5)
10
-
11
- CLASS_VERSION = 3.01
12
- CLASS_REVISION_AUTHOR="Russlan Ramdowar;russlan@ftredge.com"
13
- CLASS_REVISION_DATE=datetime(2024, 2, 13, 20, 15)
14
- LAST_MODIFICATION="Fixed typo"
15
-
16
-
17
- DOMAIN="user"
18
- OBJ_REF = "usprfl"
19
-
20
- class UserProfile(BaseModel):
21
- schema_version: float = Field(default=CLASS_VERSION, description="Version of this Class == version of DB Schema") #User can Read only
22
- # uid: str = Field(frozen=True, description="Combination of user_usrprof_<Firebase Auth UID>") #User can Read only ---> STORED as Firestore Doc ID
23
- # puid:str = Field(default_factory=lambda: f"{DOMAIN}{OBJ_REF}{datetime.utcnow().strftime('%Y%m%d%H%M')}{uuid.uuid4().hex[:8]}".lower(),
24
- # frozen=True,
25
- # description="Generated Automatically by default_factory") #User can Read only
26
- email: EmailStr = Field(frozen=True, description="Propagated from Firebase Auth" ) #User can Read only
27
- organizations_uids: Set[str] = Field( description="Depends on Subscription Plan, Regularly Updated") #User can Read only
28
- creat_date: datetime #User can Read only
29
- creat_by_user: str #User can Read only
30
- updt_date: datetime #User can Read only
31
- updt_by_user: str #User can Read only
32
- aliases: Optional[Set[str]] = None #User can Read only
33
- provider_id: str #User can Read only
34
-
35
- username: Optional[str] = None #User can Read and Edit
36
- dob: Optional[date] = None #User can Read and Edit
37
- first_name: Optional[str] = None #User can Read and Edit
38
- last_name: Optional[str] = None #User can Read and Edit
39
- mobile: Optional[str] = None #User can Read and Edit
40
- class Config:
41
- extra = "forbid"
@@ -1,36 +0,0 @@
1
- from typing import Optional, Set
2
- from pydantic import BaseModel, Field, EmailStr
3
- from datetime import date, datetime
4
-
5
-
6
- CLASS_ORIGIN_AUTHOR="Russlan Ramdowar;russlan@ftredge.com"
7
- CLASS_ORGIN_DATE=datetime(2024, 3, 15, 20, 15)
8
-
9
- CLASS_VERSION = 2.01
10
- CLASS_REVISION_AUTHOR="Russlan Ramdowar;russlan@ftredge.com"
11
- CLASS_REVISION_DATE=datetime(2024, 3, 15, 20, 15)
12
- LAST_MODIFICATION="Created , with all fields Optional"
13
-
14
- class UserProfileUpdate(BaseModel):
15
- schema_version: Optional[float] = Field(None, description="Version of this Class == version of DB Schema")
16
- email: Optional[EmailStr] = Field(None, description="Propagated from Firebase Auth")
17
- organizations_uids: Optional[Set[str]] = Field(None, description="Depends on Subscription Plan, Regularly Updated")
18
- creat_date: Optional[datetime] = Field(None, description="Creation date")
19
- creat_by_user: Optional[str] = Field(None, description="Created by user")
20
- updt_date: Optional[datetime] = Field(None, description="Update date")
21
- updt_by_user: Optional[str] = Field(None, description="Updated by user")
22
- aliases: Optional[Set[str]] = Field(None, description="User aliases")
23
- provider_id: Optional[str] = Field(None, description="Provider ID")
24
-
25
- username: Optional[str] = Field(None, description="Username")
26
- dob: Optional[date] = Field(None, description="Date of Birth")
27
- first_name: Optional[str] = Field(None, description="First Name")
28
- last_name: Optional[str] = Field(None, description="Last Name")
29
- mobile: Optional[str] = Field(None, description="Mobile Number")
30
-
31
- # def model_dump(self, **kwargs):
32
- # return super().model_dump(exclude_none=True, **kwargs)
33
-
34
-
35
-
36
-
@@ -1,51 +0,0 @@
1
- from pydantic import BaseModel, Field
2
-
3
- from datetime import datetime
4
- from dateutil.relativedelta import relativedelta
5
- from typing import Set, Optional, Dict, List
6
-
7
-
8
-
9
-
10
- CLASS_ORIGIN_AUTHOR="Russlan Ramdowar;russlan@ftredge.com"
11
- CLASS_ORGIN_DATE=datetime(2024, 2, 12, 20, 5)
12
-
13
- SCHEMA_VERSION = 2.3
14
- CLASS_REVISION_AUTHOR="Russlan Ramdowar;russlan@ftredge.com"
15
- CLASS_REVISION_DATE=datetime(2024, 2, 13, 20, 15)
16
- LAST_MODIFICATION="Changed default IAM_GROUPS"
17
-
18
- DOMAIN="user"
19
- OBJ_REF = "usrsttus"
20
-
21
- DEFAULT_IAM_GROUPS={"pulseroot":["full_open_read"]}
22
- DEFAULT_SUBSCRIPTION_PLAN="subscription_free"
23
- DEFAULT_SUBSCRIPTION_STATUS="active"
24
- DEFAULT_SUBSCRIPTION_INSIGHT_CREDITS=10
25
- DEFAULT_EXTRA_INSIGHT_CREDITS=0
26
-
27
- ############################################ !!!!! ALWAYS UPDATE SCHEMA VERSION , IF SCHEMA IS BEING MODIFIED !!! ############################################
28
- class UserStatus(BaseModel):
29
- schema_version: float = Field(default=SCHEMA_VERSION, description="Version of this Class == version of DB Schema") #User can Read only
30
- # uid: str = Field(frozen=True, description="Generated by Firebase Auth") #User can Read only
31
- # puid:str = Field(default_factory=lambda: f"{DOMAIN}{OBJ_REF}{datetime.utcnow().strftime('%Y%m%d%H%M')}{uuid.uuid4().hex[:8]}".lower(),
32
- # frozen=True,
33
- # description="Generated Automatically by default_factory") #User can Read only
34
-
35
- iam_groups: Dict[str, List[str]] = Field(default_factory=lambda:DEFAULT_IAM_GROUPS, description="User's Groups, with a default one for all authenticated Pulse users") #User can Read only
36
- sbscrptn_plan: str=Field(default_factory=lambda:DEFAULT_SUBSCRIPTION_PLAN, description="Subscription Plan ") #User can Read only
37
- sbscrptn_status: str=Field(default_factory=lambda:DEFAULT_SUBSCRIPTION_STATUS, description="Subscription Status") #User can Read only
38
- sbscrptn_start_date: datetime=Field(default_factory=lambda:datetime.utcnow(), description="Subscription Start Date") #User can Read only
39
- sbscrptn_end_date: datetime=Field(default_factory=lambda:datetime.utcnow()+relativedelta(years=1) , description="Subscription End Date") #User can Read only
40
- sbscrptn_insight_credits: int= Field(default_factory=lambda:DEFAULT_SUBSCRIPTION_INSIGHT_CREDITS, description="Depends on Subscription Plan, Set Amount udated at Regular Intervals or at Regular Time") #User can Read only
41
- sbscrptn_ins_crdts_updtd_since_datetime: datetime=Field(default_factory=lambda:datetime.utcnow(), description="Subscription Start Date") #User can Read only #User can Read only #User can Read only
42
- extra_insight_credits: int= Field(default_factory=lambda:DEFAULT_EXTRA_INSIGHT_CREDITS, description="If user purchased extra Insigth Credits they shouldn't Expire") #User can Read only
43
- payment_refs_uids: Optional[Set[str]] = None #User can Read only
44
-
45
- creat_date: datetime #User can Read only
46
- creat_by_user: str #User can Read only / Ideally shouldn't be able to see even
47
- updt_date: datetime #User can Read only / Ideally shouldn't be able to see even
48
- updt_by_user: str #User can Read only / Ideally shouldn't be able to see even
49
-
50
- class Config:
51
- extra = "forbid"