@codebolt/codeboltjs 1.1.27 → 1.1.28

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.d.ts CHANGED
@@ -97,7 +97,9 @@ declare class Codebolt {
97
97
  };
98
98
  codeutils: {
99
99
  getCodeTree: () => Promise<any>;
100
+ getJsTree: (filePath: string) => Promise<any>;
100
101
  getAllFilesAsMarkDown: () => Promise<unknown>;
102
+ matchProblem: (matcherDefinition: object, problemPatterns: [], problems: []) => Promise<unknown>;
101
103
  };
102
104
  docutils: {
103
105
  pdf_to_text: (pdf_path: any) => Promise<string>;
@@ -2,14 +2,9 @@
2
2
  * A utility module for working with code.
3
3
  */
4
4
  declare const cbcodeutils: {
5
- /**
6
- * Asynchronously generates a code tree from the provided source code.
7
- * @param {any} fileName - The name of the file.
8
- * @param {any} source - The source code to generate the tree from.
9
- * @param {any} filePath - The file path where the source code is located.
10
- * @returns {Promise<any>} A promise that resolves with the code tree.
11
- */
12
5
  getCodeTree: () => Promise<any>;
6
+ getJsTree: (filePath: string) => Promise<any>;
13
7
  getAllFilesAsMarkDown: () => Promise<unknown>;
8
+ matchProblem: (matcherDefinition: object, problemPatterns: [], problems: []) => Promise<unknown>;
14
9
  };
15
10
  export default cbcodeutils;
@@ -8,13 +8,6 @@ const websocket_1 = __importDefault(require("./websocket"));
8
8
  * A utility module for working with code.
9
9
  */
10
10
  const cbcodeutils = {
11
- /**
12
- * Asynchronously generates a code tree from the provided source code.
13
- * @param {any} fileName - The name of the file.
14
- * @param {any} source - The source code to generate the tree from.
15
- * @param {any} filePath - The file path where the source code is located.
16
- * @returns {Promise<any>} A promise that resolves with the code tree.
17
- */
18
11
  getCodeTree: () => {
19
12
  return new Promise((resolve, reject) => {
20
13
  websocket_1.default.getWebsocket.send(JSON.stringify({
@@ -29,6 +22,23 @@ const cbcodeutils = {
29
22
  });
30
23
  });
31
24
  },
25
+ getJsTree: (filePath) => {
26
+ return new Promise((resolve, reject) => {
27
+ websocket_1.default.getWebsocket.send(JSON.stringify({
28
+ "type": "codeEvent",
29
+ "action": "getJsTree",
30
+ payload: {
31
+ filePath
32
+ }
33
+ }));
34
+ websocket_1.default.getWebsocket.on('message', (data) => {
35
+ const response = JSON.parse(data);
36
+ if (response.type === "getgetJsTreeResponse") {
37
+ resolve(response.payload); // Resolve the Promise with the response data
38
+ }
39
+ });
40
+ });
41
+ },
32
42
  getAllFilesAsMarkDown: () => {
33
43
  return new Promise((resolve, reject) => {
34
44
  websocket_1.default.getWebsocket.send(JSON.stringify({
@@ -42,6 +52,25 @@ const cbcodeutils = {
42
52
  }
43
53
  });
44
54
  });
55
+ },
56
+ matchProblem: (matcherDefinition, problemPatterns, problems) => {
57
+ return new Promise((resolve, reject) => {
58
+ websocket_1.default.getWebsocket.send(JSON.stringify({
59
+ "type": "codeEvent",
60
+ "action": "getJsTree",
61
+ payload: {
62
+ matcherDefinition,
63
+ problemPatterns,
64
+ problems
65
+ }
66
+ }));
67
+ websocket_1.default.getWebsocket.on('message', (data) => {
68
+ const response = JSON.parse(data);
69
+ if (response.type === "getgetJsTreeResponse") {
70
+ resolve(response.payload); // Resolve the Promise with the response data
71
+ }
72
+ });
73
+ });
45
74
  }
46
75
  };
47
76
  exports.default = cbcodeutils;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@codebolt/codeboltjs",
3
- "version": "1.1.27",
3
+ "version": "1.1.28",
4
4
  "description": "",
5
5
  "keywords": [],
6
6
  "author": "",
@@ -4,13 +4,8 @@ import cbws from './websocket';
4
4
  * A utility module for working with code.
5
5
  */
6
6
  const cbcodeutils = {
7
- /**
8
- * Asynchronously generates a code tree from the provided source code.
9
- * @param {any} fileName - The name of the file.
10
- * @param {any} source - The source code to generate the tree from.
11
- * @param {any} filePath - The file path where the source code is located.
12
- * @returns {Promise<any>} A promise that resolves with the code tree.
13
- */
7
+
8
+
14
9
  getCodeTree: (): Promise<any> => {
15
10
  return new Promise((resolve, reject) => {
16
11
  cbws.getWebsocket.send(JSON.stringify({
@@ -25,6 +20,23 @@ const cbcodeutils = {
25
20
  });
26
21
  });
27
22
  },
23
+ getJsTree: (filePath:string): Promise<any> => {
24
+ return new Promise((resolve, reject) => {
25
+ cbws.getWebsocket.send(JSON.stringify({
26
+ "type": "codeEvent",
27
+ "action":"getJsTree",
28
+ payload:{
29
+ filePath
30
+ }
31
+ }));
32
+ cbws.getWebsocket.on('message', (data: string) => {
33
+ const response = JSON.parse(data);
34
+ if (response.type === "getgetJsTreeResponse") {
35
+ resolve(response.payload); // Resolve the Promise with the response data
36
+ }
37
+ });
38
+ });
39
+ },
28
40
  getAllFilesAsMarkDown:()=>{
29
41
  return new Promise((resolve, reject) => {
30
42
  cbws.getWebsocket.send(JSON.stringify({
@@ -38,6 +50,25 @@ const cbcodeutils = {
38
50
  }
39
51
  });
40
52
  });
53
+ },
54
+ matchProblem:(matcherDefinition:object, problemPatterns:[], problems:[])=>{
55
+ return new Promise((resolve, reject) => {
56
+ cbws.getWebsocket.send(JSON.stringify({
57
+ "type": "codeEvent",
58
+ "action":"getJsTree",
59
+ payload:{
60
+ matcherDefinition,
61
+ problemPatterns,
62
+ problems
63
+ }
64
+ }));
65
+ cbws.getWebsocket.on('message', (data: string) => {
66
+ const response = JSON.parse(data);
67
+ if (response.type === "getgetJsTreeResponse") {
68
+ resolve(response.payload); // Resolve the Promise with the response data
69
+ }
70
+ });
71
+ });
41
72
  }
42
73
  };
43
74