powr-sdk-api 4.3.0 → 4.3.1
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/dist/managers/tasks.js +11 -11
- package/package.json +1 -1
package/dist/managers/tasks.js
CHANGED
|
@@ -91,7 +91,7 @@ class ScheduledTasksManager {
|
|
|
91
91
|
|
|
92
92
|
// Build query based on user role
|
|
93
93
|
let query = {
|
|
94
|
-
|
|
94
|
+
_id: taskId
|
|
95
95
|
};
|
|
96
96
|
if (isAdmin) {
|
|
97
97
|
// Admin can access any task in the project
|
|
@@ -128,7 +128,7 @@ class ScheduledTasksManager {
|
|
|
128
128
|
|
|
129
129
|
// Build query based on user role
|
|
130
130
|
let query = {
|
|
131
|
-
|
|
131
|
+
_id: taskId
|
|
132
132
|
};
|
|
133
133
|
if (isAdmin) {
|
|
134
134
|
// Admin can update any task in the project
|
|
@@ -180,7 +180,7 @@ class ScheduledTasksManager {
|
|
|
180
180
|
|
|
181
181
|
// Build query based on user role
|
|
182
182
|
let query = {
|
|
183
|
-
|
|
183
|
+
_id: taskId
|
|
184
184
|
};
|
|
185
185
|
if (isAdmin) {
|
|
186
186
|
// Admin can delete any task in the project
|
|
@@ -225,7 +225,7 @@ class ScheduledTasksManager {
|
|
|
225
225
|
|
|
226
226
|
// Build query based on user role
|
|
227
227
|
let query = {
|
|
228
|
-
|
|
228
|
+
_id: taskId
|
|
229
229
|
};
|
|
230
230
|
if (isAdmin) {
|
|
231
231
|
// Admin can toggle any task in the project
|
|
@@ -271,7 +271,7 @@ class ScheduledTasksManager {
|
|
|
271
271
|
|
|
272
272
|
// Build query based on user role
|
|
273
273
|
let query = {
|
|
274
|
-
|
|
274
|
+
_id: taskId
|
|
275
275
|
};
|
|
276
276
|
if (isAdmin) {
|
|
277
277
|
// Admin can execute any task in the project
|
|
@@ -319,7 +319,7 @@ class ScheduledTasksManager {
|
|
|
319
319
|
const tasks = await db.collection("tasks").find(query).toArray();
|
|
320
320
|
for (const task of tasks) {
|
|
321
321
|
try {
|
|
322
|
-
console.log(`⏰ Executing: ${task.name} (${task.
|
|
322
|
+
console.log(`⏰ Executing: ${task.name} (${task._id}) for project ${task.projectId}`);
|
|
323
323
|
|
|
324
324
|
// Execute the task directly (we already have the task data)
|
|
325
325
|
const result = await this.executeTaskAction(task);
|
|
@@ -329,20 +329,20 @@ class ScheduledTasksManager {
|
|
|
329
329
|
if (!task.scheduledFor || this.isTimestamp(task.scheduledFor)) {
|
|
330
330
|
// For immediate and one-time tasks, deactivate after execution
|
|
331
331
|
updateData.isActive = false;
|
|
332
|
-
console.log(`✅ Task ${task.
|
|
332
|
+
console.log(`✅ Task ${task._id} completed and deactivated`);
|
|
333
333
|
} else if (this.isCronExpression(task.scheduledFor)) {
|
|
334
334
|
// For recurring tasks, calculate next run time
|
|
335
335
|
updateData.nextRun = this.getNextRunTime(task.scheduledFor);
|
|
336
|
-
console.log(`📅 Updated next run time for task ${task.
|
|
336
|
+
console.log(`📅 Updated next run time for task ${task._id}: ${updateData.nextRun}`);
|
|
337
337
|
}
|
|
338
338
|
await db.collection("tasks").updateOne({
|
|
339
|
-
|
|
339
|
+
_id: task._id
|
|
340
340
|
}, {
|
|
341
341
|
$set: updateData
|
|
342
342
|
});
|
|
343
|
-
console.log(`✅ Task ${task.
|
|
343
|
+
console.log(`✅ Task ${task._id} completed:`, result.success ? 'SUCCESS' : 'FAILED');
|
|
344
344
|
} catch (error) {
|
|
345
|
-
console.error(`❌ Task ${task.
|
|
345
|
+
console.error(`❌ Task ${task._id} failed:`, error.message);
|
|
346
346
|
}
|
|
347
347
|
}
|
|
348
348
|
return {
|