@codebolt/codeboltjs 2.0.5 → 2.0.7

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.
Files changed (67) hide show
  1. package/dist/core/websocket.js +2 -1
  2. package/dist/index.d.ts +65 -19
  3. package/dist/index.js +2 -2
  4. package/dist/modules/agent.js +1 -1
  5. package/dist/modules/codeparsers.d.ts +32 -3
  6. package/dist/modules/codeparsers.js +295 -3
  7. package/dist/modules/codeutils.d.ts +24 -7
  8. package/dist/modules/codeutils.js +93 -29
  9. package/dist/modules/fs.d.ts +46 -0
  10. package/dist/modules/fs.js +70 -1
  11. package/dist/modules/git.d.ts +7 -14
  12. package/dist/modules/git.js +16 -37
  13. package/dist/modules/outputparsers.d.ts +36 -4
  14. package/dist/modules/outputparsers.js +56 -5
  15. package/dist/modules/project.d.ts +3 -4
  16. package/dist/modules/project.js +7 -5
  17. package/dist/modules/terminal.js +1 -1
  18. package/dist/{modules → utils}/docutils.d.ts +3 -6
  19. package/dist/utils/docutils.js +69 -0
  20. package/dist/utils/parse-source-code/index.d.ts +9 -0
  21. package/dist/utils/parse-source-code/index.js +233 -0
  22. package/dist/utils/parse-source-code/languageParser.d.ts +8 -0
  23. package/dist/utils/parse-source-code/languageParser.js +137 -0
  24. package/dist/utils/parse-source-code/queries/c-sharp.d.ts +2 -0
  25. package/dist/utils/parse-source-code/queries/c-sharp.js +25 -0
  26. package/dist/utils/parse-source-code/queries/c.d.ts +2 -0
  27. package/dist/utils/parse-source-code/queries/c.js +17 -0
  28. package/dist/utils/parse-source-code/queries/cpp.d.ts +2 -0
  29. package/dist/utils/parse-source-code/queries/cpp.js +25 -0
  30. package/dist/utils/parse-source-code/queries/go.d.ts +2 -0
  31. package/dist/utils/parse-source-code/queries/go.js +29 -0
  32. package/dist/utils/parse-source-code/queries/index.d.ts +12 -0
  33. package/dist/utils/parse-source-code/queries/index.js +30 -0
  34. package/dist/utils/parse-source-code/queries/java.d.ts +2 -0
  35. package/dist/utils/parse-source-code/queries/java.js +17 -0
  36. package/dist/utils/parse-source-code/queries/javascript.d.ts +2 -0
  37. package/dist/utils/parse-source-code/queries/javascript.js +67 -0
  38. package/dist/utils/parse-source-code/queries/php.d.ts +2 -0
  39. package/dist/utils/parse-source-code/queries/php.js +17 -0
  40. package/dist/utils/parse-source-code/queries/python.d.ts +2 -0
  41. package/dist/utils/parse-source-code/queries/python.js +13 -0
  42. package/dist/utils/parse-source-code/queries/ruby.d.ts +2 -0
  43. package/dist/utils/parse-source-code/queries/ruby.js +54 -0
  44. package/dist/utils/parse-source-code/queries/rust.d.ts +2 -0
  45. package/dist/utils/parse-source-code/queries/rust.js +18 -0
  46. package/dist/utils/parse-source-code/queries/swift.d.ts +2 -0
  47. package/dist/utils/parse-source-code/queries/swift.js +47 -0
  48. package/dist/utils/parse-source-code/queries/typescript.d.ts +2 -0
  49. package/dist/utils/parse-source-code/queries/typescript.js +34 -0
  50. package/dist/utils/parse-source-code/tree-sitter-c.wasm +0 -0
  51. package/dist/utils/parse-source-code/tree-sitter-c_sharp.wasm +0 -0
  52. package/dist/utils/parse-source-code/tree-sitter-cpp.wasm +0 -0
  53. package/dist/utils/parse-source-code/tree-sitter-go.wasm +0 -0
  54. package/dist/utils/parse-source-code/tree-sitter-java.wasm +0 -0
  55. package/dist/utils/parse-source-code/tree-sitter-javascript.wasm +0 -0
  56. package/dist/utils/parse-source-code/tree-sitter-php.wasm +0 -0
  57. package/dist/utils/parse-source-code/tree-sitter-python.wasm +0 -0
  58. package/dist/utils/parse-source-code/tree-sitter-ruby.wasm +0 -0
  59. package/dist/utils/parse-source-code/tree-sitter-rust.wasm +0 -0
  60. package/dist/utils/parse-source-code/tree-sitter-swift.wasm +0 -0
  61. package/dist/utils/parse-source-code/tree-sitter-tsx.wasm +0 -0
  62. package/dist/utils/parse-source-code/tree-sitter-typescript.wasm +0 -0
  63. package/dist/utils/parse-source-code/tree-sitter.wasm +0 -0
  64. package/dist/utils.d.ts +1 -0
  65. package/dist/utils.js +6 -1
  66. package/package.json +6 -2
  67. package/dist/modules/docutils.js +0 -19
@@ -1,9 +1,35 @@
1
1
  "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
2
25
  var __importDefault = (this && this.__importDefault) || function (mod) {
3
26
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
27
  };
5
28
  Object.defineProperty(exports, "__esModule", { value: true });
6
29
  const websocket_1 = __importDefault(require("../core/websocket"));
30
+ const fs = __importStar(require("fs"));
31
+ const path_1 = __importDefault(require("path"));
32
+ const languageParser_1 = require("../utils/parse-source-code/languageParser");
7
33
  /**
8
34
  * A utility module for working with code.
9
35
  */
@@ -11,28 +37,65 @@ const cbcodeutils = {
11
37
  /**
12
38
  * Retrieves a JavaScript tree structure for a given file path.
13
39
  * @param {string} filePath - The path of the file to retrieve the JS tree for.
14
- * @returns {Promise<GetJsTreeResponse>} A promise that resolves with the JS tree response.
40
+ * @returns {Promise<JSTreeResponse>} A promise that resolves with the JS tree response.
15
41
  */
16
- getJsTree: (filePath) => {
17
- return websocket_1.default.messageManager.sendAndWaitForResponse({
18
- "type": "settingEvent",
19
- "action": "getProjectPath"
20
- }, "getProjectPathResponse");
21
- // return new Promise(async (resolve, reject) => {
22
- // cbws.messageManager.send({
23
- // "type": "codeEvent",
24
- // "action": "getJsTree",
25
- // payload: {
26
- // filePath
27
- // }
28
- // });
29
- // cbws.getWebsocket.on('message', (data: string) => {
30
- // const response = JSON.parse(data);
31
- // if (response.type === "getJsTreeResponse") {
32
- // resolve(response); // Resolve the Promise with the response data
33
- // }
34
- // });
35
- // });
42
+ getJsTree: async (filePath) => {
43
+ try {
44
+ // If no filePath is provided, we can't parse anything
45
+ if (!filePath) {
46
+ throw new Error('No file path provided for parsing');
47
+ }
48
+ // Get absolute path to ensure file can be accessed
49
+ const absolutePath = path_1.default.resolve(filePath);
50
+ // Check if file exists
51
+ await fs.promises.access(absolutePath);
52
+ // Get file extension to determine language parser
53
+ const ext = path_1.default.extname(absolutePath).toLowerCase().slice(1);
54
+ // Load appropriate language parser
55
+ const languageParsers = await (0, languageParser_1.loadRequiredLanguageParsers)([absolutePath]);
56
+ // Get parser for this file type
57
+ const { parser, query } = languageParsers[ext] || {};
58
+ if (!parser || !query) {
59
+ throw new Error(`Unsupported language: ${ext}`);
60
+ }
61
+ // Read file content
62
+ const fileContent = await fs.promises.readFile(absolutePath, 'utf8');
63
+ // Parse file to get AST
64
+ const tree = parser.parse(fileContent);
65
+ // Get captures from the AST using the query
66
+ const captures = query.captures(tree.rootNode);
67
+ // Sort captures by position
68
+ captures.sort((a, b) => a.node.startPosition.row - b.node.startPosition.row ||
69
+ a.node.startPosition.column - b.node.startPosition.column);
70
+ // Transform captures into a structured format
71
+ const structure = captures.map((capture) => {
72
+ const { node, name } = capture;
73
+ return {
74
+ type: name.includes('definition.') ? name.split('definition.')[1] : name,
75
+ name: node.text,
76
+ startLine: node.startPosition.row,
77
+ endLine: node.endPosition.row,
78
+ startColumn: node.startPosition.column,
79
+ endColumn: node.endPosition.column,
80
+ nodeType: node.type
81
+ };
82
+ });
83
+ // Return response with the appropriate structure
84
+ return {
85
+ event: 'getJsTreeResponse',
86
+ payload: {
87
+ filePath: absolutePath,
88
+ structure
89
+ }
90
+ };
91
+ }
92
+ catch (error) {
93
+ // Return error response
94
+ return {
95
+ event: 'getJsTreeResponse',
96
+ error: error instanceof Error ? error.message : String(error)
97
+ };
98
+ }
36
99
  },
37
100
  /**
38
101
  * Retrieves all files as Markdown.
@@ -46,20 +109,21 @@ const cbcodeutils = {
46
109
  },
47
110
  /**
48
111
  * Performs a matching operation based on the provided matcher definition and problem patterns.
49
- * @param {object} matcherDefinition - The definition of the matcher.
50
- * @param {Array} problemPatterns - The patterns to match against.
51
- * @param {Array} problems - The list of problems.
112
+ * @param {object} matcherDefinition - The definition of the matcher (name, pattern, language, etc.).
113
+ * @param {Array} problemPatterns - The patterns to match against (regex patterns with severity levels).
114
+ * @param {Array} problems - Optional list of pre-existing problems to include.
52
115
  * @returns {Promise<MatchProblemResponse>} A promise that resolves with the matching problem response.
53
116
  */
54
- performMatch: (matcherDefinition, problemPatterns, problems) => {
117
+ performMatch: (matcherDefinition, problemPatterns, problems = []) => {
55
118
  return websocket_1.default.messageManager.sendAndWaitForResponse({
56
119
  "type": "codeEvent",
57
120
  "action": "performMatch",
58
121
  payload: {
59
122
  matcherDefinition,
60
123
  problemPatterns,
124
+ problems
61
125
  }
62
- }, "getgetJsTreeResponse");
126
+ }, "matchProblemResponse");
63
127
  },
64
128
  /**
65
129
  * Retrieves the list of matchers.
@@ -73,7 +137,7 @@ const cbcodeutils = {
73
137
  },
74
138
  /**
75
139
  * Retrieves details of a match.
76
- * @param {string} matcher - The matcher to retrieve details for.
140
+ * @param {string} matcher - The matcher to retrieve details for (by name or identifier).
77
141
  * @returns {Promise<getMatchDetail>} A promise that resolves with the match detail response.
78
142
  */
79
143
  matchDetail: (matcher) => {
@@ -81,9 +145,9 @@ const cbcodeutils = {
81
145
  "type": "codeEvent",
82
146
  "action": "getMatchDetail",
83
147
  payload: {
84
- match: matcher
148
+ matcher: matcher
85
149
  }
86
- }, "matchDetailTreeResponse");
150
+ }, "getMatchDetailResponse");
87
151
  }
88
152
  };
89
153
  exports.default = cbcodeutils;
@@ -90,5 +90,51 @@ declare const cbfs: {
90
90
  * @returns {Promise<{success: boolean, result: any}>} A promise that resolves with the write operation result.
91
91
  */
92
92
  writeToFile: (relPath: string, newContent: string) => Promise<any>;
93
+ /**
94
+ * @function listFiles
95
+ * @description Lists all files in a directory.
96
+ * @param {string} path - The path to list files from.
97
+ * @param {boolean} isRecursive - Whether to list files recursively.
98
+ * @param {boolean} askForPermission - Whether to ask for permission before listing.
99
+ * @returns {Promise<{success: boolean, result: any}>} A promise that resolves with the list of files.
100
+ */
101
+ /**
102
+ * @function grepSearch
103
+ * @description Performs a grep search in files.
104
+ * @param {string} path - The path to search within.
105
+ * @param {string} query - The query to search for.
106
+ * @param {string} includePattern - Pattern of files to include.
107
+ * @param {string} excludePattern - Pattern of files to exclude.
108
+ * @param {boolean} caseSensitive - Whether the search is case sensitive.
109
+ * @returns {Promise<{success: boolean, result: any}>} A promise that resolves with the search results.
110
+ */
111
+ grepSearch: (path: string, query: string, includePattern?: string, excludePattern?: string, caseSensitive?: boolean) => Promise<{
112
+ success: boolean;
113
+ result: any;
114
+ }>;
115
+ /**
116
+ * @function fileSearch
117
+ * @description Performs a fuzzy search for files.
118
+ * @param {string} query - The query to search for.
119
+ * @returns {Promise<{success: boolean, result: any}>} A promise that resolves with the search results.
120
+ */
121
+ fileSearch: (query: string) => Promise<{
122
+ success: boolean;
123
+ result: any;
124
+ }>;
125
+ /**
126
+ * @function editFileWithDiff
127
+ * @description Edits a file by applying a diff.
128
+ * @param {string} targetFile - The target file to edit.
129
+ * @param {string} codeEdit - The code edit to apply.
130
+ * @param {string} diffIdentifier - The diff identifier.
131
+ * @param {string} prompt - The prompt for the edit.
132
+ * @param {string} applyModel - The model to apply the edit with.
133
+ * @returns {Promise<{success: boolean, result: any}>} A promise that resolves with the edit result.
134
+ */
135
+ editFileWithDiff: (targetFile: string, codeEdit: string, diffIdentifier: string, prompt: string, applyModel?: string) => Promise<{
136
+ success: boolean;
137
+ result: any;
138
+ }>;
93
139
  };
94
140
  export default cbfs;
@@ -78,7 +78,7 @@ const cbfs = {
78
78
  filePath,
79
79
  newContent
80
80
  },
81
- }, "commandOutput");
81
+ }, "updateFileResponse");
82
82
  },
83
83
  /**
84
84
  * @function deleteFile
@@ -180,5 +180,74 @@ const cbfs = {
180
180
  }
181
181
  }, "writeToFileResponse");
182
182
  },
183
+ /**
184
+ * @function listFiles
185
+ * @description Lists all files in a directory.
186
+ * @param {string} path - The path to list files from.
187
+ * @param {boolean} isRecursive - Whether to list files recursively.
188
+ * @param {boolean} askForPermission - Whether to ask for permission before listing.
189
+ * @returns {Promise<{success: boolean, result: any}>} A promise that resolves with the list of files.
190
+ */
191
+ /**
192
+ * @function grepSearch
193
+ * @description Performs a grep search in files.
194
+ * @param {string} path - The path to search within.
195
+ * @param {string} query - The query to search for.
196
+ * @param {string} includePattern - Pattern of files to include.
197
+ * @param {string} excludePattern - Pattern of files to exclude.
198
+ * @param {boolean} caseSensitive - Whether the search is case sensitive.
199
+ * @returns {Promise<{success: boolean, result: any}>} A promise that resolves with the search results.
200
+ */
201
+ grepSearch: (path, query, includePattern, excludePattern, caseSensitive = true) => {
202
+ return websocket_1.default.messageManager.sendAndWaitForResponse({
203
+ "type": "fsEvent",
204
+ "action": "grep_search",
205
+ "message": {
206
+ path,
207
+ query,
208
+ includePattern,
209
+ excludePattern,
210
+ caseSensitive
211
+ }
212
+ }, "grepSearchResponse");
213
+ },
214
+ /**
215
+ * @function fileSearch
216
+ * @description Performs a fuzzy search for files.
217
+ * @param {string} query - The query to search for.
218
+ * @returns {Promise<{success: boolean, result: any}>} A promise that resolves with the search results.
219
+ */
220
+ fileSearch: (query) => {
221
+ return websocket_1.default.messageManager.sendAndWaitForResponse({
222
+ "type": "fsEvent",
223
+ "action": "file_search",
224
+ "message": {
225
+ query
226
+ }
227
+ }, "fileSearchResponse");
228
+ },
229
+ /**
230
+ * @function editFileWithDiff
231
+ * @description Edits a file by applying a diff.
232
+ * @param {string} targetFile - The target file to edit.
233
+ * @param {string} codeEdit - The code edit to apply.
234
+ * @param {string} diffIdentifier - The diff identifier.
235
+ * @param {string} prompt - The prompt for the edit.
236
+ * @param {string} applyModel - The model to apply the edit with.
237
+ * @returns {Promise<{success: boolean, result: any}>} A promise that resolves with the edit result.
238
+ */
239
+ editFileWithDiff: (targetFile, codeEdit, diffIdentifier, prompt, applyModel) => {
240
+ return websocket_1.default.messageManager.sendAndWaitForResponse({
241
+ "type": "fsEvent",
242
+ "action": "edit_file_with_diff",
243
+ "message": {
244
+ target_file: targetFile,
245
+ code_edit: codeEdit,
246
+ diffIdentifier,
247
+ prompt,
248
+ applyModel
249
+ }
250
+ }, "editFileAndApplyDiffResponse");
251
+ },
183
252
  };
184
253
  exports.default = cbfs;
@@ -8,37 +8,30 @@ declare const gitService: {
8
8
  * @returns {Promise<any>} A promise that resolves with the response from the init event.
9
9
  */
10
10
  init: (path: string) => Promise<any>;
11
- /**
12
- * Clones a Git repository from the given URL to the specified path.
13
- * @param {string} url - The URL of the Git repository to clone.
14
- * @param {string} path - The file system path where the repository should be cloned to.
15
- * @returns {Promise<any>} A promise that resolves with the response from the clone event.
16
- */
17
- clone: (url: string, path: string) => Promise<any>;
18
11
  /**
19
12
  * Pulls the latest changes from the remote repository to the local repository at the given path.
20
13
  * @param {string} path - The file system path of the local Git repository.
21
14
  * @returns {Promise<any>} A promise that resolves with the response from the pull event.
22
15
  */
23
- pull: (path: string) => Promise<any>;
16
+ pull: () => Promise<any>;
24
17
  /**
25
18
  * Pushes local repository changes to the remote repository at the given path.
26
19
  * @param {string} path - The file system path of the local Git repository.
27
20
  * @returns {Promise<any>} A promise that resolves with the response from the push event.
28
21
  */
29
- push: (path: string) => Promise<any>;
22
+ push: () => Promise<any>;
30
23
  /**
31
24
  * Retrieves the status of the local repository at the given path.
32
25
  * @param {string} path - The file system path of the local Git repository.
33
26
  * @returns {Promise<any>} A promise that resolves with the response from the status event.
34
27
  */
35
- status: (path: string) => Promise<any>;
28
+ status: () => Promise<any>;
36
29
  /**
37
30
  * Adds changes in the local repository to the staging area at the given path.
38
31
  * @param {string} path - The file system path of the local Git repository.
39
32
  * @returns {Promise<any>} A promise that resolves with the response from the add event.
40
33
  */
41
- add: (path: string) => Promise<any>;
34
+ addAll: () => Promise<any>;
42
35
  /**
43
36
  * Commits the staged changes in the local repository with the given commit message.
44
37
  * @param {string} message - The commit message to use for the commit.
@@ -51,14 +44,14 @@ declare const gitService: {
51
44
  * @param {string} branch - The name of the branch or commit to check out.
52
45
  * @returns {Promise<any>} A promise that resolves with the response from the checkout event.
53
46
  */
54
- checkout: (path: string, branch: string) => Promise<any>;
47
+ checkout: (branch: string) => Promise<any>;
55
48
  /**
56
49
  * Creates a new branch in the local repository at the given path.
57
50
  * @param {string} path - The file system path of the local Git repository.
58
51
  * @param {string} branch - The name of the new branch to create.
59
52
  * @returns {Promise<any>} A promise that resolves with the response from the branch event.
60
53
  */
61
- branch: (path: string, branch: string) => Promise<any>;
54
+ branch: (branch: string) => Promise<any>;
62
55
  /**
63
56
  * Retrieves the commit logs for the local repository at the given path.
64
57
  * @param {string} path - The file system path of the local Git repository.
@@ -71,6 +64,6 @@ declare const gitService: {
71
64
  * @param {string} path - The file system path of the local Git repository.
72
65
  * @returns {Promise<any>} A promise that resolves with the response from the diff event.
73
66
  */
74
- diff: (commitHash: string, path: string) => Promise<any>;
67
+ diff: (commitHash: string) => Promise<any>;
75
68
  };
76
69
  export default gitService;
@@ -18,32 +18,17 @@ const gitService = {
18
18
  "type": "gitEvent",
19
19
  "action": "Init",
20
20
  "path": path
21
- }, "InitResponse");
22
- },
23
- /**
24
- * Clones a Git repository from the given URL to the specified path.
25
- * @param {string} url - The URL of the Git repository to clone.
26
- * @param {string} path - The file system path where the repository should be cloned to.
27
- * @returns {Promise<any>} A promise that resolves with the response from the clone event.
28
- */
29
- clone: async (url, path) => {
30
- return websocket_1.default.messageManager.sendAndWaitForResponse({
31
- "type": "gitEvent",
32
- "action": "Clone",
33
- "url": url,
34
- "path": path
35
- }, "CloneResponse");
21
+ }, "gitInitResponse");
36
22
  },
37
23
  /**
38
24
  * Pulls the latest changes from the remote repository to the local repository at the given path.
39
25
  * @param {string} path - The file system path of the local Git repository.
40
26
  * @returns {Promise<any>} A promise that resolves with the response from the pull event.
41
27
  */
42
- pull: async (path) => {
28
+ pull: async () => {
43
29
  return websocket_1.default.messageManager.sendAndWaitForResponse({
44
30
  "type": "gitEvent",
45
- "action": "Pull",
46
- "path": path
31
+ "action": "Pull"
47
32
  }, "PullResponse");
48
33
  },
49
34
  /**
@@ -51,11 +36,10 @@ const gitService = {
51
36
  * @param {string} path - The file system path of the local Git repository.
52
37
  * @returns {Promise<any>} A promise that resolves with the response from the push event.
53
38
  */
54
- push: async (path) => {
39
+ push: async () => {
55
40
  return websocket_1.default.messageManager.sendAndWaitForResponse({
56
41
  "type": "gitEvent",
57
42
  "action": "Push",
58
- "path": path
59
43
  }, "PushResponse");
60
44
  },
61
45
  /**
@@ -63,23 +47,21 @@ const gitService = {
63
47
  * @param {string} path - The file system path of the local Git repository.
64
48
  * @returns {Promise<any>} A promise that resolves with the response from the status event.
65
49
  */
66
- status: async (path) => {
50
+ status: async () => {
67
51
  return websocket_1.default.messageManager.sendAndWaitForResponse({
68
52
  "type": "gitEvent",
69
53
  "action": "Status",
70
- "path": path
71
- }, "StatusResponse");
54
+ }, "gitStatusResponse");
72
55
  },
73
56
  /**
74
57
  * Adds changes in the local repository to the staging area at the given path.
75
58
  * @param {string} path - The file system path of the local Git repository.
76
59
  * @returns {Promise<any>} A promise that resolves with the response from the add event.
77
60
  */
78
- add: async (path) => {
61
+ addAll: async () => {
79
62
  return websocket_1.default.messageManager.sendAndWaitForResponse({
80
63
  "type": "gitEvent",
81
64
  "action": "Add",
82
- "path": path
83
65
  }, "AddResponse");
84
66
  },
85
67
  /**
@@ -100,13 +82,12 @@ const gitService = {
100
82
  * @param {string} branch - The name of the branch or commit to check out.
101
83
  * @returns {Promise<any>} A promise that resolves with the response from the checkout event.
102
84
  */
103
- checkout: async (path, branch) => {
85
+ checkout: async (branch) => {
104
86
  return websocket_1.default.messageManager.sendAndWaitForResponse({
105
87
  "type": "gitEvent",
106
88
  "action": "Checkout",
107
- "path": path,
108
89
  "branch": branch
109
- }, "CheckoutResponse");
90
+ }, "gitCheckoutResponse");
110
91
  },
111
92
  /**
112
93
  * Creates a new branch in the local repository at the given path.
@@ -114,13 +95,12 @@ const gitService = {
114
95
  * @param {string} branch - The name of the new branch to create.
115
96
  * @returns {Promise<any>} A promise that resolves with the response from the branch event.
116
97
  */
117
- branch: async (path, branch) => {
98
+ branch: async (branch) => {
118
99
  return websocket_1.default.messageManager.sendAndWaitForResponse({
119
100
  "type": "gitEvent",
120
- "action": "Branch",
121
- "path": path,
122
- "branch": branch
123
- }, "BranchResponse");
101
+ "action": "gitBranch",
102
+ "branch": branch,
103
+ }, "gitBranchResponse");
124
104
  },
125
105
  /**
126
106
  * Retrieves the commit logs for the local repository at the given path.
@@ -130,9 +110,9 @@ const gitService = {
130
110
  logs: async (path) => {
131
111
  return websocket_1.default.messageManager.sendAndWaitForResponse({
132
112
  "type": "gitEvent",
133
- "action": "Logs",
113
+ "action": "gitLogs",
134
114
  "path": path
135
- }, "LogsResponse");
115
+ }, "gitLogsResponse");
136
116
  },
137
117
  /**
138
118
  * Retrieves the diff of changes for a specific commit in the local repository.
@@ -140,11 +120,10 @@ const gitService = {
140
120
  * @param {string} path - The file system path of the local Git repository.
141
121
  * @returns {Promise<any>} A promise that resolves with the response from the diff event.
142
122
  */
143
- diff: async (commitHash, path) => {
123
+ diff: async (commitHash) => {
144
124
  return websocket_1.default.messageManager.sendAndWaitForResponse({
145
125
  "type": "gitEvent",
146
126
  "action": "Diff",
147
- "path": path,
148
127
  "commitHash": commitHash
149
128
  }, "DiffResponse");
150
129
  }
@@ -3,11 +3,43 @@
3
3
  */
4
4
  declare const cboutputparsers: {
5
5
  /**
6
- * Initializes the output parser module.
7
- * Currently, this function does not perform any operations.
8
- * @param {any} output - The output to be initialized.
6
+ * Parses JSON string and returns a result object.
7
+ * @param {string} jsonString - The JSON string to parse.
8
+ * @returns {Object} An object with success flag and parsed data or error.
9
9
  */
10
- init: (output: any) => void;
10
+ parseJSON: (jsonString: string) => {
11
+ success: boolean;
12
+ parsed?: any;
13
+ error?: Error;
14
+ };
15
+ /**
16
+ * Parses XML string and returns a result object.
17
+ * @param {string} xmlString - The XML string to parse.
18
+ * @returns {Object} An object with success flag and parsed data.
19
+ */
20
+ parseXML: (xmlString: string) => {
21
+ success: boolean;
22
+ parsed?: any;
23
+ };
24
+ /**
25
+ * Parses CSV string and returns a result object.
26
+ * @param {string} csvString - The CSV string to parse.
27
+ * @returns {Object} An object with success flag and parsed data or error.
28
+ */
29
+ parseCSV: (csvString: string) => {
30
+ success: boolean;
31
+ parsed?: any[];
32
+ error?: Error;
33
+ };
34
+ /**
35
+ * Parses text string and returns a result object with lines.
36
+ * @param {string} text - The text to parse.
37
+ * @returns {Object} An object with success flag and parsed lines.
38
+ */
39
+ parseText: (text: string) => {
40
+ success: boolean;
41
+ parsed: string[];
42
+ };
11
43
  /**
12
44
  * Parses the given output and returns all the error messages.
13
45
  * @param {any} output - The output to parse for error messages.
@@ -5,12 +5,63 @@ Object.defineProperty(exports, "__esModule", { value: true });
5
5
  */
6
6
  const cboutputparsers = {
7
7
  /**
8
- * Initializes the output parser module.
9
- * Currently, this function does not perform any operations.
10
- * @param {any} output - The output to be initialized.
8
+ * Parses JSON string and returns a result object.
9
+ * @param {string} jsonString - The JSON string to parse.
10
+ * @returns {Object} An object with success flag and parsed data or error.
11
11
  */
12
- init: (output) => {
13
- // Initialization code can be added here if necessary
12
+ parseJSON: (jsonString) => {
13
+ try {
14
+ const parsed = JSON.parse(jsonString);
15
+ return { success: true, parsed };
16
+ }
17
+ catch (error) {
18
+ return { success: false, error: error };
19
+ }
20
+ },
21
+ /**
22
+ * Parses XML string and returns a result object.
23
+ * @param {string} xmlString - The XML string to parse.
24
+ * @returns {Object} An object with success flag and parsed data.
25
+ */
26
+ parseXML: (xmlString) => {
27
+ // Simple XML parsing - in a real implementation, would use a proper XML parser
28
+ const hasValidRoot = xmlString.trim().startsWith('<') && xmlString.trim().endsWith('>');
29
+ return {
30
+ success: hasValidRoot,
31
+ parsed: hasValidRoot ? { rootElement: xmlString } : undefined
32
+ };
33
+ },
34
+ /**
35
+ * Parses CSV string and returns a result object.
36
+ * @param {string} csvString - The CSV string to parse.
37
+ * @returns {Object} An object with success flag and parsed data or error.
38
+ */
39
+ parseCSV: (csvString) => {
40
+ try {
41
+ const lines = csvString.split('\n');
42
+ const headers = lines[0].split(',');
43
+ const results = lines.slice(1).map(line => {
44
+ const values = line.split(',');
45
+ const obj = {};
46
+ headers.forEach((header, index) => {
47
+ obj[header] = values[index];
48
+ });
49
+ return obj;
50
+ });
51
+ return { success: true, parsed: results };
52
+ }
53
+ catch (error) {
54
+ return { success: false, error: error };
55
+ }
56
+ },
57
+ /**
58
+ * Parses text string and returns a result object with lines.
59
+ * @param {string} text - The text to parse.
60
+ * @returns {Object} An object with success flag and parsed lines.
61
+ */
62
+ parseText: (text) => {
63
+ const lines = text ? text.split('\n') : [];
64
+ return { success: true, parsed: lines };
14
65
  },
15
66
  /**
16
67
  * Parses the given output and returns all the error messages.
@@ -4,11 +4,10 @@ import { GetProjectPathResponse } from '@codebolt/types';
4
4
  */
5
5
  declare const cbproject: {
6
6
  /**
7
- * Placeholder for a method to get project settings.
8
- * Currently, this method does not perform any operations.
9
- * @param {any} output - The output where project settings would be stored.
7
+ * Retrieves the project settings from the server.
8
+ * @returns {Promise<any>} A promise that resolves with the project settings response.
10
9
  */
11
- getProjectSettings: (output: any) => void;
10
+ getProjectSettings: () => Promise<any>;
12
11
  /**
13
12
  * Retrieves the path of the current project.
14
13
  * @returns {Promise<GetProjectPathResponse>} A promise that resolves with the project path response.
@@ -9,12 +9,14 @@ const websocket_1 = __importDefault(require("../core/websocket"));
9
9
  */
10
10
  const cbproject = {
11
11
  /**
12
- * Placeholder for a method to get project settings.
13
- * Currently, this method does not perform any operations.
14
- * @param {any} output - The output where project settings would be stored.
12
+ * Retrieves the project settings from the server.
13
+ * @returns {Promise<any>} A promise that resolves with the project settings response.
15
14
  */
16
- getProjectSettings: (output) => {
17
- // Implementation for getting project settings will be added here
15
+ getProjectSettings: () => {
16
+ return websocket_1.default.messageManager.sendAndWaitForResponse({
17
+ "type": "settingEvent",
18
+ "action": "getProjectSettings"
19
+ }, "getProjectSettingsResponse");
18
20
  },
19
21
  /**
20
22
  * Retrieves the path of the current project.