@codebolt/codeboltjs 1.1.12 → 1.1.14
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/index.js +4 -0
- package/modules/state.d.ts +8 -0
- package/modules/state.js +26 -0
- package/modules/task.d.ts +23 -0
- package/modules/task.js +74 -0
- package/package.json +1 -1
- package/src/index.ts +5 -1
- package/src/modules/state.ts +24 -0
- package/src/modules/task.ts +72 -0
package/index.js
CHANGED
|
@@ -20,6 +20,8 @@ const outputparsers_1 = __importDefault(require("./modules/outputparsers"));
|
|
|
20
20
|
const project_1 = __importDefault(require("./modules/project"));
|
|
21
21
|
const git_1 = __importDefault(require("./modules/git"));
|
|
22
22
|
const dbmemory_1 = __importDefault(require("./modules/dbmemory"));
|
|
23
|
+
const state_1 = __importDefault(require("./modules/state"));
|
|
24
|
+
const task_1 = __importDefault(require("./modules/task"));
|
|
23
25
|
const ws_1 = __importDefault(require("ws"));
|
|
24
26
|
/**
|
|
25
27
|
* @class Codebolt
|
|
@@ -48,6 +50,8 @@ class Codebolt {
|
|
|
48
50
|
this.outputparsers = outputparsers_1.default;
|
|
49
51
|
this.project = project_1.default;
|
|
50
52
|
this.dbmemory = dbmemory_1.default;
|
|
53
|
+
this.cbstate = state_1.default;
|
|
54
|
+
this.taskplaner = task_1.default;
|
|
51
55
|
this.websocket = websocket_1.default.getWebsocket;
|
|
52
56
|
}
|
|
53
57
|
/**
|
package/modules/state.js
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const websocket_1 = __importDefault(require("./websocket"));
|
|
7
|
+
/**
|
|
8
|
+
* Retrieves the application state asynchronously.
|
|
9
|
+
* @returns {Promise<any>} A promise that resolves with the application state.
|
|
10
|
+
*/
|
|
11
|
+
const cbstate = {
|
|
12
|
+
getApplicationState: async () => {
|
|
13
|
+
return new Promise((resolve, reject) => {
|
|
14
|
+
websocket_1.default.getWebsocket.send(JSON.stringify({
|
|
15
|
+
"type": "getAppState",
|
|
16
|
+
}));
|
|
17
|
+
websocket_1.default.getWebsocket.on('message', (data) => {
|
|
18
|
+
const response = JSON.parse(data);
|
|
19
|
+
if (response.type === "getAppStateResponse") {
|
|
20
|
+
resolve(response); // Resolve the Promise with the response data
|
|
21
|
+
}
|
|
22
|
+
});
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
};
|
|
26
|
+
exports.default = cbstate;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Manages task operations via WebSocket communication.
|
|
3
|
+
*/
|
|
4
|
+
declare const taskplaner: {
|
|
5
|
+
/**
|
|
6
|
+
* Adds a task using a WebSocket message.
|
|
7
|
+
* @param {string} task - The task to be added.
|
|
8
|
+
* @returns {Promise<any>} A promise that resolves with the response from the add task event.
|
|
9
|
+
*/
|
|
10
|
+
addTask: (task: string) => Promise<any>;
|
|
11
|
+
/**
|
|
12
|
+
* Retrieves all tasks using a WebSocket message.
|
|
13
|
+
* @returns {Promise<any>} A promise that resolves with the response from the get tasks event.
|
|
14
|
+
*/
|
|
15
|
+
getTasks: () => Promise<any>;
|
|
16
|
+
/**
|
|
17
|
+
* Updates an existing task using a WebSocket message.
|
|
18
|
+
* @param {string} task - The updated task information.
|
|
19
|
+
* @returns {Promise<any>} A promise that resolves with the response from the update task event.
|
|
20
|
+
*/
|
|
21
|
+
updateTask: (task: string) => Promise<any>;
|
|
22
|
+
};
|
|
23
|
+
export default taskplaner;
|
package/modules/task.js
ADDED
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const websocket_1 = __importDefault(require("./websocket"));
|
|
7
|
+
/**
|
|
8
|
+
* Manages task operations via WebSocket communication.
|
|
9
|
+
*/
|
|
10
|
+
const taskplaner = {
|
|
11
|
+
/**
|
|
12
|
+
* Adds a task using a WebSocket message.
|
|
13
|
+
* @param {string} task - The task to be added.
|
|
14
|
+
* @returns {Promise<any>} A promise that resolves with the response from the add task event.
|
|
15
|
+
*/
|
|
16
|
+
addTask: async (task) => {
|
|
17
|
+
return new Promise((resolve, reject) => {
|
|
18
|
+
websocket_1.default.getWebsocket.send(JSON.stringify({
|
|
19
|
+
"type": "taskEvent",
|
|
20
|
+
"action": "addTask",
|
|
21
|
+
message: {
|
|
22
|
+
"task": task
|
|
23
|
+
}
|
|
24
|
+
}));
|
|
25
|
+
websocket_1.default.getWebsocket.on('message', (data) => {
|
|
26
|
+
const response = JSON.parse(data);
|
|
27
|
+
if (response.type === "addTaskResponse") {
|
|
28
|
+
resolve(response); // Resolve the promise with the response data from adding the task
|
|
29
|
+
}
|
|
30
|
+
});
|
|
31
|
+
});
|
|
32
|
+
},
|
|
33
|
+
/**
|
|
34
|
+
* Retrieves all tasks using a WebSocket message.
|
|
35
|
+
* @returns {Promise<any>} A promise that resolves with the response from the get tasks event.
|
|
36
|
+
*/
|
|
37
|
+
getTasks: async () => {
|
|
38
|
+
return new Promise((resolve, reject) => {
|
|
39
|
+
websocket_1.default.getWebsocket.send(JSON.stringify({
|
|
40
|
+
"type": "taskEvent",
|
|
41
|
+
"action": "getTasks"
|
|
42
|
+
}));
|
|
43
|
+
websocket_1.default.getWebsocket.on('message', (data) => {
|
|
44
|
+
const response = JSON.parse(data);
|
|
45
|
+
if (response.type === "getTasksResponse") {
|
|
46
|
+
resolve(response); // Resolve the promise with the response data from retrieving tasks
|
|
47
|
+
}
|
|
48
|
+
});
|
|
49
|
+
});
|
|
50
|
+
},
|
|
51
|
+
/**
|
|
52
|
+
* Updates an existing task using a WebSocket message.
|
|
53
|
+
* @param {string} task - The updated task information.
|
|
54
|
+
* @returns {Promise<any>} A promise that resolves with the response from the update task event.
|
|
55
|
+
*/
|
|
56
|
+
updateTask: async (task) => {
|
|
57
|
+
return new Promise((resolve, reject) => {
|
|
58
|
+
websocket_1.default.getWebsocket.send(JSON.stringify({
|
|
59
|
+
"type": "taskEvent",
|
|
60
|
+
"action": "updateTask",
|
|
61
|
+
message: {
|
|
62
|
+
"task": task
|
|
63
|
+
}
|
|
64
|
+
}));
|
|
65
|
+
websocket_1.default.getWebsocket.on('message', (data) => {
|
|
66
|
+
const response = JSON.parse(data);
|
|
67
|
+
if (response.type === "updateTaskResponse") {
|
|
68
|
+
resolve(response); // Resolve the promise with the response data from updating the task
|
|
69
|
+
}
|
|
70
|
+
});
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
};
|
|
74
|
+
exports.default = taskplaner;
|
package/package.json
CHANGED
package/src/index.ts
CHANGED
|
@@ -15,8 +15,11 @@ import cboutputparsers from './modules/outputparsers';
|
|
|
15
15
|
import cbproject from './modules/project';
|
|
16
16
|
import git from './modules/git';
|
|
17
17
|
import dbmemory from './modules/dbmemory';
|
|
18
|
+
import cbstate from './modules/state';
|
|
19
|
+
import task from './modules/task';
|
|
18
20
|
import WebSocket from 'ws';
|
|
19
21
|
|
|
22
|
+
|
|
20
23
|
/**
|
|
21
24
|
* @class Codebolt
|
|
22
25
|
* @description This class provides a unified interface to interact with various modules.
|
|
@@ -69,7 +72,6 @@ class Codebolt {
|
|
|
69
72
|
start_browser(objective:string, url:string, previous_command:string, browser_content:string) {
|
|
70
73
|
cbbrowser.newPage();
|
|
71
74
|
}
|
|
72
|
-
|
|
73
75
|
websocket: WebSocket | null = null;
|
|
74
76
|
fs = cbfs;
|
|
75
77
|
git=git;
|
|
@@ -87,6 +89,8 @@ class Codebolt {
|
|
|
87
89
|
outputparsers = cboutputparsers;
|
|
88
90
|
project = cbproject;
|
|
89
91
|
dbmemory = dbmemory;
|
|
92
|
+
cbstate=cbstate;
|
|
93
|
+
taskplaner=task
|
|
90
94
|
}
|
|
91
95
|
|
|
92
96
|
// export default new Codebolt();
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import cbws from './websocket';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Retrieves the application state asynchronously.
|
|
5
|
+
* @returns {Promise<any>} A promise that resolves with the application state.
|
|
6
|
+
*/
|
|
7
|
+
const cbstate = {
|
|
8
|
+
getApplicationState: async (): Promise<any> => {
|
|
9
|
+
return new Promise((resolve, reject) => {
|
|
10
|
+
cbws.getWebsocket.send(JSON.stringify({
|
|
11
|
+
"type": "getAppState",
|
|
12
|
+
|
|
13
|
+
}));
|
|
14
|
+
cbws.getWebsocket.on('message', (data: string) => {
|
|
15
|
+
const response = JSON.parse(data);
|
|
16
|
+
if (response.type === "getAppStateResponse") {
|
|
17
|
+
resolve(response); // Resolve the Promise with the response data
|
|
18
|
+
}
|
|
19
|
+
});
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
export default cbstate;
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import cbws from './websocket';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Manages task operations via WebSocket communication.
|
|
5
|
+
*/
|
|
6
|
+
const taskplaner = {
|
|
7
|
+
/**
|
|
8
|
+
* Adds a task using a WebSocket message.
|
|
9
|
+
* @param {string} task - The task to be added.
|
|
10
|
+
* @returns {Promise<any>} A promise that resolves with the response from the add task event.
|
|
11
|
+
*/
|
|
12
|
+
addTask: async (task: string): Promise<any> => {
|
|
13
|
+
return new Promise((resolve, reject) => {
|
|
14
|
+
cbws.getWebsocket.send(JSON.stringify({
|
|
15
|
+
"type": "taskEvent",
|
|
16
|
+
"action":"addTask",
|
|
17
|
+
message:{
|
|
18
|
+
"task": task
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
}));
|
|
22
|
+
cbws.getWebsocket.on('message', (data: string) => {
|
|
23
|
+
const response = JSON.parse(data);
|
|
24
|
+
if (response.type === "addTaskResponse") {
|
|
25
|
+
resolve(response); // Resolve the promise with the response data from adding the task
|
|
26
|
+
}
|
|
27
|
+
});
|
|
28
|
+
});
|
|
29
|
+
},
|
|
30
|
+
/**
|
|
31
|
+
* Retrieves all tasks using a WebSocket message.
|
|
32
|
+
* @returns {Promise<any>} A promise that resolves with the response from the get tasks event.
|
|
33
|
+
*/
|
|
34
|
+
getTasks: async (): Promise<any> => {
|
|
35
|
+
return new Promise((resolve, reject) => {
|
|
36
|
+
cbws.getWebsocket.send(JSON.stringify({
|
|
37
|
+
"type":"taskEvent",
|
|
38
|
+
"action": "getTasks"
|
|
39
|
+
}));
|
|
40
|
+
cbws.getWebsocket.on('message', (data: string) => {
|
|
41
|
+
const response = JSON.parse(data);
|
|
42
|
+
if (response.type === "getTasksResponse") {
|
|
43
|
+
resolve(response); // Resolve the promise with the response data from retrieving tasks
|
|
44
|
+
}
|
|
45
|
+
});
|
|
46
|
+
});
|
|
47
|
+
},
|
|
48
|
+
/**
|
|
49
|
+
* Updates an existing task using a WebSocket message.
|
|
50
|
+
* @param {string} task - The updated task information.
|
|
51
|
+
* @returns {Promise<any>} A promise that resolves with the response from the update task event.
|
|
52
|
+
*/
|
|
53
|
+
updateTask: async ( task: string): Promise<any> => {
|
|
54
|
+
return new Promise((resolve, reject) => {
|
|
55
|
+
cbws.getWebsocket.send(JSON.stringify({
|
|
56
|
+
"type": "taskEvent",
|
|
57
|
+
"action": "updateTask",
|
|
58
|
+
message: {
|
|
59
|
+
"task": task
|
|
60
|
+
}
|
|
61
|
+
}));
|
|
62
|
+
cbws.getWebsocket.on('message', (data: string) => {
|
|
63
|
+
const response = JSON.parse(data);
|
|
64
|
+
if (response.type === "updateTaskResponse") {
|
|
65
|
+
resolve(response); // Resolve the promise with the response data from updating the task
|
|
66
|
+
}
|
|
67
|
+
});
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
export default taskplaner;
|