@codebolt/codeboltjs 1.1.10 → 1.1.13

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 CHANGED
@@ -20,6 +20,7 @@ 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"));
23
24
  const ws_1 = __importDefault(require("ws"));
24
25
  /**
25
26
  * @class Codebolt
@@ -48,6 +49,7 @@ class Codebolt {
48
49
  this.outputparsers = outputparsers_1.default;
49
50
  this.project = project_1.default;
50
51
  this.dbmemory = dbmemory_1.default;
52
+ this.cbstate = state_1.default;
51
53
  this.websocket = websocket_1.default.getWebsocket;
52
54
  }
53
55
  /**
package/modules/chat.d.ts CHANGED
@@ -10,6 +10,7 @@ declare class CustomEventEmitter extends EventEmitter {
10
10
  */
11
11
  declare const cbchat: {
12
12
  eventEmitter: CustomEventEmitter;
13
+ getChatHistory(): Promise<unknown>;
13
14
  /**
14
15
  * Sends a message through the WebSocket connection.
15
16
  * @param {string} message - The message to be sent.
package/modules/chat.js CHANGED
@@ -16,6 +16,19 @@ class CustomEventEmitter extends events_1.EventEmitter {
16
16
  */
17
17
  const cbchat = {
18
18
  eventEmitter: new CustomEventEmitter(),
19
+ getChatHistory() {
20
+ return new Promise((resolve, reject) => {
21
+ websocket_1.default.getWebsocket.send(JSON.stringify({
22
+ "type": "getChatHistory"
23
+ }));
24
+ websocket_1.default.getWebsocket.on('message', (data) => {
25
+ const response = JSON.parse(data);
26
+ if (response.type === "getChatHistoryResponse") {
27
+ resolve(response); // Resolve the Promise with the response data
28
+ }
29
+ });
30
+ });
31
+ },
19
32
  /**
20
33
  * Sends a message through the WebSocket connection.
21
34
  * @param {string} message - The message to be sent.
@@ -0,0 +1,4 @@
1
+ declare const cbstate: {
2
+ getApplicationState: () => Promise<any>;
3
+ };
4
+ export default cbstate;
@@ -0,0 +1,22 @@
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
+ const cbstate = {
8
+ getApplicationState: async () => {
9
+ return new Promise((resolve, reject) => {
10
+ websocket_1.default.getWebsocket.send(JSON.stringify({
11
+ "type": "getAppState",
12
+ }));
13
+ websocket_1.default.getWebsocket.on('message', (data) => {
14
+ const response = JSON.parse(data);
15
+ if (response.type === "getAppStateResponse") {
16
+ resolve(response); // Resolve the Promise with the response data
17
+ }
18
+ });
19
+ });
20
+ }
21
+ };
22
+ exports.default = cbstate;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@codebolt/codeboltjs",
3
- "version": "1.1.10",
3
+ "version": "1.1.13",
4
4
  "description": "",
5
5
  "keywords": [],
6
6
  "author": "",
package/src/index.ts CHANGED
@@ -15,6 +15,7 @@ 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'
18
19
  import WebSocket from 'ws';
19
20
 
20
21
  /**
@@ -87,6 +88,7 @@ class Codebolt {
87
88
  outputparsers = cboutputparsers;
88
89
  project = cbproject;
89
90
  dbmemory = dbmemory;
91
+ cbstate=cbstate;
90
92
  }
91
93
 
92
94
  // export default new Codebolt();
@@ -13,6 +13,22 @@ class CustomEventEmitter extends EventEmitter {}
13
13
  const cbchat = {
14
14
  eventEmitter: new CustomEventEmitter(),
15
15
 
16
+ getChatHistory() {
17
+ return new Promise((resolve, reject) => {
18
+ cbws.getWebsocket.send(JSON.stringify({
19
+ "type": "getChatHistory"
20
+ }));
21
+ cbws.getWebsocket.on('message', (data: string) => {
22
+ const response = JSON.parse(data);
23
+ if (response.type === "getChatHistoryResponse") {
24
+ resolve(response); // Resolve the Promise with the response data
25
+ }
26
+ })
27
+ })
28
+
29
+
30
+ },
31
+
16
32
  /**
17
33
  * Sends a message through the WebSocket connection.
18
34
  * @param {string} message - The message to be sent.
@@ -0,0 +1,22 @@
1
+ import cbws from './websocket';
2
+
3
+
4
+ const cbstate = {
5
+ getApplicationState: async (): Promise<any> => {
6
+ return new Promise((resolve, reject) => {
7
+ cbws.getWebsocket.send(JSON.stringify({
8
+ "type": "getAppState",
9
+
10
+ }));
11
+ cbws.getWebsocket.on('message', (data: string) => {
12
+ const response = JSON.parse(data);
13
+ if (response.type === "getAppStateResponse") {
14
+ resolve(response); // Resolve the Promise with the response data
15
+ }
16
+ });
17
+ });
18
+ }
19
+ };
20
+
21
+ export default cbstate;
22
+