trovesuite 1.0.4__tar.gz → 1.0.6__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 (39) hide show
  1. {trovesuite-1.0.4/src/trovesuite.egg-info → trovesuite-1.0.6}/PKG-INFO +176 -5
  2. {trovesuite-1.0.4 → trovesuite-1.0.6}/README.md +175 -4
  3. {trovesuite-1.0.4 → trovesuite-1.0.6}/pyproject.toml +2 -2
  4. {trovesuite-1.0.4 → trovesuite-1.0.6}/setup.py +1 -1
  5. trovesuite-1.0.6/src/trovesuite/__init__.py +18 -0
  6. trovesuite-1.0.6/src/trovesuite/auth/__init__.py +14 -0
  7. trovesuite-1.0.6/src/trovesuite/auth/auth_controller.py +11 -0
  8. {trovesuite-1.0.4 → trovesuite-1.0.6}/src/trovesuite/entities/health.py +4 -4
  9. trovesuite-1.0.6/src/trovesuite/notification/__init__.py +14 -0
  10. trovesuite-1.0.6/src/trovesuite/notification/notification_base.py +13 -0
  11. trovesuite-1.0.6/src/trovesuite/notification/notification_controller.py +21 -0
  12. trovesuite-1.0.6/src/trovesuite/notification/notification_read_dto.py +21 -0
  13. trovesuite-1.0.6/src/trovesuite/notification/notification_service.py +73 -0
  14. trovesuite-1.0.6/src/trovesuite/notification/notification_write_dto.py +21 -0
  15. {trovesuite-1.0.4 → trovesuite-1.0.6/src/trovesuite.egg-info}/PKG-INFO +176 -5
  16. {trovesuite-1.0.4 → trovesuite-1.0.6}/src/trovesuite.egg-info/SOURCES.txt +6 -0
  17. trovesuite-1.0.4/src/trovesuite/__init__.py +0 -16
  18. trovesuite-1.0.4/src/trovesuite/auth/__init__.py +0 -17
  19. trovesuite-1.0.4/src/trovesuite/auth/auth_controller.py +0 -11
  20. {trovesuite-1.0.4 → trovesuite-1.0.6}/LICENSE +0 -0
  21. {trovesuite-1.0.4 → trovesuite-1.0.6}/MANIFEST.in +0 -0
  22. {trovesuite-1.0.4 → trovesuite-1.0.6}/requirements.txt +0 -0
  23. {trovesuite-1.0.4 → trovesuite-1.0.6}/setup.cfg +0 -0
  24. {trovesuite-1.0.4 → trovesuite-1.0.6}/src/trovesuite/auth/auth_base.py +0 -0
  25. {trovesuite-1.0.4 → trovesuite-1.0.6}/src/trovesuite/auth/auth_read_dto.py +0 -0
  26. {trovesuite-1.0.4 → trovesuite-1.0.6}/src/trovesuite/auth/auth_service.py +0 -0
  27. {trovesuite-1.0.4 → trovesuite-1.0.6}/src/trovesuite/auth/auth_write_dto.py +0 -0
  28. {trovesuite-1.0.4 → trovesuite-1.0.6}/src/trovesuite/configs/__init__.py +0 -0
  29. {trovesuite-1.0.4 → trovesuite-1.0.6}/src/trovesuite/configs/database.py +0 -0
  30. {trovesuite-1.0.4 → trovesuite-1.0.6}/src/trovesuite/configs/logging.py +0 -0
  31. {trovesuite-1.0.4 → trovesuite-1.0.6}/src/trovesuite/configs/settings.py +0 -0
  32. {trovesuite-1.0.4 → trovesuite-1.0.6}/src/trovesuite/entities/__init__.py +0 -0
  33. {trovesuite-1.0.4 → trovesuite-1.0.6}/src/trovesuite/entities/sh_response.py +0 -0
  34. {trovesuite-1.0.4 → trovesuite-1.0.6}/src/trovesuite/utils/__init__.py +0 -0
  35. {trovesuite-1.0.4 → trovesuite-1.0.6}/src/trovesuite/utils/helper.py +0 -0
  36. {trovesuite-1.0.4 → trovesuite-1.0.6}/src/trovesuite.egg-info/dependency_links.txt +0 -0
  37. {trovesuite-1.0.4 → trovesuite-1.0.6}/src/trovesuite.egg-info/not-zip-safe +0 -0
  38. {trovesuite-1.0.4 → trovesuite-1.0.6}/src/trovesuite.egg-info/requires.txt +0 -0
  39. {trovesuite-1.0.4 → trovesuite-1.0.6}/src/trovesuite.egg-info/top_level.txt +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: trovesuite
3
- Version: 1.0.4
3
+ Version: 1.0.6
4
4
  Summary: TroveSuite services package providing authentication, authorization, notifications, and other enterprise services for TroveSuite applications
5
5
  Home-page: https://dev.azure.com/brightgclt/trovesuite/_git/packages
6
6
  Author: Bright Debrah Owusu
@@ -119,10 +119,28 @@ poetry install --with dev
119
119
 
120
120
  ## Quick Start
121
121
 
122
+ > **✅ Package Status**: All import issues have been resolved in version 1.0.5. The package now works correctly when installed from PyPI or wheel files.
123
+
124
+ ### Import Patterns
125
+
126
+ The package provides clean, simplified import patterns:
127
+
128
+ ```python
129
+ # Import services and DTOs from main package
130
+ from trovesuite import AuthService, NotificationService
131
+ from trovesuite.auth import AuthServiceWriteDto
132
+ from trovesuite.notification import NotificationEmailServiceWriteDto, NotificationSMSServiceWriteDto
133
+
134
+ # Or import everything you need in one line
135
+ from trovesuite import AuthService, NotificationService
136
+ from trovesuite.auth import AuthServiceWriteDto
137
+ from trovesuite.notification import NotificationEmailServiceWriteDto
138
+ ```
139
+
122
140
  ### Basic Usage
123
141
 
124
142
  ```python
125
- from trovesuite import AuthService
143
+ from trovesuite import AuthService, NotificationService
126
144
  from trovesuite.configs.settings import db_settings
127
145
 
128
146
  # Configure your database settings
@@ -137,7 +155,7 @@ db_settings.SECRET_KEY = "your-secret-key"
137
155
  auth_service = AuthService()
138
156
 
139
157
  # Authorize a user
140
- from trovesuite.auth.auth_write_dto import AuthServiceWriteDto
158
+ from trovesuite.auth import AuthServiceWriteDto
141
159
  auth_data = AuthServiceWriteDto(user_id="user123", tenant="tenant456")
142
160
  result = AuthService.authorize(auth_data)
143
161
 
@@ -149,6 +167,30 @@ else:
149
167
  print(f"Authorization failed: {result.detail}")
150
168
  ```
151
169
 
170
+ ### Notification Service Usage
171
+
172
+ ```python
173
+ from trovesuite import NotificationService
174
+ from trovesuite.notification import NotificationEmailServiceWriteDto
175
+
176
+ # Send an email notification
177
+ email_data = NotificationEmailServiceWriteDto(
178
+ sender_email="your-email@gmail.com",
179
+ receiver_email=["recipient1@example.com", "recipient2@example.com"],
180
+ password="your-app-password", # Gmail app password
181
+ subject="Test Notification",
182
+ text_message="This is a plain text message",
183
+ html_message="<h1>This is an HTML message</h1><p>With rich formatting!</p>"
184
+ )
185
+
186
+ result = NotificationService.send_email(email_data)
187
+
188
+ if result.success:
189
+ print(f"Email sent successfully: {result.detail}")
190
+ else:
191
+ print(f"Email failed: {result.error}")
192
+ ```
193
+
152
194
  ### JWT Token Decoding
153
195
 
154
196
  ```python
@@ -166,7 +208,7 @@ async def protected_route(token: str = Depends(oauth2_scheme)):
166
208
  tenant_id = user_data["tenant_id"]
167
209
 
168
210
  # Authorize user
169
- from trovesuite.auth.auth_write_dto import AuthServiceWriteDto
211
+ from trovesuite.auth import AuthServiceWriteDto
170
212
  auth_data = AuthServiceWriteDto(user_id=user_id, tenant=tenant_id)
171
213
  auth_result = AuthService.authorize(auth_data)
172
214
  return auth_result
@@ -395,8 +437,84 @@ Check if user has all of the required permissions.
395
437
  **Returns:**
396
438
  - `bool`: True if user has all of the required permissions
397
439
 
440
+ ### NotificationService
441
+
442
+ #### `send_email(data: NotificationEmailServiceWriteDto) -> Respons[NotificationEmailServiceReadDto]`
443
+
444
+ Sends an email notification via Gmail SMTP. Supports both plain text and HTML email bodies.
445
+
446
+ **Parameters:**
447
+ - `data`: Email notification data including sender, recipients, subject, and message content
448
+
449
+ **Returns:**
450
+ - `Respons[NotificationEmailServiceReadDto]`: Email sending result with success status and details
451
+
452
+ **Example:**
453
+ ```python
454
+ from trovesuite import NotificationService
455
+ from trovesuite.notification import NotificationEmailServiceWriteDto
456
+
457
+ email_data = NotificationEmailServiceWriteDto(
458
+ sender_email="sender@gmail.com",
459
+ receiver_email=["user1@example.com", "user2@example.com"],
460
+ password="your-gmail-app-password",
461
+ subject="Welcome to TroveSuite",
462
+ text_message="Welcome! This is a plain text message.",
463
+ html_message="<h1>Welcome!</h1><p>This is an <strong>HTML</strong> message.</p>"
464
+ )
465
+
466
+ result = NotificationService.send_email(email_data)
467
+ if result.success:
468
+ print("Email sent successfully!")
469
+ else:
470
+ print(f"Failed to send email: {result.error}")
471
+ ```
472
+
473
+ #### `send_sms(data: NotificationSMSServiceWriteDto) -> Respons[NotificationSMSServiceReadDto]`
474
+
475
+ Sends an SMS notification (currently not implemented).
476
+
477
+ **Parameters:**
478
+ - `data`: SMS notification data
479
+
480
+ **Returns:**
481
+ - `Respons[NotificationSMSServiceReadDto]`: SMS sending result
482
+
398
483
  ### Data Models
399
484
 
485
+ #### `NotificationEmailServiceWriteDto`
486
+
487
+ ```python
488
+ class NotificationEmailServiceWriteDto(BaseModel):
489
+ sender_email: str
490
+ receiver_email: Union[str, List[str]] # Single email or list of emails
491
+ password: str # Gmail app password
492
+ subject: str
493
+ text_message: str
494
+ html_message: Optional[str] = None # Optional HTML content
495
+ ```
496
+
497
+ #### `NotificationEmailServiceReadDto`
498
+
499
+ ```python
500
+ class NotificationEmailServiceReadDto(BaseModel):
501
+ pass # Empty response model for email service
502
+ ```
503
+
504
+ #### `NotificationSMSServiceWriteDto`
505
+
506
+ ```python
507
+ class NotificationSMSServiceWriteDto(BaseModel):
508
+ pass # To be implemented for SMS functionality
509
+ ```
510
+
511
+ #### `NotificationSMSServiceReadDto`
512
+
513
+ ```python
514
+ class NotificationSMSServiceReadDto(BaseModel):
515
+ pass # To be implemented for SMS functionality
516
+ ```
517
+
400
518
  #### `AuthServiceReadDto`
401
519
 
402
520
  ```python
@@ -557,15 +675,65 @@ poetry install
557
675
 
558
676
  This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
559
677
 
678
+ ## Troubleshooting
679
+
680
+ ### Import Issues
681
+
682
+ If you encounter import errors, make sure you're using the correct import patterns:
683
+
684
+ ```python
685
+ # ✅ Correct imports
686
+ from trovesuite import AuthService, NotificationService
687
+ from trovesuite.auth import AuthServiceWriteDto
688
+ from trovesuite.notification import NotificationEmailServiceWriteDto
689
+
690
+ # ❌ Incorrect imports (will fail)
691
+ from trovesuite.auth.auth_write_dto import AuthServiceWriteDto # Too specific
692
+ from trovesuite.notification.notification_write_dto import NotificationEmailServiceWriteDto # Too specific
693
+ ```
694
+
695
+ ### Package Installation
696
+
697
+ If you're having issues with the package installation:
698
+
699
+ 1. **Make sure you have the latest version**:
700
+ ```bash
701
+ pip install --upgrade trovesuite
702
+ ```
703
+
704
+ 2. **Force reinstall if needed**:
705
+ ```bash
706
+ pip install --force-reinstall trovesuite
707
+ ```
708
+
709
+ 3. **Check your Python environment**:
710
+ ```bash
711
+ python -c "import trovesuite; print('Package installed successfully')"
712
+ ```
713
+
714
+ ### Common Issues
715
+
716
+ - **ImportError: No module named 'src'**: This was fixed in version 1.0.5. Update to the latest version.
717
+ - **AttributeError: module has no attribute 'AuthServiceWriteDto'**: Use `from trovesuite.auth import AuthServiceWriteDto` instead of importing from the main package.
718
+
560
719
  ## Support
561
720
 
562
721
  For support, email brightgclt@gmail.com or create a work item in the [Azure DevOps repository](https://dev.azure.com/brightgclt/trovesuite/_workitems/create).
563
722
 
564
723
  ## Changelog
565
724
 
725
+ ### 1.0.5
726
+ - Fixed all import issues across auth, notification, and entities modules
727
+ - Changed absolute imports (`from src.trovesuite.`) to relative imports (`from .` and `from ..`)
728
+ - Ensured package works correctly when installed from PyPI or wheel
729
+ - Added service write DTOs to module exports for easier usage
730
+ - Updated documentation with simplified import patterns
731
+ - All services and DTOs now import correctly in clean environments
732
+ - Package builds and installs without import errors
733
+
566
734
  ### 1.0.8
567
735
  - Restructured package for direct service imports
568
- - Added notification services
736
+ - Added comprehensive notification services with email support
569
737
  - Excluded controllers from package build
570
738
  - Updated import paths for better usability
571
739
  - JWT token validation
@@ -574,3 +742,6 @@ For support, email brightgclt@gmail.com or create a work item in the [Azure DevO
574
742
  - PostgreSQL database integration
575
743
  - Comprehensive logging
576
744
  - Azure integration support
745
+ - Email notification service with Gmail SMTP support
746
+ - Support for both plain text and HTML email content
747
+ - Multiple recipient support for email notifications
@@ -66,10 +66,28 @@ poetry install --with dev
66
66
 
67
67
  ## Quick Start
68
68
 
69
+ > **✅ Package Status**: All import issues have been resolved in version 1.0.5. The package now works correctly when installed from PyPI or wheel files.
70
+
71
+ ### Import Patterns
72
+
73
+ The package provides clean, simplified import patterns:
74
+
75
+ ```python
76
+ # Import services and DTOs from main package
77
+ from trovesuite import AuthService, NotificationService
78
+ from trovesuite.auth import AuthServiceWriteDto
79
+ from trovesuite.notification import NotificationEmailServiceWriteDto, NotificationSMSServiceWriteDto
80
+
81
+ # Or import everything you need in one line
82
+ from trovesuite import AuthService, NotificationService
83
+ from trovesuite.auth import AuthServiceWriteDto
84
+ from trovesuite.notification import NotificationEmailServiceWriteDto
85
+ ```
86
+
69
87
  ### Basic Usage
70
88
 
71
89
  ```python
72
- from trovesuite import AuthService
90
+ from trovesuite import AuthService, NotificationService
73
91
  from trovesuite.configs.settings import db_settings
74
92
 
75
93
  # Configure your database settings
@@ -84,7 +102,7 @@ db_settings.SECRET_KEY = "your-secret-key"
84
102
  auth_service = AuthService()
85
103
 
86
104
  # Authorize a user
87
- from trovesuite.auth.auth_write_dto import AuthServiceWriteDto
105
+ from trovesuite.auth import AuthServiceWriteDto
88
106
  auth_data = AuthServiceWriteDto(user_id="user123", tenant="tenant456")
89
107
  result = AuthService.authorize(auth_data)
90
108
 
@@ -96,6 +114,30 @@ else:
96
114
  print(f"Authorization failed: {result.detail}")
97
115
  ```
98
116
 
117
+ ### Notification Service Usage
118
+
119
+ ```python
120
+ from trovesuite import NotificationService
121
+ from trovesuite.notification import NotificationEmailServiceWriteDto
122
+
123
+ # Send an email notification
124
+ email_data = NotificationEmailServiceWriteDto(
125
+ sender_email="your-email@gmail.com",
126
+ receiver_email=["recipient1@example.com", "recipient2@example.com"],
127
+ password="your-app-password", # Gmail app password
128
+ subject="Test Notification",
129
+ text_message="This is a plain text message",
130
+ html_message="<h1>This is an HTML message</h1><p>With rich formatting!</p>"
131
+ )
132
+
133
+ result = NotificationService.send_email(email_data)
134
+
135
+ if result.success:
136
+ print(f"Email sent successfully: {result.detail}")
137
+ else:
138
+ print(f"Email failed: {result.error}")
139
+ ```
140
+
99
141
  ### JWT Token Decoding
100
142
 
101
143
  ```python
@@ -113,7 +155,7 @@ async def protected_route(token: str = Depends(oauth2_scheme)):
113
155
  tenant_id = user_data["tenant_id"]
114
156
 
115
157
  # Authorize user
116
- from trovesuite.auth.auth_write_dto import AuthServiceWriteDto
158
+ from trovesuite.auth import AuthServiceWriteDto
117
159
  auth_data = AuthServiceWriteDto(user_id=user_id, tenant=tenant_id)
118
160
  auth_result = AuthService.authorize(auth_data)
119
161
  return auth_result
@@ -342,8 +384,84 @@ Check if user has all of the required permissions.
342
384
  **Returns:**
343
385
  - `bool`: True if user has all of the required permissions
344
386
 
387
+ ### NotificationService
388
+
389
+ #### `send_email(data: NotificationEmailServiceWriteDto) -> Respons[NotificationEmailServiceReadDto]`
390
+
391
+ Sends an email notification via Gmail SMTP. Supports both plain text and HTML email bodies.
392
+
393
+ **Parameters:**
394
+ - `data`: Email notification data including sender, recipients, subject, and message content
395
+
396
+ **Returns:**
397
+ - `Respons[NotificationEmailServiceReadDto]`: Email sending result with success status and details
398
+
399
+ **Example:**
400
+ ```python
401
+ from trovesuite import NotificationService
402
+ from trovesuite.notification import NotificationEmailServiceWriteDto
403
+
404
+ email_data = NotificationEmailServiceWriteDto(
405
+ sender_email="sender@gmail.com",
406
+ receiver_email=["user1@example.com", "user2@example.com"],
407
+ password="your-gmail-app-password",
408
+ subject="Welcome to TroveSuite",
409
+ text_message="Welcome! This is a plain text message.",
410
+ html_message="<h1>Welcome!</h1><p>This is an <strong>HTML</strong> message.</p>"
411
+ )
412
+
413
+ result = NotificationService.send_email(email_data)
414
+ if result.success:
415
+ print("Email sent successfully!")
416
+ else:
417
+ print(f"Failed to send email: {result.error}")
418
+ ```
419
+
420
+ #### `send_sms(data: NotificationSMSServiceWriteDto) -> Respons[NotificationSMSServiceReadDto]`
421
+
422
+ Sends an SMS notification (currently not implemented).
423
+
424
+ **Parameters:**
425
+ - `data`: SMS notification data
426
+
427
+ **Returns:**
428
+ - `Respons[NotificationSMSServiceReadDto]`: SMS sending result
429
+
345
430
  ### Data Models
346
431
 
432
+ #### `NotificationEmailServiceWriteDto`
433
+
434
+ ```python
435
+ class NotificationEmailServiceWriteDto(BaseModel):
436
+ sender_email: str
437
+ receiver_email: Union[str, List[str]] # Single email or list of emails
438
+ password: str # Gmail app password
439
+ subject: str
440
+ text_message: str
441
+ html_message: Optional[str] = None # Optional HTML content
442
+ ```
443
+
444
+ #### `NotificationEmailServiceReadDto`
445
+
446
+ ```python
447
+ class NotificationEmailServiceReadDto(BaseModel):
448
+ pass # Empty response model for email service
449
+ ```
450
+
451
+ #### `NotificationSMSServiceWriteDto`
452
+
453
+ ```python
454
+ class NotificationSMSServiceWriteDto(BaseModel):
455
+ pass # To be implemented for SMS functionality
456
+ ```
457
+
458
+ #### `NotificationSMSServiceReadDto`
459
+
460
+ ```python
461
+ class NotificationSMSServiceReadDto(BaseModel):
462
+ pass # To be implemented for SMS functionality
463
+ ```
464
+
347
465
  #### `AuthServiceReadDto`
348
466
 
349
467
  ```python
@@ -504,15 +622,65 @@ poetry install
504
622
 
505
623
  This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
506
624
 
625
+ ## Troubleshooting
626
+
627
+ ### Import Issues
628
+
629
+ If you encounter import errors, make sure you're using the correct import patterns:
630
+
631
+ ```python
632
+ # ✅ Correct imports
633
+ from trovesuite import AuthService, NotificationService
634
+ from trovesuite.auth import AuthServiceWriteDto
635
+ from trovesuite.notification import NotificationEmailServiceWriteDto
636
+
637
+ # ❌ Incorrect imports (will fail)
638
+ from trovesuite.auth.auth_write_dto import AuthServiceWriteDto # Too specific
639
+ from trovesuite.notification.notification_write_dto import NotificationEmailServiceWriteDto # Too specific
640
+ ```
641
+
642
+ ### Package Installation
643
+
644
+ If you're having issues with the package installation:
645
+
646
+ 1. **Make sure you have the latest version**:
647
+ ```bash
648
+ pip install --upgrade trovesuite
649
+ ```
650
+
651
+ 2. **Force reinstall if needed**:
652
+ ```bash
653
+ pip install --force-reinstall trovesuite
654
+ ```
655
+
656
+ 3. **Check your Python environment**:
657
+ ```bash
658
+ python -c "import trovesuite; print('Package installed successfully')"
659
+ ```
660
+
661
+ ### Common Issues
662
+
663
+ - **ImportError: No module named 'src'**: This was fixed in version 1.0.5. Update to the latest version.
664
+ - **AttributeError: module has no attribute 'AuthServiceWriteDto'**: Use `from trovesuite.auth import AuthServiceWriteDto` instead of importing from the main package.
665
+
507
666
  ## Support
508
667
 
509
668
  For support, email brightgclt@gmail.com or create a work item in the [Azure DevOps repository](https://dev.azure.com/brightgclt/trovesuite/_workitems/create).
510
669
 
511
670
  ## Changelog
512
671
 
672
+ ### 1.0.5
673
+ - Fixed all import issues across auth, notification, and entities modules
674
+ - Changed absolute imports (`from src.trovesuite.`) to relative imports (`from .` and `from ..`)
675
+ - Ensured package works correctly when installed from PyPI or wheel
676
+ - Added service write DTOs to module exports for easier usage
677
+ - Updated documentation with simplified import patterns
678
+ - All services and DTOs now import correctly in clean environments
679
+ - Package builds and installs without import errors
680
+
513
681
  ### 1.0.8
514
682
  - Restructured package for direct service imports
515
- - Added notification services
683
+ - Added comprehensive notification services with email support
516
684
  - Excluded controllers from package build
517
685
  - Updated import paths for better usability
518
686
  - JWT token validation
@@ -521,3 +689,6 @@ For support, email brightgclt@gmail.com or create a work item in the [Azure DevO
521
689
  - PostgreSQL database integration
522
690
  - Comprehensive logging
523
691
  - Azure integration support
692
+ - Email notification service with Gmail SMTP support
693
+ - Support for both plain text and HTML email content
694
+ - Multiple recipient support for email notifications
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [tool.poetry]
6
6
  name = "trovesuite"
7
- version = "1.0.4"
7
+ version = "1.0.6"
8
8
  description = "TroveSuite services package providing authentication, authorization, notifications, and other enterprise services for TroveSuite applications"
9
9
  authors = ["brightgclt <brightgclt@gmail.com>"]
10
10
  license = "MIT"
@@ -56,7 +56,7 @@ Documentation = "https://dev.azure.com/brightgclt/trovesuite/_git/packages"
56
56
 
57
57
  [project]
58
58
  name = "trovesuite"
59
- version = "1.0.4"
59
+ version = "1.0.6"
60
60
  description = "TroveSuite services package providing authentication, authorization, notifications, and other enterprise services for TroveSuite applications"
61
61
  readme = "README.md"
62
62
  license = {text = "MIT"}
@@ -15,7 +15,7 @@ with open("pyproject.toml", "r", encoding="utf-8") as fh:
15
15
 
16
16
  setup(
17
17
  name="trovesuite",
18
- version="1.0.4",
18
+ version="1.0.6",
19
19
  author="Bright Debrah Owusu",
20
20
  author_email="owusu.debrah@deladetech.com",
21
21
  description="TroveSuite services package providing authentication, authorization, notifications, and other enterprise services for TroveSuite applications",
@@ -0,0 +1,18 @@
1
+ """
2
+ TroveSuite Package
3
+
4
+ A comprehensive authentication, authorization, and notification service for ERP systems.
5
+ Provides JWT token validation, user authorization, permission checking, and notification capabilities.
6
+ """
7
+
8
+ from .auth import AuthService
9
+ from .notification import NotificationService
10
+
11
+ __version__ = "1.0.5"
12
+ __author__ = "Bright Debrah Owusu"
13
+ __email__ = "owusu.debrah@deladetech.com"
14
+
15
+ __all__ = [
16
+ "AuthService",
17
+ "NotificationService"
18
+ ]
@@ -0,0 +1,14 @@
1
+ """
2
+ TroveSuite Auth Module
3
+
4
+ Authentication and authorization services for ERP systems.
5
+ """
6
+
7
+ from .auth_service import AuthService
8
+ from .auth_write_dto import AuthServiceWriteDto
9
+
10
+ __all__ = [
11
+ "AuthService",
12
+ "AuthServiceWriteDto"
13
+ ]
14
+
@@ -0,0 +1,11 @@
1
+ from fastapi import APIRouter
2
+ from .auth_write_dto import AuthControllerWriteDto
3
+ from .auth_read_dto import AuthControllerReadDto
4
+ from .auth_service import AuthService
5
+ from ..entities.sh_response import Respons
6
+
7
+ auth_router = APIRouter()
8
+
9
+ @auth_router.post("/auth", response_model=Respons[AuthControllerReadDto])
10
+ async def authorize(data: AuthControllerWriteDto):
11
+ return AuthService.authorize(data=data)
@@ -1,8 +1,8 @@
1
1
  from fastapi import APIRouter
2
- from src.entities.shared.shared_response import Respons
3
- from src.configs.settings import db_settings
4
- from src.configs.database import DatabaseManager
5
- from src.configs.logging import get_logger
2
+ from .sh_response import Respons
3
+ from ..configs.settings import db_settings
4
+ from ..configs.database import DatabaseManager
5
+ from ..configs.logging import get_logger
6
6
 
7
7
  health_check_router = APIRouter(tags=["Health Path"])
8
8
  logger = get_logger("health")
@@ -0,0 +1,14 @@
1
+ """
2
+ TroveSuite Notification Service
3
+
4
+ Provides email and SMS notification capabilities for TroveSuite applications.
5
+ """
6
+
7
+ from .notification_service import NotificationService
8
+ from .notification_write_dto import NotificationEmailServiceWriteDto, NotificationSMSServiceWriteDto
9
+
10
+ __all__ = [
11
+ "NotificationService",
12
+ "NotificationEmailServiceWriteDto",
13
+ "NotificationSMSServiceWriteDto"
14
+ ]
@@ -0,0 +1,13 @@
1
+ from typing import List, Optional, Union
2
+ from pydantic import BaseModel
3
+
4
+ class NotificationEmailBase(BaseModel):
5
+ sender_email: str
6
+ receiver_email: Union[str, List[str]]
7
+ password: str
8
+ subject: str
9
+ text_message: str
10
+ html_message: Optional[str] = None
11
+
12
+ class NotificationSMSBase(BaseModel):
13
+ pass
@@ -0,0 +1,21 @@
1
+ from .notification_write_dto import (
2
+ NotificationEmailControllerWriteDto,
3
+ NotificationSMSControllerWriteDto
4
+ )
5
+ from .notification_read_dto import (
6
+ NotificationEmailControllerReadDto,
7
+ NotificationSMSControllerReadDto
8
+ )
9
+ from .notification_service import NotificationService
10
+ from ..entities.sh_response import Respons
11
+ from fastapi import APIRouter
12
+
13
+ notification_router = APIRouter()
14
+
15
+ @notification_router.post("/send_email", response_model=Respons[NotificationEmailControllerReadDto])
16
+ async def send_email(data: NotificationEmailControllerWriteDto):
17
+ return NotificationService.send_email(data=data)
18
+
19
+ @notification_router.post("/send_sms", response_model=Respons[NotificationSMSControllerReadDto])
20
+ async def send_sms(data: NotificationSMSControllerWriteDto):
21
+ return NotificationService.send_sms(data=data)
@@ -0,0 +1,21 @@
1
+ from .notification_base import (
2
+ NotificationEmailBase,
3
+ NotificationSMSBase
4
+ )
5
+ from pydantic import BaseModel
6
+
7
+ # EMAIL Notification
8
+
9
+ class NotificationEmailControllerReadDto(NotificationEmailBase):
10
+ pass
11
+
12
+ class NotificationEmailServiceReadDto(BaseModel):
13
+ pass
14
+
15
+ # SMS Notification
16
+
17
+ class NotificationSMSControllerReadDto(NotificationSMSBase):
18
+ pass
19
+
20
+ class NotificationSMSServiceReadDto(BaseModel):
21
+ pass
@@ -0,0 +1,73 @@
1
+ import smtplib
2
+ from email.mime.text import MIMEText
3
+ from email.mime.multipart import MIMEMultipart
4
+ from ..entities.sh_response import Respons
5
+ from .notification_read_dto import (
6
+ NotificationEmailServiceReadDto,
7
+ NotificationSMSServiceReadDto
8
+ )
9
+ from .notification_write_dto import (
10
+ NotificationEmailServiceWriteDto,
11
+ NotificationSMSServiceWriteDto
12
+ )
13
+
14
+ class NotificationService:
15
+
16
+ @staticmethod
17
+ def send_email(data: NotificationEmailServiceWriteDto) -> Respons[NotificationEmailServiceReadDto]:
18
+ """
19
+ Send an email (single or multiple recipients) via Gmail SMTP.
20
+ Supports both plain text and HTML email bodies.
21
+ """
22
+
23
+ # Extract input data
24
+ receiver_email = data.receiver_email
25
+ text_message = data.text_message
26
+ html_message = getattr(data, "html_message", None)
27
+ sender_email = data.sender_email
28
+ password = data.password
29
+ subject = data.subject
30
+
31
+ # Allow single email or list
32
+ if isinstance(receiver_email, str):
33
+ receiver_email = [receiver_email]
34
+
35
+ # Create the email container
36
+ message = MIMEMultipart("alternative")
37
+ message["From"] = sender_email
38
+ message["To"] = ", ".join(receiver_email)
39
+ message["Subject"] = subject
40
+
41
+ # Attach plain text
42
+ message.attach(MIMEText(text_message, "plain"))
43
+
44
+ # Attach HTML if provided
45
+ if html_message:
46
+ message.attach(MIMEText(html_message, "html"))
47
+
48
+ try:
49
+ with smtplib.SMTP_SSL("smtp.gmail.com", 465) as server:
50
+ server.login(sender_email, password)
51
+ server.sendmail(sender_email, receiver_email, message.as_string())
52
+
53
+ return Respons[NotificationEmailServiceReadDto](
54
+ detail=f"Email successfully sent to {len(receiver_email)} recipient(s)",
55
+ error=None,
56
+ data=[],
57
+ status_code=200,
58
+ success=True,
59
+ )
60
+
61
+ except Exception as e:
62
+ print(e)
63
+ return Respons[NotificationEmailServiceReadDto](
64
+ detail="An error occurred while sending the email",
65
+ error=str(e),
66
+ data=[],
67
+ status_code=500,
68
+ success=False,
69
+ )
70
+
71
+ @staticmethod
72
+ def send_sms(data: NotificationSMSServiceWriteDto) -> Respons[NotificationSMSServiceReadDto]:
73
+ pass
@@ -0,0 +1,21 @@
1
+ from pydantic import BaseModel
2
+ from .notification_base import (
3
+ NotificationEmailBase,
4
+ NotificationSMSBase
5
+ )
6
+
7
+ # Email Notification
8
+
9
+ class NotificationEmailControllerWriteDto(NotificationEmailBase):
10
+ pass
11
+
12
+ class NotificationEmailServiceWriteDto(NotificationEmailControllerWriteDto):
13
+ pass
14
+
15
+ # SMS Notification
16
+
17
+ class NotificationSMSControllerWriteDto(NotificationSMSBase):
18
+ pass
19
+
20
+ class NotificationSMSServiceWriteDto(BaseModel):
21
+ pass
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: trovesuite
3
- Version: 1.0.4
3
+ Version: 1.0.6
4
4
  Summary: TroveSuite services package providing authentication, authorization, notifications, and other enterprise services for TroveSuite applications
5
5
  Home-page: https://dev.azure.com/brightgclt/trovesuite/_git/packages
6
6
  Author: Bright Debrah Owusu
@@ -119,10 +119,28 @@ poetry install --with dev
119
119
 
120
120
  ## Quick Start
121
121
 
122
+ > **✅ Package Status**: All import issues have been resolved in version 1.0.5. The package now works correctly when installed from PyPI or wheel files.
123
+
124
+ ### Import Patterns
125
+
126
+ The package provides clean, simplified import patterns:
127
+
128
+ ```python
129
+ # Import services and DTOs from main package
130
+ from trovesuite import AuthService, NotificationService
131
+ from trovesuite.auth import AuthServiceWriteDto
132
+ from trovesuite.notification import NotificationEmailServiceWriteDto, NotificationSMSServiceWriteDto
133
+
134
+ # Or import everything you need in one line
135
+ from trovesuite import AuthService, NotificationService
136
+ from trovesuite.auth import AuthServiceWriteDto
137
+ from trovesuite.notification import NotificationEmailServiceWriteDto
138
+ ```
139
+
122
140
  ### Basic Usage
123
141
 
124
142
  ```python
125
- from trovesuite import AuthService
143
+ from trovesuite import AuthService, NotificationService
126
144
  from trovesuite.configs.settings import db_settings
127
145
 
128
146
  # Configure your database settings
@@ -137,7 +155,7 @@ db_settings.SECRET_KEY = "your-secret-key"
137
155
  auth_service = AuthService()
138
156
 
139
157
  # Authorize a user
140
- from trovesuite.auth.auth_write_dto import AuthServiceWriteDto
158
+ from trovesuite.auth import AuthServiceWriteDto
141
159
  auth_data = AuthServiceWriteDto(user_id="user123", tenant="tenant456")
142
160
  result = AuthService.authorize(auth_data)
143
161
 
@@ -149,6 +167,30 @@ else:
149
167
  print(f"Authorization failed: {result.detail}")
150
168
  ```
151
169
 
170
+ ### Notification Service Usage
171
+
172
+ ```python
173
+ from trovesuite import NotificationService
174
+ from trovesuite.notification import NotificationEmailServiceWriteDto
175
+
176
+ # Send an email notification
177
+ email_data = NotificationEmailServiceWriteDto(
178
+ sender_email="your-email@gmail.com",
179
+ receiver_email=["recipient1@example.com", "recipient2@example.com"],
180
+ password="your-app-password", # Gmail app password
181
+ subject="Test Notification",
182
+ text_message="This is a plain text message",
183
+ html_message="<h1>This is an HTML message</h1><p>With rich formatting!</p>"
184
+ )
185
+
186
+ result = NotificationService.send_email(email_data)
187
+
188
+ if result.success:
189
+ print(f"Email sent successfully: {result.detail}")
190
+ else:
191
+ print(f"Email failed: {result.error}")
192
+ ```
193
+
152
194
  ### JWT Token Decoding
153
195
 
154
196
  ```python
@@ -166,7 +208,7 @@ async def protected_route(token: str = Depends(oauth2_scheme)):
166
208
  tenant_id = user_data["tenant_id"]
167
209
 
168
210
  # Authorize user
169
- from trovesuite.auth.auth_write_dto import AuthServiceWriteDto
211
+ from trovesuite.auth import AuthServiceWriteDto
170
212
  auth_data = AuthServiceWriteDto(user_id=user_id, tenant=tenant_id)
171
213
  auth_result = AuthService.authorize(auth_data)
172
214
  return auth_result
@@ -395,8 +437,84 @@ Check if user has all of the required permissions.
395
437
  **Returns:**
396
438
  - `bool`: True if user has all of the required permissions
397
439
 
440
+ ### NotificationService
441
+
442
+ #### `send_email(data: NotificationEmailServiceWriteDto) -> Respons[NotificationEmailServiceReadDto]`
443
+
444
+ Sends an email notification via Gmail SMTP. Supports both plain text and HTML email bodies.
445
+
446
+ **Parameters:**
447
+ - `data`: Email notification data including sender, recipients, subject, and message content
448
+
449
+ **Returns:**
450
+ - `Respons[NotificationEmailServiceReadDto]`: Email sending result with success status and details
451
+
452
+ **Example:**
453
+ ```python
454
+ from trovesuite import NotificationService
455
+ from trovesuite.notification import NotificationEmailServiceWriteDto
456
+
457
+ email_data = NotificationEmailServiceWriteDto(
458
+ sender_email="sender@gmail.com",
459
+ receiver_email=["user1@example.com", "user2@example.com"],
460
+ password="your-gmail-app-password",
461
+ subject="Welcome to TroveSuite",
462
+ text_message="Welcome! This is a plain text message.",
463
+ html_message="<h1>Welcome!</h1><p>This is an <strong>HTML</strong> message.</p>"
464
+ )
465
+
466
+ result = NotificationService.send_email(email_data)
467
+ if result.success:
468
+ print("Email sent successfully!")
469
+ else:
470
+ print(f"Failed to send email: {result.error}")
471
+ ```
472
+
473
+ #### `send_sms(data: NotificationSMSServiceWriteDto) -> Respons[NotificationSMSServiceReadDto]`
474
+
475
+ Sends an SMS notification (currently not implemented).
476
+
477
+ **Parameters:**
478
+ - `data`: SMS notification data
479
+
480
+ **Returns:**
481
+ - `Respons[NotificationSMSServiceReadDto]`: SMS sending result
482
+
398
483
  ### Data Models
399
484
 
485
+ #### `NotificationEmailServiceWriteDto`
486
+
487
+ ```python
488
+ class NotificationEmailServiceWriteDto(BaseModel):
489
+ sender_email: str
490
+ receiver_email: Union[str, List[str]] # Single email or list of emails
491
+ password: str # Gmail app password
492
+ subject: str
493
+ text_message: str
494
+ html_message: Optional[str] = None # Optional HTML content
495
+ ```
496
+
497
+ #### `NotificationEmailServiceReadDto`
498
+
499
+ ```python
500
+ class NotificationEmailServiceReadDto(BaseModel):
501
+ pass # Empty response model for email service
502
+ ```
503
+
504
+ #### `NotificationSMSServiceWriteDto`
505
+
506
+ ```python
507
+ class NotificationSMSServiceWriteDto(BaseModel):
508
+ pass # To be implemented for SMS functionality
509
+ ```
510
+
511
+ #### `NotificationSMSServiceReadDto`
512
+
513
+ ```python
514
+ class NotificationSMSServiceReadDto(BaseModel):
515
+ pass # To be implemented for SMS functionality
516
+ ```
517
+
400
518
  #### `AuthServiceReadDto`
401
519
 
402
520
  ```python
@@ -557,15 +675,65 @@ poetry install
557
675
 
558
676
  This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
559
677
 
678
+ ## Troubleshooting
679
+
680
+ ### Import Issues
681
+
682
+ If you encounter import errors, make sure you're using the correct import patterns:
683
+
684
+ ```python
685
+ # ✅ Correct imports
686
+ from trovesuite import AuthService, NotificationService
687
+ from trovesuite.auth import AuthServiceWriteDto
688
+ from trovesuite.notification import NotificationEmailServiceWriteDto
689
+
690
+ # ❌ Incorrect imports (will fail)
691
+ from trovesuite.auth.auth_write_dto import AuthServiceWriteDto # Too specific
692
+ from trovesuite.notification.notification_write_dto import NotificationEmailServiceWriteDto # Too specific
693
+ ```
694
+
695
+ ### Package Installation
696
+
697
+ If you're having issues with the package installation:
698
+
699
+ 1. **Make sure you have the latest version**:
700
+ ```bash
701
+ pip install --upgrade trovesuite
702
+ ```
703
+
704
+ 2. **Force reinstall if needed**:
705
+ ```bash
706
+ pip install --force-reinstall trovesuite
707
+ ```
708
+
709
+ 3. **Check your Python environment**:
710
+ ```bash
711
+ python -c "import trovesuite; print('Package installed successfully')"
712
+ ```
713
+
714
+ ### Common Issues
715
+
716
+ - **ImportError: No module named 'src'**: This was fixed in version 1.0.5. Update to the latest version.
717
+ - **AttributeError: module has no attribute 'AuthServiceWriteDto'**: Use `from trovesuite.auth import AuthServiceWriteDto` instead of importing from the main package.
718
+
560
719
  ## Support
561
720
 
562
721
  For support, email brightgclt@gmail.com or create a work item in the [Azure DevOps repository](https://dev.azure.com/brightgclt/trovesuite/_workitems/create).
563
722
 
564
723
  ## Changelog
565
724
 
725
+ ### 1.0.5
726
+ - Fixed all import issues across auth, notification, and entities modules
727
+ - Changed absolute imports (`from src.trovesuite.`) to relative imports (`from .` and `from ..`)
728
+ - Ensured package works correctly when installed from PyPI or wheel
729
+ - Added service write DTOs to module exports for easier usage
730
+ - Updated documentation with simplified import patterns
731
+ - All services and DTOs now import correctly in clean environments
732
+ - Package builds and installs without import errors
733
+
566
734
  ### 1.0.8
567
735
  - Restructured package for direct service imports
568
- - Added notification services
736
+ - Added comprehensive notification services with email support
569
737
  - Excluded controllers from package build
570
738
  - Updated import paths for better usability
571
739
  - JWT token validation
@@ -574,3 +742,6 @@ For support, email brightgclt@gmail.com or create a work item in the [Azure DevO
574
742
  - PostgreSQL database integration
575
743
  - Comprehensive logging
576
744
  - Azure integration support
745
+ - Email notification service with Gmail SMTP support
746
+ - Support for both plain text and HTML email content
747
+ - Multiple recipient support for email notifications
@@ -24,5 +24,11 @@ src/trovesuite/configs/settings.py
24
24
  src/trovesuite/entities/__init__.py
25
25
  src/trovesuite/entities/health.py
26
26
  src/trovesuite/entities/sh_response.py
27
+ src/trovesuite/notification/__init__.py
28
+ src/trovesuite/notification/notification_base.py
29
+ src/trovesuite/notification/notification_controller.py
30
+ src/trovesuite/notification/notification_read_dto.py
31
+ src/trovesuite/notification/notification_service.py
32
+ src/trovesuite/notification/notification_write_dto.py
27
33
  src/trovesuite/utils/__init__.py
28
34
  src/trovesuite/utils/helper.py
@@ -1,16 +0,0 @@
1
- """
2
- TroveSuite Auth Package
3
-
4
- A comprehensive authentication and authorization service for ERP systems.
5
- Provides JWT token validation, user authorization, and permission checking.
6
- """
7
-
8
- from .auth import AuthService
9
-
10
- __version__ = "1.0.8"
11
- __author__ = "Bright Debrah Owusu"
12
- __email__ = "owusu.debrah@deladetech.com"
13
-
14
- __all__ = [
15
- "AuthService"
16
- ]
@@ -1,17 +0,0 @@
1
- """
2
- TroveSuite Auth Module
3
-
4
- Authentication and authorization services for ERP systems.
5
- """
6
-
7
- from .auth_service import AuthService
8
- from .auth_base import AuthBase
9
- from .auth_read_dto import AuthServiceReadDto, AuthControllerReadDto
10
-
11
- __all__ = [
12
- "AuthService",
13
- "AuthBase",
14
- "AuthServiceReadDto",
15
- "AuthControllerReadDto"
16
- ]
17
-
@@ -1,11 +0,0 @@
1
- from fastapi import APIRouter
2
- from src.trovesuite.auth.auth_write_dto import AuthControllerWriteDto
3
- from src.trovesuite.auth.auth_read_dto import AuthControllerReadDto
4
- from src.trovesuite.auth.auth_service import AuthService
5
- from src.trovesuite.entities.sh_response import Respons
6
-
7
- auth_router = APIRouter()
8
-
9
- @auth_router.post("/auth", response_model=Respons[AuthControllerReadDto])
10
- async def authorize(data: AuthControllerWriteDto):
11
- return AuthService.authorize(data=data)
File without changes
File without changes
File without changes
File without changes