domain.events.data_events¶
src.domain.events.data_events
¶
Data synchronization domain events (F7.7 Phase 2).
Pattern: 3 events per workflow (ATTEMPTED → SUCCEEDED/FAILED) - *Attempted: User initiated sync (before business logic) - *Succeeded: Operation completed successfully (after business commit) - *Failed: Operation failed (after business rollback)
Handlers: - LoggingEventHandler: ALL 3 events - AuditEventHandler: ALL 3 events
Workflows: 1. Account Sync: Sync account data from provider 2. Transaction Sync: Sync transaction data from provider 3. Holdings Sync: Sync holdings (positions) from provider 4. File Import: Import data from uploaded file
Classes¶
AccountSyncAttempted
dataclass
¶
Bases: DomainEvent
Account sync attempt initiated.
Triggers: - LoggingEventHandler: Log attempt - AuditEventHandler: Record ACCOUNT_SYNC_ATTEMPTED
Attributes:
| Name | Type | Description |
|---|---|---|
connection_id |
UUID
|
Provider connection being synced. |
user_id |
UUID
|
User initiating sync. |
Source code in src/domain/events/data_events.py
AccountSyncSucceeded
dataclass
¶
Bases: DomainEvent
Account sync completed successfully.
Triggers: - LoggingEventHandler: Log success - AuditEventHandler: Record ACCOUNT_SYNC_SUCCEEDED
Attributes:
| Name | Type | Description |
|---|---|---|
connection_id |
UUID
|
Provider connection synced. |
user_id |
UUID
|
User who initiated sync. |
account_count |
int
|
Number of accounts synced. |
Source code in src/domain/events/data_events.py
AccountSyncFailed
dataclass
¶
Bases: DomainEvent
Account sync failed.
Triggers: - LoggingEventHandler: Log failure - AuditEventHandler: Record ACCOUNT_SYNC_FAILED
Attributes:
| Name | Type | Description |
|---|---|---|
connection_id |
UUID
|
Provider connection attempted. |
user_id |
UUID
|
User who initiated sync. |
reason |
str
|
Failure reason (e.g., "connection_not_found", "provider_error", "authentication_failed"). |
Source code in src/domain/events/data_events.py
TransactionSyncAttempted
dataclass
¶
Bases: DomainEvent
Transaction sync attempt initiated.
Triggers: - LoggingEventHandler: Log attempt - AuditEventHandler: Record TRANSACTION_SYNC_ATTEMPTED
Attributes:
| Name | Type | Description |
|---|---|---|
connection_id |
UUID
|
Provider connection being synced. |
user_id |
UUID
|
User initiating sync. |
account_id |
UUID | None
|
Specific account if targeted sync (optional). |
Source code in src/domain/events/data_events.py
TransactionSyncSucceeded
dataclass
¶
Bases: DomainEvent
Transaction sync completed successfully.
Triggers: - LoggingEventHandler: Log success - AuditEventHandler: Record TRANSACTION_SYNC_SUCCEEDED
Attributes:
| Name | Type | Description |
|---|---|---|
connection_id |
UUID
|
Provider connection synced. |
user_id |
UUID
|
User who initiated sync. |
account_id |
UUID | None
|
Specific account if targeted sync (optional). |
transaction_count |
int
|
Number of transactions synced. |
Source code in src/domain/events/data_events.py
TransactionSyncFailed
dataclass
¶
Bases: DomainEvent
Transaction sync failed.
Triggers: - LoggingEventHandler: Log failure - AuditEventHandler: Record TRANSACTION_SYNC_FAILED
Attributes:
| Name | Type | Description |
|---|---|---|
connection_id |
UUID
|
Provider connection attempted. |
user_id |
UUID
|
User who initiated sync. |
account_id |
UUID | None
|
Specific account if targeted sync (optional). |
reason |
str
|
Failure reason (e.g., "connection_not_found", "provider_error", "date_range_invalid"). |
Source code in src/domain/events/data_events.py
HoldingsSyncAttempted
dataclass
¶
Bases: DomainEvent
Holdings sync attempt initiated.
Triggers: - LoggingEventHandler: Log attempt - AuditEventHandler: Record HOLDINGS_SYNC_ATTEMPTED
Attributes:
| Name | Type | Description |
|---|---|---|
account_id |
UUID
|
Account being synced. |
user_id |
UUID
|
User initiating sync. |
Source code in src/domain/events/data_events.py
HoldingsSyncSucceeded
dataclass
¶
Bases: DomainEvent
Holdings sync completed successfully.
Triggers: - LoggingEventHandler: Log success - AuditEventHandler: Record HOLDINGS_SYNC_SUCCEEDED
Attributes:
| Name | Type | Description |
|---|---|---|
account_id |
UUID
|
Account synced. |
user_id |
UUID
|
User who initiated sync. |
holding_count |
int
|
Number of holdings synced. |
Source code in src/domain/events/data_events.py
HoldingsSyncFailed
dataclass
¶
Bases: DomainEvent
Holdings sync failed.
Triggers: - LoggingEventHandler: Log failure - AuditEventHandler: Record HOLDINGS_SYNC_FAILED
Attributes:
| Name | Type | Description |
|---|---|---|
account_id |
UUID
|
Account attempted. |
user_id |
UUID
|
User who initiated sync. |
reason |
str
|
Failure reason (e.g., "account_not_found", "provider_error", "holdings_not_supported"). |
Source code in src/domain/events/data_events.py
FileImportAttempted
dataclass
¶
Bases: DomainEvent
File import attempt initiated.
Triggers: - LoggingEventHandler: Log attempt - AuditEventHandler: Record FILE_IMPORT_ATTEMPTED
Attributes:
| Name | Type | Description |
|---|---|---|
user_id |
UUID
|
User importing file. |
provider_slug |
str
|
Provider identifier (e.g., "chase_file"). |
file_name |
str
|
Original filename. |
file_format |
str
|
File format (e.g., "qfx", "ofx", "csv"). |
Source code in src/domain/events/data_events.py
FileImportSucceeded
dataclass
¶
Bases: DomainEvent
File import completed successfully.
Triggers: - LoggingEventHandler: Log success - AuditEventHandler: Record FILE_IMPORT_SUCCEEDED
Attributes:
| Name | Type | Description |
|---|---|---|
user_id |
UUID
|
User who imported file. |
provider_slug |
str
|
Provider identifier. |
file_name |
str
|
Original filename. |
file_format |
str
|
File format. |
account_count |
int
|
Number of accounts created/updated. |
transaction_count |
int
|
Number of transactions imported. |
Source code in src/domain/events/data_events.py
FileImportFailed
dataclass
¶
Bases: DomainEvent
File import failed.
Triggers: - LoggingEventHandler: Log failure - AuditEventHandler: Record FILE_IMPORT_FAILED
Attributes:
| Name | Type | Description |
|---|---|---|
user_id |
UUID
|
User who attempted import. |
provider_slug |
str
|
Provider identifier. |
file_name |
str
|
Original filename. |
file_format |
str
|
File format. |
reason |
str
|
Failure reason (e.g., "parse_error", "unsupported_format", "invalid_file_structure"). |
Source code in src/domain/events/data_events.py
FileImportProgress
dataclass
¶
Bases: DomainEvent
File import progress update (emitted periodically during import).
This is an OPERATIONAL event, not part of the 3-state workflow. Used for real-time progress updates via SSE.
Triggers: - LoggingEventHandler: Log progress (DEBUG level) - SSEEventHandler: Broadcast via SSE
Attributes:
| Name | Type | Description |
|---|---|---|
user_id |
UUID
|
User importing file. |
provider_slug |
str
|
Provider identifier. |
file_name |
str
|
Original filename. |
file_format |
str
|
File format. |
progress_percent |
int
|
Progress percentage (0-100). |
records_processed |
int
|
Number of records processed so far. |
total_records |
int
|
Total records to process (may be estimate). |