Skip to content

Commit ba457c2

Browse files
task planner added
1 parent d6ba2d2 commit ba457c2

File tree

3 files changed

+32
-3
lines changed

3 files changed

+32
-3
lines changed

src/index.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,11 @@ import cboutputparsers from './modules/outputparsers';
1515
import cbproject from './modules/project';
1616
import git from './modules/git';
1717
import dbmemory from './modules/dbmemory';
18-
import cbstate from './modules/state'
18+
import cbstate from './modules/state';
19+
import task from './modules/task';
1920
import WebSocket from 'ws';
2021

22+
2123
/**
2224
* @class Codebolt
2325
* @description This class provides a unified interface to interact with various modules.
@@ -89,6 +91,7 @@ class Codebolt {
8991
project = cbproject;
9092
dbmemory = dbmemory;
9193
cbstate=cbstate;
94+
taskplaner=task
9295
}
9396

9497
// export default new Codebolt();

src/modules/state.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
import cbws from './websocket';
22

3-
3+
/**
4+
* Retrieves the application state asynchronously.
5+
* @returns {Promise<any>} A promise that resolves with the application state.
6+
*/
47
const cbstate = {
58
getApplicationState: async (): Promise<any> => {
69
return new Promise((resolve, reject) => {
@@ -19,4 +22,3 @@ const cbstate = {
1922
};
2023

2124
export default cbstate;
22-

src/modules/task.ts

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
import cbws from './websocket';
2+
3+
/**
4+
* Fetches the list of tasks asynchronously.
5+
* @returns {Promise<any>} A promise that resolves with the list of tasks.
6+
*/
7+
const taskplaner = {
8+
getTasks: async (): Promise<any> => {
9+
return new Promise((resolve, reject) => {
10+
cbws.getWebsocket.send(JSON.stringify({
11+
"type": "getTasks",
12+
13+
}));
14+
cbws.getWebsocket.on('message', (data: string) => {
15+
const response = JSON.parse(data);
16+
if (response.type === "getTasksResponse") {
17+
resolve(response); // Resolve the Promise with the task data
18+
}
19+
});
20+
});
21+
}
22+
};
23+
24+
export default taskplaner;

0 commit comments

Comments
 (0)