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 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
  };
@@ -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
- // Export manager instances
33
- functionsManager,
34
- toolsManager,
35
- scheduledTasksManager
36
+ createTask
36
37
  };
@@ -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
@@ -2,9 +2,7 @@
2
2
 
3
3
  const express = require("express");
4
4
  const router = express.Router();
5
- const {
6
- functionsManager
7
- } = require("../managers");
5
+ const functionsManager = require("../managers/functions");
8
6
  const {
9
7
  getDb
10
8
  } = require("../services/mongo");
@@ -2,9 +2,7 @@
2
2
 
3
3
  const express = require("express");
4
4
  const router = express.Router();
5
- const {
6
- toolsManager
7
- } = require("../managers");
5
+ const toolsManager = require("../managers/tools");
8
6
  const {
9
7
  getDb
10
8
  } = require("../services/mongo");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "powr-sdk-api",
3
- "version": "4.3.8",
3
+ "version": "4.3.10",
4
4
  "description": "Shared API core library for PowrStack projects",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",