powr-sdk-api 4.3.3 → 4.3.5

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.
@@ -2,10 +2,31 @@
2
2
 
3
3
  const functionsManager = require('./functions');
4
4
  const toolsManager = require('./tools');
5
- const tasksManager = require('./tasks');
5
+ const scheduledTasksManager = require('./tasks');
6
+
7
+ // Async Functions initialization function
8
+ const initializeFunctions = async (options = {}) => {
9
+ // Initialize Functions manager with options
10
+ await functionsManager.initialize(options);
11
+ };
12
+
13
+ // Async Tools initialization function
14
+ const initializeTools = async (options = {}) => {
15
+ // Initialize Tools manager with options
16
+ await toolsManager.initialize(options);
17
+ };
18
+ const executeTool = async (options = {}) => {
19
+ // Execute tool action
20
+ return await toolsManager.executeToolAction(options);
21
+ };
22
+ const executeTasks = async (options = {}) => {
23
+ // Execute scheduled tasks
24
+ await scheduledTasksManager.executeScheduledTasks(options);
25
+ };
6
26
  module.exports = {
7
- initializeFunctions: functionsManager.initialize,
8
- initializeTools: toolsManager.initialize,
9
- executeTasks: tasksManager.executeScheduledTasks,
10
- executeTool: toolsManager.executeToolAction
27
+ // Initialization/Execution methods
28
+ initializeFunctions,
29
+ initializeTools,
30
+ executeTasks,
31
+ executeTool
11
32
  };
@@ -309,7 +309,10 @@ class TasksManager {
309
309
  }
310
310
 
311
311
  // Execute scheduled tasks (called by MongoDB Atlas Scheduled Trigger)
312
- async executeScheduledTasks(projectId) {
312
+ async executeScheduledTasks(options = {}) {
313
+ const {
314
+ projectId
315
+ } = options;
313
316
  try {
314
317
  const db = await getDb();
315
318
  const query = {
@@ -366,12 +369,10 @@ class TasksManager {
366
369
  async executeTaskAction(task) {
367
370
  try {
368
371
  // Import tools manager
369
- const {
370
- toolsManager
371
- } = require('./index');
372
+ const toolsManager = require('./tools');
372
373
 
373
374
  // Execute the tool action
374
- const result = await toolsManager.executeToolAction(task.userId, task.toolId, task.actionId, task.params);
375
+ const result = await toolsManager.executeToolAction(task);
375
376
 
376
377
  // Log execution
377
378
  await this.logTaskExecution(task, result);
@@ -150,7 +150,13 @@ class ToolsManager {
150
150
  }
151
151
 
152
152
  // Execute tool action
153
- async executeToolAction(userId, toolId, actionId, params) {
153
+ async executeToolAction(options = {}) {
154
+ const {
155
+ userId,
156
+ toolId,
157
+ actionId,
158
+ params
159
+ } = options;
154
160
  if (!this.isEnabled) {
155
161
  return {
156
162
  success: false,
@@ -282,7 +282,9 @@ router.post("/execute-scheduled", async (req, res) => {
282
282
  console.log(`🔍 API: Executing scheduled tasks for project: ${projectId}`);
283
283
 
284
284
  // Execute all scheduled tasks for this project
285
- const result = await tasksManager.executeScheduledTasks(projectId);
285
+ const result = await tasksManager.executeScheduledTasks({
286
+ projectId
287
+ });
286
288
  console.log(`✅ API: Scheduled tasks execution completed for project: ${projectId}`);
287
289
  res.json({
288
290
  success: true,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "powr-sdk-api",
3
- "version": "4.3.3",
3
+ "version": "4.3.5",
4
4
  "description": "Shared API core library for PowrStack projects",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",