@realtimex/email-automator 2.8.0 → 2.8.2
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.
- package/api/src/services/eventLogger.ts +4 -0
- package/api/src/services/processor.ts +11 -2
- package/dist/api/src/services/eventLogger.js +3 -0
- package/dist/api/src/services/processor.js +10 -2
- package/dist/assets/{index-G4P4tnAm.js → index-B8JaOAxd.js} +25 -25
- package/dist/assets/{index-BAFmzMNU.css → index-BXVbfEhG.css} +1 -1
- package/dist/index.html +2 -2
- package/package.json +1 -1
- package/vite.config.ts +4 -0
|
@@ -46,6 +46,10 @@ export class EventLogger {
|
|
|
46
46
|
await this.log('action', state, { action, reason }, emailId);
|
|
47
47
|
}
|
|
48
48
|
|
|
49
|
+
async success(state: string, message: string, details?: any) {
|
|
50
|
+
await this.log('info', state, { message, ...details, is_completion: true });
|
|
51
|
+
}
|
|
52
|
+
|
|
49
53
|
async error(state: string, errorOrDetails: any, emailId?: string) {
|
|
50
54
|
let details;
|
|
51
55
|
if (errorOrDetails instanceof Error) {
|
|
@@ -103,13 +103,22 @@ export class EmailProcessorService {
|
|
|
103
103
|
// After processing new emails, run retention rules for this account
|
|
104
104
|
await this.runRetentionRules(refreshedAccount, rules || [], settings, result, eventLogger);
|
|
105
105
|
|
|
106
|
-
//
|
|
107
|
-
this.processQueue(userId, settings).catch(err =>
|
|
106
|
+
// Wait for background worker to process the queue (ensure sync is fully complete before event)
|
|
107
|
+
await this.processQueue(userId, settings).catch(err =>
|
|
108
108
|
logger.error('Background worker failed', err)
|
|
109
109
|
);
|
|
110
110
|
|
|
111
111
|
// Update log and account on success
|
|
112
112
|
if (log) {
|
|
113
|
+
if (eventLogger) {
|
|
114
|
+
await eventLogger.success('Finished', 'Sync run completed', {
|
|
115
|
+
total_processed: result.processed,
|
|
116
|
+
deleted: result.deleted,
|
|
117
|
+
drafted: result.drafted,
|
|
118
|
+
errors: result.errors
|
|
119
|
+
});
|
|
120
|
+
}
|
|
121
|
+
|
|
113
122
|
await this.supabase
|
|
114
123
|
.from('processing_logs')
|
|
115
124
|
.update({
|
|
@@ -35,6 +35,9 @@ export class EventLogger {
|
|
|
35
35
|
async action(state, emailId, action, reason) {
|
|
36
36
|
await this.log('action', state, { action, reason }, emailId);
|
|
37
37
|
}
|
|
38
|
+
async success(state, message, details) {
|
|
39
|
+
await this.log('info', state, { message, ...details, is_completion: true });
|
|
40
|
+
}
|
|
38
41
|
async error(state, errorOrDetails, emailId) {
|
|
39
42
|
let details;
|
|
40
43
|
if (errorOrDetails instanceof Error) {
|
|
@@ -80,10 +80,18 @@ export class EmailProcessorService {
|
|
|
80
80
|
}
|
|
81
81
|
// After processing new emails, run retention rules for this account
|
|
82
82
|
await this.runRetentionRules(refreshedAccount, rules || [], settings, result, eventLogger);
|
|
83
|
-
//
|
|
84
|
-
this.processQueue(userId, settings).catch(err => logger.error('Background worker failed', err));
|
|
83
|
+
// Wait for background worker to process the queue (ensure sync is fully complete before event)
|
|
84
|
+
await this.processQueue(userId, settings).catch(err => logger.error('Background worker failed', err));
|
|
85
85
|
// Update log and account on success
|
|
86
86
|
if (log) {
|
|
87
|
+
if (eventLogger) {
|
|
88
|
+
await eventLogger.success('Finished', 'Sync run completed', {
|
|
89
|
+
total_processed: result.processed,
|
|
90
|
+
deleted: result.deleted,
|
|
91
|
+
drafted: result.drafted,
|
|
92
|
+
errors: result.errors
|
|
93
|
+
});
|
|
94
|
+
}
|
|
87
95
|
await this.supabase
|
|
88
96
|
.from('processing_logs')
|
|
89
97
|
.update({
|