ipulse-shared-core-ftredge 1.0.0__tar.gz → 1.2.0__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.
- {ipulse_shared_core_ftredge-1.0.0 → ipulse_shared_core_ftredge-1.2.0}/PKG-INFO +1 -2
- {ipulse_shared_core_ftredge-1.0.0 → ipulse_shared_core_ftredge-1.2.0}/setup.py +3 -3
- ipulse_shared_core_ftredge-1.2.0/src/ipulse_shared_core_ftredge/__init__.py +5 -0
- ipulse_shared_core_ftredge-1.2.0/src/ipulse_shared_core_ftredge/models/__init__.py +8 -0
- ipulse_shared_core_ftredge-1.2.0/src/ipulse_shared_core_ftredge/models/audit_log_firestore.py +12 -0
- ipulse_shared_core_ftredge-1.2.0/src/ipulse_shared_core_ftredge/models/organisation.py +65 -0
- ipulse_shared_core_ftredge-1.2.0/src/ipulse_shared_core_ftredge/models/pulse_enums.py +187 -0
- ipulse_shared_core_ftredge-1.2.0/src/ipulse_shared_core_ftredge/models/resource_catalog_item.py +116 -0
- ipulse_shared_core_ftredge-1.2.0/src/ipulse_shared_core_ftredge/models/user_auth.py +6 -0
- ipulse_shared_core_ftredge-1.2.0/src/ipulse_shared_core_ftredge/models/user_profile.py +151 -0
- ipulse_shared_core_ftredge-1.2.0/src/ipulse_shared_core_ftredge/models/user_profile_update.py +18 -0
- {ipulse_shared_core_ftredge-1.0.0 → ipulse_shared_core_ftredge-1.2.0/src}/ipulse_shared_core_ftredge.egg-info/PKG-INFO +1 -2
- ipulse_shared_core_ftredge-1.2.0/src/ipulse_shared_core_ftredge.egg-info/SOURCES.txt +18 -0
- ipulse_shared_core_ftredge-1.2.0/src/ipulse_shared_core_ftredge.egg-info/top_level.txt +1 -0
- ipulse_shared_core_ftredge-1.0.0/ipulse_shared_core_ftredge.egg-info/SOURCES.txt +0 -9
- ipulse_shared_core_ftredge-1.0.0/ipulse_shared_core_ftredge.egg-info/top_level.txt +0 -1
- {ipulse_shared_core_ftredge-1.0.0 → ipulse_shared_core_ftredge-1.2.0}/LICENCE +0 -0
- {ipulse_shared_core_ftredge-1.0.0 → ipulse_shared_core_ftredge-1.2.0}/README.md +0 -0
- {ipulse_shared_core_ftredge-1.0.0 → ipulse_shared_core_ftredge-1.2.0}/pyproject.toml +0 -0
- {ipulse_shared_core_ftredge-1.0.0 → ipulse_shared_core_ftredge-1.2.0}/setup.cfg +0 -0
- {ipulse_shared_core_ftredge-1.0.0 → ipulse_shared_core_ftredge-1.2.0/src}/ipulse_shared_core_ftredge.egg-info/dependency_links.txt +0 -0
- {ipulse_shared_core_ftredge-1.0.0 → ipulse_shared_core_ftredge-1.2.0/src}/ipulse_shared_core_ftredge.egg-info/requires.txt +0 -0
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: ipulse_shared_core_ftredge
|
|
3
|
-
Version: 1.
|
|
3
|
+
Version: 1.2.0
|
|
4
4
|
Summary: Shared models 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
|
|
7
|
-
Author-email: russlan@ftredge.com
|
|
8
7
|
License-File: LICENCE
|
|
9
8
|
Requires-Dist: pydantic[email]
|
|
10
9
|
Requires-Dist: uuid
|
|
@@ -2,15 +2,15 @@ from setuptools import setup, find_packages
|
|
|
2
2
|
|
|
3
3
|
setup(
|
|
4
4
|
name='ipulse_shared_core_ftredge',
|
|
5
|
-
version='1.
|
|
6
|
-
|
|
5
|
+
version='1.2.0',
|
|
6
|
+
package_dir={'': 'src'}, # Specify the source directory
|
|
7
|
+
packages=find_packages(where='src'), # Look for packages in 'src'
|
|
7
8
|
install_requires=[
|
|
8
9
|
# List your dependencies here
|
|
9
10
|
'pydantic[email]',
|
|
10
11
|
'uuid'
|
|
11
12
|
],
|
|
12
13
|
author='Russlan Ramdowar',
|
|
13
|
-
author_email='russlan@ftredge.com',
|
|
14
14
|
description='Shared models for the Pulse platform project. Using AI for financial advisory and investment management.',
|
|
15
15
|
url='https://github.com/TheFutureEdge/ipulse_shared_core',
|
|
16
16
|
)
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
from pydantic import BaseModel
|
|
2
|
+
from datetime import datetime
|
|
3
|
+
|
|
4
|
+
class AuditLogFirestore(BaseModel):
|
|
5
|
+
user_uid: str
|
|
6
|
+
action: str
|
|
7
|
+
collection_name: str
|
|
8
|
+
document_name: str
|
|
9
|
+
field_name: str
|
|
10
|
+
old_value: str
|
|
11
|
+
new_value: str
|
|
12
|
+
timestamp: datetime.utcnow()
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
from pydantic import BaseModel, validator, ValidationError, Field
|
|
2
|
+
from typing import Set, Optional
|
|
3
|
+
import uuid
|
|
4
|
+
from datetime import datetime
|
|
5
|
+
import pulse_enums as enums
|
|
6
|
+
import dateutil.parser
|
|
7
|
+
|
|
8
|
+
CLASS_VERSION= 1.0
|
|
9
|
+
MODULE= "core"
|
|
10
|
+
CLASS_REF="orgn"
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
class Organisation(BaseModel):
|
|
14
|
+
puid: str = Field(default_factory=lambda: f"{datetime.utcnow().strftime('%Y%m%d%H%M')}{uuid.uuid4().hex[:8]}_{MODULE}{CLASS_REF}".lower())
|
|
15
|
+
name: str
|
|
16
|
+
creat_date: datetime = Field(default_factory=lambda:datetime.utcnow())
|
|
17
|
+
updt_date: datetime = Field(default_factory=lambda:datetime.utcnow())
|
|
18
|
+
creat_by_user: Optional[str] = None
|
|
19
|
+
updt_by_user: Optional[str] = None
|
|
20
|
+
relations: Set[str]=None
|
|
21
|
+
description: Optional[str] = None # Updated to use Optional
|
|
22
|
+
industries: Optional[Set[str]] = None # Updated to use Optional
|
|
23
|
+
website: Optional[str] = None # Updated to use Optional
|
|
24
|
+
org_admin_user_uids: Optional[Set[str]] = None # Updated to use Optional
|
|
25
|
+
class Config:
|
|
26
|
+
extra = "forbid"
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
@validator('relations', pre=True, always=True)
|
|
30
|
+
def validate_relations(cls, relations):
|
|
31
|
+
if not set(relations).issubset(enums.organisation_relations):
|
|
32
|
+
raise ValueError("Invalid relation values provided.")
|
|
33
|
+
return relations
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
@validator('industries', pre=True, always=True)
|
|
37
|
+
def validate_industries(cls, industries):
|
|
38
|
+
if industries is not None and not set(industries).issubset(enums.organisation_industries):
|
|
39
|
+
raise ValueError("Invalid industry values provided.")
|
|
40
|
+
return industries
|
|
41
|
+
|
|
42
|
+
@validator('creat_date', 'updt_date', pre=True)
|
|
43
|
+
def parse_date(cls, value):
|
|
44
|
+
if value is None:
|
|
45
|
+
return value
|
|
46
|
+
if isinstance(value, datetime):
|
|
47
|
+
return value
|
|
48
|
+
try:
|
|
49
|
+
# Assuming Firestore returns an ISO 8601 string, adjust if necessary
|
|
50
|
+
print("Putting Updt or Creat date in a valid format in a Validator when creating Organisation object")
|
|
51
|
+
return dateutil.parser.isoparse(value)
|
|
52
|
+
except (TypeError, ValueError):
|
|
53
|
+
raise ValidationError(f"Invalid datetime format inside Organisation: {value}")
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
### Description, Industries, and Website are optional for Retail Customer and mandatory for Non Retail Customer
|
|
57
|
+
@validator('description', 'industries', 'website', pre=True, always=True)
|
|
58
|
+
def validate_optional_fields(cls, value, values):
|
|
59
|
+
if values.get('name') == 'Retail Customer' and values.get('relations') == {"retail_customer"} or values.get('relations') == ["retail_customer"]:
|
|
60
|
+
if value is not None:
|
|
61
|
+
raise ValueError("For 'Retail Customer' with only 'retail_customer' relations, description, industries, and website should not be provided.")
|
|
62
|
+
else:
|
|
63
|
+
if value is None:
|
|
64
|
+
raise ValueError("For Non Retail Customer, description, industries, and website are mandatory.")
|
|
65
|
+
return value
|
|
@@ -0,0 +1,187 @@
|
|
|
1
|
+
organisation_relations = {
|
|
2
|
+
"*",
|
|
3
|
+
"retail_customer",
|
|
4
|
+
"corporate_customer",
|
|
5
|
+
"parent",
|
|
6
|
+
"sister",
|
|
7
|
+
"self",
|
|
8
|
+
"partner",
|
|
9
|
+
"supplier",
|
|
10
|
+
"sponsor",
|
|
11
|
+
"investor",
|
|
12
|
+
"regulator",
|
|
13
|
+
"other"
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
organisation_industries = {
|
|
17
|
+
"*",
|
|
18
|
+
"data",
|
|
19
|
+
"government",
|
|
20
|
+
"media",
|
|
21
|
+
"academic",
|
|
22
|
+
"commercial",
|
|
23
|
+
"fund",
|
|
24
|
+
"finance",
|
|
25
|
+
"advisory",
|
|
26
|
+
"hedgefund",
|
|
27
|
+
"bank",
|
|
28
|
+
"vc",
|
|
29
|
+
"pe",
|
|
30
|
+
"construction",
|
|
31
|
+
"healthcare",
|
|
32
|
+
"technology",
|
|
33
|
+
"consulting",
|
|
34
|
+
"retail",
|
|
35
|
+
"non_profit",
|
|
36
|
+
"individual",
|
|
37
|
+
"freelancer",
|
|
38
|
+
"other"
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
resource_classifications = {
|
|
43
|
+
"*",
|
|
44
|
+
"public",
|
|
45
|
+
"auth_required_open", # synthetic data , prices of gold etc.
|
|
46
|
+
"auth_required_restricted", ##special features
|
|
47
|
+
"auth_required_confidential", ## user data etc.
|
|
48
|
+
"internal_only_open", ## internal public reports, emails etc.
|
|
49
|
+
"internal_only_restricted", ##internal financials summary reports , web and app analytics, lsit of admin users etc.
|
|
50
|
+
"internal_only_confidential", ## source data : key financials, salaries and bonuses etc
|
|
51
|
+
"top_confidential" ##secrets, admin passwords etc.
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
effects={"allow", "deny"}
|
|
55
|
+
|
|
56
|
+
actions ={
|
|
57
|
+
"create",
|
|
58
|
+
"batch_create",
|
|
59
|
+
"read",
|
|
60
|
+
"batch_read",
|
|
61
|
+
"update",
|
|
62
|
+
"batch_update",
|
|
63
|
+
"add",
|
|
64
|
+
"batch_add",
|
|
65
|
+
"remove",
|
|
66
|
+
"batch_remove",
|
|
67
|
+
"delete",
|
|
68
|
+
"batch_delete",
|
|
69
|
+
"rename" ,
|
|
70
|
+
"batch_rename",
|
|
71
|
+
"move",
|
|
72
|
+
"batch_move",
|
|
73
|
+
"download",
|
|
74
|
+
"upload",
|
|
75
|
+
"share"
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
|
|
79
|
+
resource_types = {
|
|
80
|
+
"db", "sql_db", "nosql_db", "dynamodb",
|
|
81
|
+
"big_query", "big_query_project", "big_query_table", "big_query_column",
|
|
82
|
+
"big_query_row", "big_query_cell",
|
|
83
|
+
"firestore", "firestore_project", "firestore_collection",
|
|
84
|
+
"firestore_document","firestore_document_with_timeseries" "firestore_document_field",
|
|
85
|
+
"pandas_dataframe", "spark_dataframe",
|
|
86
|
+
"s3_bucket", "storage_bucket",
|
|
87
|
+
"folder", "file", "json_file", "csv_file", "pdf_file",
|
|
88
|
+
"unstructured_file", "image", "video", "audio", "text",
|
|
89
|
+
"api", "report", "dashboard", "webpage", "website", "web"
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
|
|
93
|
+
resource_origins = {"*", "internal", "external", "mixed"}
|
|
94
|
+
|
|
95
|
+
resource_original_or_processed = {"*",
|
|
96
|
+
"original_source",
|
|
97
|
+
"original_copy",
|
|
98
|
+
"processed_source", # Example User Profiles
|
|
99
|
+
"processed_copy",
|
|
100
|
+
"mixed_source",
|
|
101
|
+
"mixed_copy" }
|
|
102
|
+
|
|
103
|
+
resource_contents = {
|
|
104
|
+
"*",
|
|
105
|
+
"synthetic_data",
|
|
106
|
+
"composite_data",
|
|
107
|
+
"user_core_profile"
|
|
108
|
+
"user_generated_shareable",
|
|
109
|
+
"user_owned_shareable",
|
|
110
|
+
"user_generated_private",
|
|
111
|
+
"user_owned_private",
|
|
112
|
+
"organisation_profile",
|
|
113
|
+
"mlprediction",
|
|
114
|
+
"mlmetrics",
|
|
115
|
+
"internal_report",
|
|
116
|
+
"system_generated",
|
|
117
|
+
"our_financials"
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
resource_readable_by={
|
|
121
|
+
"*",
|
|
122
|
+
"all",
|
|
123
|
+
"authenticated",
|
|
124
|
+
"restircted",
|
|
125
|
+
"owner",
|
|
126
|
+
"selected_by_owner",
|
|
127
|
+
"admin",
|
|
128
|
+
"selected_by_admin",
|
|
129
|
+
"super_admin",
|
|
130
|
+
"super_admin_selected",
|
|
131
|
+
"system"
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
resource_updatable_by={
|
|
135
|
+
"*",
|
|
136
|
+
"all",
|
|
137
|
+
"authenticated",
|
|
138
|
+
"restircted",
|
|
139
|
+
"owner",
|
|
140
|
+
"selected_by_owner",
|
|
141
|
+
"admin",
|
|
142
|
+
"selected_by_admin",
|
|
143
|
+
"super_admin",
|
|
144
|
+
"super_admin_selected",
|
|
145
|
+
"system"
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
pulse_modules={
|
|
149
|
+
"*",
|
|
150
|
+
"core",
|
|
151
|
+
"gym",
|
|
152
|
+
"orcl",
|
|
153
|
+
"scen",
|
|
154
|
+
"invs",
|
|
155
|
+
"prfl",
|
|
156
|
+
"trde",
|
|
157
|
+
"bet",
|
|
158
|
+
"chat"
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
licences_types={
|
|
162
|
+
"*",
|
|
163
|
+
######################################### OPEN or FULL Rights
|
|
164
|
+
"public",
|
|
165
|
+
"open",
|
|
166
|
+
"open_no_tandc",
|
|
167
|
+
"full_rights",
|
|
168
|
+
"full_rights_for_sale",
|
|
169
|
+
"commercial_licence_perpetual",
|
|
170
|
+
"customer_private_tac",
|
|
171
|
+
######################################### SPECIAL CONDITIONS
|
|
172
|
+
"open_with_tandc",
|
|
173
|
+
"on_special_request",
|
|
174
|
+
"commercial_licence_limited_time",
|
|
175
|
+
"customer_owned_for_sale",
|
|
176
|
+
######################################### Not for Commercial Use
|
|
177
|
+
"full_rights_not_for_sale",
|
|
178
|
+
"internal_only",
|
|
179
|
+
"academic_licence",
|
|
180
|
+
"not_for_commercial_use",
|
|
181
|
+
"customer_private"
|
|
182
|
+
######################################### Unknown
|
|
183
|
+
"commercial_licence_not_purchased",
|
|
184
|
+
"web_scrapped",
|
|
185
|
+
"unknown"
|
|
186
|
+
}
|
|
187
|
+
|
ipulse_shared_core_ftredge-1.2.0/src/ipulse_shared_core_ftredge/models/resource_catalog_item.py
ADDED
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
import uuid
|
|
2
|
+
from datetime import datetime
|
|
3
|
+
from pydantic import BaseModel, validator, ValidationError
|
|
4
|
+
from typing import Dict, Any, Set, Optional
|
|
5
|
+
import pulse_enums as enums
|
|
6
|
+
|
|
7
|
+
import dateutil.parser
|
|
8
|
+
|
|
9
|
+
CLASS_VERSION = 1.0
|
|
10
|
+
CLASS_REF = "resdes"
|
|
11
|
+
MODULE = "core"
|
|
12
|
+
|
|
13
|
+
class ResourceCatalogItem(BaseModel):
|
|
14
|
+
|
|
15
|
+
resr_puid_or_name: str #Ex: username
|
|
16
|
+
resr_path: str #Ex: ipulse-401013/cloud/firesotre/Users/{user_uid}/username
|
|
17
|
+
resr_name: str #Ex: username
|
|
18
|
+
resr_pulse_module: str = None #Ex: core
|
|
19
|
+
resr_type: str
|
|
20
|
+
resr_classifications: Set[str]
|
|
21
|
+
resr_contents:Set[str]
|
|
22
|
+
resr_original_or_processed: str
|
|
23
|
+
resr_origin: str
|
|
24
|
+
resr_origin_organisations_uids: Set[str]
|
|
25
|
+
resr_origin_description: str
|
|
26
|
+
resr_licences_types: Set[str]
|
|
27
|
+
resr_description_details: str
|
|
28
|
+
resr_updtbl_by_non_staff: bool
|
|
29
|
+
resr_creat_by_user_uid: str
|
|
30
|
+
resr_creat_date: datetime
|
|
31
|
+
class_version:float = CLASS_VERSION
|
|
32
|
+
resr_columns_count: int=None
|
|
33
|
+
resr_columns: Optional[Dict[Any, Any]] = None #OPTIONAL
|
|
34
|
+
resr_structure_version: Optional[str]=None # OPTIONAL
|
|
35
|
+
resr_structure_updt_date: Optional[str]=None #OPTIONAL
|
|
36
|
+
resr_structure_updt_by_user_uid: Optional[str]=None # OPTIONAL
|
|
37
|
+
resr_tags: Optional[Dict[Any, Any]] = None #OPTIONAL
|
|
38
|
+
resr_content_updt_date: Optional[str]=None #OPTIONAL
|
|
39
|
+
resr_content_updt_by_user_uid: Optional[str]=None # OPTIONAL
|
|
40
|
+
puid: str = None #TO BE SETUP BY Validator
|
|
41
|
+
metadata_version: float = None #TO BE SETUP BY Validator
|
|
42
|
+
metadata_creat_date: datetime = None #TO BE SETUP BY Management Service
|
|
43
|
+
metadata_creat_by: str = None #TO BE SETUP BY Management Service
|
|
44
|
+
metadata_updt_date: datetime = None #TO BE SETUP BY Management Service
|
|
45
|
+
metadata_updt_by: str = None #TO BE SETUP BY Management Service
|
|
46
|
+
|
|
47
|
+
@validator('puid', pre=True, always=True)
|
|
48
|
+
def set_puid(cls, puid, values):
|
|
49
|
+
if puid is None:
|
|
50
|
+
return f"{datetime.utcnow().strftime('%Y%m%d%H%M')}{uuid.uuid4().hex[:8]}_{MODULE}{CLASS_REF}".lower()
|
|
51
|
+
return puid
|
|
52
|
+
|
|
53
|
+
@validator('metadata_version', pre=True, always=True)
|
|
54
|
+
def set_metadata_version(cls, metadata_version, values):
|
|
55
|
+
if metadata_version is None:
|
|
56
|
+
return 1.0
|
|
57
|
+
else:
|
|
58
|
+
return metadata_version + 0.1
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
@validator('resr_pulse_module', pre=True, always=True)
|
|
62
|
+
def validate_resr_pulse_module(cls, resr_pulse_modules):
|
|
63
|
+
if resr_pulse_modules not in enums.pulse_modules:
|
|
64
|
+
raise ValueError("Invalid pulse_modules values provided.")
|
|
65
|
+
return resr_pulse_modules
|
|
66
|
+
|
|
67
|
+
@validator('resr_type', pre=True, always=True)
|
|
68
|
+
def validate_resr_type(cls, resr_type):
|
|
69
|
+
if resr_type not in enums.resource_types:
|
|
70
|
+
raise ValueError("Invalid resource_types value provided.")
|
|
71
|
+
return resr_type
|
|
72
|
+
|
|
73
|
+
@validator('resr_classifications', pre=True, always=True)
|
|
74
|
+
def validate_resr_classifications(cls, resr_classifications):
|
|
75
|
+
if not resr_classifications.issubset(enums.resource_classifications):
|
|
76
|
+
raise ValueError("Invalid resr_classifications values provided.")
|
|
77
|
+
return resr_classifications
|
|
78
|
+
|
|
79
|
+
@validator('resr_contents', pre=True, always=True)
|
|
80
|
+
def validate_resr_contents(cls, resr_contents):
|
|
81
|
+
if not resr_contents.issubset(enums.resource_contents):
|
|
82
|
+
raise ValueError("Invalid resr_contents values provided.")
|
|
83
|
+
return resr_contents
|
|
84
|
+
|
|
85
|
+
@validator('resr_original_or_processed', pre=True, always=True)
|
|
86
|
+
def validate_resr_original_or_processed(cls, resr_original_or_processed):
|
|
87
|
+
if resr_original_or_processed not in enums.resource_original_or_processed:
|
|
88
|
+
raise ValueError("Invalid resr_original_or_processed value provided.")
|
|
89
|
+
return resr_original_or_processed
|
|
90
|
+
|
|
91
|
+
@validator('resr_origin', pre=True, always=True)
|
|
92
|
+
def validate_resr_origin(cls, resr_origin):
|
|
93
|
+
if resr_origin not in enums.resource_origins:
|
|
94
|
+
raise ValueError("Invalid resource_origins value provided.")
|
|
95
|
+
return resr_origin
|
|
96
|
+
|
|
97
|
+
|
|
98
|
+
@validator('metadata_creat_date', 'metadata_updt_date', pre=True)
|
|
99
|
+
def parse_date(cls, value):
|
|
100
|
+
if value is None:
|
|
101
|
+
return value
|
|
102
|
+
if isinstance(value, datetime):
|
|
103
|
+
return value
|
|
104
|
+
try:
|
|
105
|
+
# Assuming Firestore returns an ISO 8601 string, adjust if necessary
|
|
106
|
+
return dateutil.parser.isoparse(value)
|
|
107
|
+
except (TypeError, ValueError):
|
|
108
|
+
raise ValidationError(f"Invalid datetime format inside Resource Description: {value}")
|
|
109
|
+
|
|
110
|
+
|
|
111
|
+
|
|
112
|
+
@validator('metadata_updt_date', 'metadata_updt_date', pre=True, always=True)
|
|
113
|
+
def set_default_updt_date(cls, date, values):
|
|
114
|
+
if date is None:
|
|
115
|
+
return datetime.utcnow().isoformat()
|
|
116
|
+
return date
|
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
from pydantic import BaseModel, EmailStr , Field, root_validator
|
|
2
|
+
from datetime import datetime , date
|
|
3
|
+
from typing import Set, Optional, Dict, Any, Annotated
|
|
4
|
+
import uuid
|
|
5
|
+
import pulse_enums as enums
|
|
6
|
+
|
|
7
|
+
CLASS_VERSION = 2.1
|
|
8
|
+
CLASS_VERSION_AUTHOR="Russlan Ramdowar;russlan@ftredge.com"
|
|
9
|
+
CLASS_VERSION_DATE=datetime(2023, 12, 23, 17, 50)
|
|
10
|
+
MODULE="core"
|
|
11
|
+
CLASS_REF = "usrpf"
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
class UserProfile(BaseModel):
|
|
15
|
+
uid: Annotated[str, {"resr_classification":"auth_required_restricted",
|
|
16
|
+
"resr_readable_by": ["owner", "selected_by_admin"],
|
|
17
|
+
"resr_updatable_by": ["admin"],
|
|
18
|
+
"resr_original_or_processed" : "original_source",
|
|
19
|
+
"resr_origin":"internal",
|
|
20
|
+
"resr_origin_organisation_uids":["20231220futureedgegroup_coreorgn"],
|
|
21
|
+
"resr_origin_description":"Original User field",
|
|
22
|
+
"resr_creat_date":datetime(2023, 12, 23),
|
|
23
|
+
"resr_creat_by_user":"Russlan Ramdowar;russlan@ftredge.com",
|
|
24
|
+
"metadata_updt_date":datetime(2023, 12, 23),
|
|
25
|
+
"metadata_updt_by_user":"Russlan Ramdowar;russlan@ftredge.com"}] = Field(frozen=True, description="Generated by Firebase Auth",
|
|
26
|
+
)
|
|
27
|
+
|
|
28
|
+
puid:str = Field(default_factory=lambda: f"{datetime.utcnow().strftime('%Y%m%d%H%M')}{uuid.uuid4().hex[:8]}_{MODULE}{CLASS_REF}".lower(),
|
|
29
|
+
frozen=True,
|
|
30
|
+
description="Generated Automatically by default_factory",
|
|
31
|
+
metadata={"resr_classification":"auth_required_restricted",
|
|
32
|
+
"resr_readable_by": ["owner", "selected_by_admin"],
|
|
33
|
+
"resr_updatable_by": [],
|
|
34
|
+
"resr_original_or_processed" : "original_source",
|
|
35
|
+
"resr_origin":"internal",
|
|
36
|
+
"resr_origin_organisation_uids":["20231220futureedgegroup_coreorgn"],
|
|
37
|
+
"resr_origin_description":"Original User field",
|
|
38
|
+
"resr_creat_date":datetime(2023, 12, 23),
|
|
39
|
+
"resr_creat_by_user":"Russlan Ramdowar;russlan@ftredge.com",
|
|
40
|
+
"metadata_updt_date":datetime(2023, 12, 23),
|
|
41
|
+
"metadata_updt_by_user":"Russlan Ramdowar;russlan@ftredge.com"})
|
|
42
|
+
email: EmailStr = Field(frozen=True,
|
|
43
|
+
description="Propagated from Firebase Auth",
|
|
44
|
+
metadata={"resr_classification":"auth_required_restricted",
|
|
45
|
+
"resr_readable_by": ["owner", "selected_by_admin"],
|
|
46
|
+
"resr_updatable_by": ["owner","admin"],
|
|
47
|
+
"resr_original_or_processed" : "original_source",
|
|
48
|
+
"resr_origin":"internal",
|
|
49
|
+
"resr_origin_organisation_uids":["20231220futureedgegroup_coreorgn"],
|
|
50
|
+
"resr_origin_description":"Original User field",
|
|
51
|
+
"resr_creat_date":datetime(2023, 12, 23),
|
|
52
|
+
"resr_creat_by_user":"Russlan Ramdowar;russlan@ftredge.com",
|
|
53
|
+
"metadata_updt_date":datetime(2023, 12, 23),
|
|
54
|
+
"metadata_updt_by_user":"Russlan Ramdowar;russlan@ftredge.com"})
|
|
55
|
+
insights_credits: int= Field(default_factory=lambda:7,
|
|
56
|
+
description="Depends on Subscription Plan, Regularly Updated",
|
|
57
|
+
metadata={"resr_classification":"auth_required_confidential",
|
|
58
|
+
"resr_readable_by": ["owner", "selected_by_admin"],
|
|
59
|
+
"resr_updatable_by": ["admin"],
|
|
60
|
+
"resr_original_or_processed" : "original_source",
|
|
61
|
+
"resr_origin":"internal",
|
|
62
|
+
"resr_origin_organisation_uids":["20231220futureedgegroup_coreorgn"],
|
|
63
|
+
"resr_origin_description":"Original User field",
|
|
64
|
+
"resr_creat_date":datetime(2023, 12, 23),
|
|
65
|
+
"resr_creat_by_user":"Russlan Ramdowar",
|
|
66
|
+
"metadata_updt_date":datetime(2023, 12, 23),
|
|
67
|
+
"metadata_updt_by_user":"Russlan Ramdowar"})
|
|
68
|
+
organizations_uids: Set[str] = Field(
|
|
69
|
+
description="Depends on Subscription Plan, Regularly Updated",
|
|
70
|
+
metadata={"resr_classification":"auth_required_confidential",
|
|
71
|
+
"resr_readable_by": ["owner", "selected_by_admin"],
|
|
72
|
+
"resr_updatable_by": ["selected_by_admin"],
|
|
73
|
+
"resr_original_or_processed" : "original_source",
|
|
74
|
+
"resr_origin":"internal",
|
|
75
|
+
"resr_origin_organisation_uids":["20231220futureedgegroup_coreorgn"],
|
|
76
|
+
"resr_origin_description":"Original User field",
|
|
77
|
+
"resr_creat_date":datetime(2023, 12, 23),
|
|
78
|
+
"resr_creat_by_user":"Russlan Ramdowar",
|
|
79
|
+
"metadata_updt_date":datetime(2023, 12, 23),
|
|
80
|
+
"metadata_updt_by_user":"Russlan Ramdowar"})
|
|
81
|
+
creat_date: datetime #User can Read only
|
|
82
|
+
creat_by_user: str #User shouldn't see this or edit this_dump=
|
|
83
|
+
updt_date: datetime #User can Read only
|
|
84
|
+
updt_by_user: str #User shouldn't see this or edit this
|
|
85
|
+
approved: bool #User shouldn't see this or edit this
|
|
86
|
+
provider_id: str #User shouldn't see this or edit this
|
|
87
|
+
username: Optional[str] = None #User can Read and Edit
|
|
88
|
+
aliases: Optional[Set[str]] = None #User can Read and Edit
|
|
89
|
+
dob: Optional[date] = None #User can Read and Edit
|
|
90
|
+
first_name: Optional[str] = None #User can Read and Edit
|
|
91
|
+
last_name: Optional[str] = None #User can Read and Edit
|
|
92
|
+
mobile: Optional[str] = None #User can Read and Edit
|
|
93
|
+
groups_names: Set[str] = None #User can Read only
|
|
94
|
+
policies_uids: Optional[Set[str]] = None #User can Read only
|
|
95
|
+
subscription_plan_uid: Optional[str]=None #User can Read only
|
|
96
|
+
insights_credits_updated_since: Optional[datetime]=None #User can Read only
|
|
97
|
+
|
|
98
|
+
|
|
99
|
+
|
|
100
|
+
class Config:
|
|
101
|
+
extra = "forbid"
|
|
102
|
+
# Custom metadata
|
|
103
|
+
metadata = {
|
|
104
|
+
"resr_puid_or_name":"Users",
|
|
105
|
+
"resr_path":"firestore/Users",
|
|
106
|
+
"resr_name":"Users",
|
|
107
|
+
"resr_pulse_module":MODULE,
|
|
108
|
+
"resr_type":"firestore_collection",
|
|
109
|
+
"resr_classifications":{ "auth_required_confidential"},
|
|
110
|
+
"resr_contents":{"user_core_profile"},
|
|
111
|
+
"resr_original_or_processed":"original_source",
|
|
112
|
+
"resr_origin":"internal",
|
|
113
|
+
"resr_origin_organisations_uids":{"20231220futureedgegroup_coreorgn"},
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
@root_validator(pre=True)
|
|
117
|
+
def check_resr_classification(cls, values: Dict[Any, Any]):
|
|
118
|
+
for field_name, field_value in values.items():
|
|
119
|
+
if field_name in cls.model_fields:
|
|
120
|
+
print(f"field_name : {field_name} , field_value : {field_value}")
|
|
121
|
+
# field_info = cls.model_fields[field_name].field_info
|
|
122
|
+
# resr_classification = field_info.extra.get("resr_classification")
|
|
123
|
+
# if resr_classification and resr_classification not in enums.resource_classifications:
|
|
124
|
+
# raise ValueError(f"Invalid resource_classification '{resr_classification}' for field '{field_name}'")
|
|
125
|
+
return values
|
|
126
|
+
|
|
127
|
+
|
|
128
|
+
|
|
129
|
+
# class User(BaseModel):
|
|
130
|
+
# puid: str
|
|
131
|
+
# puid2:str #User can Read only
|
|
132
|
+
# email: EmailStr #User can Read only
|
|
133
|
+
# insights_credits: int=7 #User can Read only
|
|
134
|
+
# organizations_ids: Set[str] #User can Read only
|
|
135
|
+
# created_at: datetime #User can Read only
|
|
136
|
+
# created_by: str #User shouldn't see this or edit this
|
|
137
|
+
# updated_at: datetime #User can Read only
|
|
138
|
+
# updated_by: str #User shouldn't see this or edit this
|
|
139
|
+
# approved: bool #User shouldn't see this or edit this
|
|
140
|
+
# provider_id: str #User shouldn't see this or edit this
|
|
141
|
+
# username: Optional[str] = None #User can Read and Edit
|
|
142
|
+
# aliases: Optional[Set[str]] = None #User can Read and Edit
|
|
143
|
+
# dob: Optional[date] = None #User can Read and Edit
|
|
144
|
+
# first_name: Optional[str] = None #User can Read and Edit
|
|
145
|
+
# last_name: Optional[str] = None #User can Read and Edit
|
|
146
|
+
# mobile: Optional[str] = None #User can Read and Edit
|
|
147
|
+
# groups_names: Set[str] = None #User can Read only
|
|
148
|
+
# policies_uids: Optional[Set[str]] = None #User can Read only
|
|
149
|
+
# subscription_plan_uid: Optional[str]=None #User can Read only
|
|
150
|
+
# insights_credits_updated_since: Optional[datetime]=None #User can Read only
|
|
151
|
+
# class_version: float = CLASS_VERSION #User shouldn't see this or edit this
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
|
|
2
|
+
from typing import Optional, Set
|
|
3
|
+
from pydantic import BaseModel
|
|
4
|
+
from datetime import datetime , date
|
|
5
|
+
|
|
6
|
+
class UserProfileUpdate(BaseModel):
|
|
7
|
+
email: Optional[str] = None
|
|
8
|
+
username: Optional[str] = None
|
|
9
|
+
aliases: Optional[Set[str]] = None
|
|
10
|
+
first_name: Optional[str] = None
|
|
11
|
+
last_name: Optional[str] = None
|
|
12
|
+
mobile: Optional[str] = None
|
|
13
|
+
dob: Optional[date] = None
|
|
14
|
+
updt_date: Optional[datetime] = None
|
|
15
|
+
updt_by_user: Optional[str] = None
|
|
16
|
+
|
|
17
|
+
def model_dump(self, **kwargs):
|
|
18
|
+
return super().model_dump(exclude_none=True, **kwargs)
|
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: ipulse_shared_core_ftredge
|
|
3
|
-
Version: 1.
|
|
3
|
+
Version: 1.2.0
|
|
4
4
|
Summary: Shared models 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
|
|
7
|
-
Author-email: russlan@ftredge.com
|
|
8
7
|
License-File: LICENCE
|
|
9
8
|
Requires-Dist: pydantic[email]
|
|
10
9
|
Requires-Dist: uuid
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
LICENCE
|
|
2
|
+
README.md
|
|
3
|
+
pyproject.toml
|
|
4
|
+
setup.py
|
|
5
|
+
src/ipulse_shared_core_ftredge/__init__.py
|
|
6
|
+
src/ipulse_shared_core_ftredge.egg-info/PKG-INFO
|
|
7
|
+
src/ipulse_shared_core_ftredge.egg-info/SOURCES.txt
|
|
8
|
+
src/ipulse_shared_core_ftredge.egg-info/dependency_links.txt
|
|
9
|
+
src/ipulse_shared_core_ftredge.egg-info/requires.txt
|
|
10
|
+
src/ipulse_shared_core_ftredge.egg-info/top_level.txt
|
|
11
|
+
src/ipulse_shared_core_ftredge/models/__init__.py
|
|
12
|
+
src/ipulse_shared_core_ftredge/models/audit_log_firestore.py
|
|
13
|
+
src/ipulse_shared_core_ftredge/models/organisation.py
|
|
14
|
+
src/ipulse_shared_core_ftredge/models/pulse_enums.py
|
|
15
|
+
src/ipulse_shared_core_ftredge/models/resource_catalog_item.py
|
|
16
|
+
src/ipulse_shared_core_ftredge/models/user_auth.py
|
|
17
|
+
src/ipulse_shared_core_ftredge/models/user_profile.py
|
|
18
|
+
src/ipulse_shared_core_ftredge/models/user_profile_update.py
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
ipulse_shared_core_ftredge
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
LICENCE
|
|
2
|
-
README.md
|
|
3
|
-
pyproject.toml
|
|
4
|
-
setup.py
|
|
5
|
-
ipulse_shared_core_ftredge.egg-info/PKG-INFO
|
|
6
|
-
ipulse_shared_core_ftredge.egg-info/SOURCES.txt
|
|
7
|
-
ipulse_shared_core_ftredge.egg-info/dependency_links.txt
|
|
8
|
-
ipulse_shared_core_ftredge.egg-info/requires.txt
|
|
9
|
-
ipulse_shared_core_ftredge.egg-info/top_level.txt
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|