powr-sdk-api 4.3.8 → 4.3.10
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/index.js +4 -2
- package/dist/managers/index.js +5 -4
- package/dist/managers/tasks.js +14 -0
- package/dist/routes/functions.js +1 -3
- package/dist/routes/tools.js +1 -3
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -20,7 +20,8 @@ const {
|
|
|
20
20
|
initializeFunctions,
|
|
21
21
|
initializeTools,
|
|
22
22
|
executeTasks,
|
|
23
|
-
executeTool
|
|
23
|
+
executeTool,
|
|
24
|
+
createTask
|
|
24
25
|
} = require("./managers");
|
|
25
26
|
const {
|
|
26
27
|
verifyToken
|
|
@@ -36,5 +37,6 @@ module.exports = {
|
|
|
36
37
|
initializeTools,
|
|
37
38
|
verifyToken,
|
|
38
39
|
executeTasks,
|
|
39
|
-
executeTool
|
|
40
|
+
executeTool,
|
|
41
|
+
createTask
|
|
40
42
|
};
|
package/dist/managers/index.js
CHANGED
|
@@ -23,14 +23,15 @@ const executeTasks = async (options = {}) => {
|
|
|
23
23
|
// Execute scheduled tasks
|
|
24
24
|
await scheduledTasksManager.executeScheduledTasks(options);
|
|
25
25
|
};
|
|
26
|
+
const createTask = async taskData => {
|
|
27
|
+
// Create a new task/workflow
|
|
28
|
+
return await scheduledTasksManager.createTask(taskData);
|
|
29
|
+
};
|
|
26
30
|
module.exports = {
|
|
27
31
|
// Initialization/Execution methods
|
|
28
32
|
initializeFunctions,
|
|
29
33
|
initializeTools,
|
|
30
34
|
executeTasks,
|
|
31
35
|
executeTool,
|
|
32
|
-
|
|
33
|
-
functionsManager,
|
|
34
|
-
toolsManager,
|
|
35
|
-
scheduledTasksManager
|
|
36
|
+
createTask
|
|
36
37
|
};
|
package/dist/managers/tasks.js
CHANGED
|
@@ -86,6 +86,20 @@ class TasksManager {
|
|
|
86
86
|
const tasks = await db.collection("tasks").find(query).sort({
|
|
87
87
|
createdAt: -1
|
|
88
88
|
}).toArray();
|
|
89
|
+
|
|
90
|
+
// For workflows, get the last execution time
|
|
91
|
+
for (const task of tasks) {
|
|
92
|
+
if (task.type === 'workflow') {
|
|
93
|
+
const lastExecution = await db.collection("workflow_executions").findOne({
|
|
94
|
+
workflowId: task._id
|
|
95
|
+
}, {
|
|
96
|
+
sort: {
|
|
97
|
+
executedAt: -1
|
|
98
|
+
}
|
|
99
|
+
});
|
|
100
|
+
task.lastRun = (lastExecution === null || lastExecution === void 0 ? void 0 : lastExecution.executedAt) || null;
|
|
101
|
+
}
|
|
102
|
+
}
|
|
89
103
|
return {
|
|
90
104
|
success: true,
|
|
91
105
|
tasks
|
package/dist/routes/functions.js
CHANGED
package/dist/routes/tools.js
CHANGED