@codebolt/codeboltjs 1.1.70 → 1.1.73
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 +2 -0
- package/package.json +4 -2
- package/src/index.ts +3 -1
- package/webpack.config.js +1 -1
- package/docs/modules/_internal_.EventEmitter.html +0 -6
- package/docs/modules/_internal_.WebSocket.html +0 -21
- package/docs/modules/_internal_._node_stream_consumers_.html +0 -6
- package/docs/modules/_internal_._node_stream_promises_.html +0 -3
- package/docs/modules/_internal_.html +0 -228
- package/docs/modules/_internal_.internal.finished.html +0 -2
- package/docs/modules/_internal_.internal.html +0 -36
- package/docs/modules/_internal_.internal.pipeline.html +0 -2
- package/index.d.ts +0 -238
- package/modules/browser.d.ts +0 -108
- package/modules/browser.js +0 -331
- package/modules/chat.d.ts +0 -63
- package/modules/chat.js +0 -174
- package/modules/codeparsers.d.ts +0 -23
- package/modules/codeparsers.js +0 -30
- package/modules/codeutils.d.ts +0 -37
- package/modules/codeutils.js +0 -166
- package/modules/crawler.d.ts +0 -45
- package/modules/crawler.js +0 -123
- package/modules/dbmemory.d.ts +0 -20
- package/modules/dbmemory.js +0 -54
- package/modules/debug.d.ts +0 -23
- package/modules/debug.js +0 -64
- package/modules/docutils.d.ts +0 -12
- package/modules/docutils.js +0 -19
- package/modules/fs.d.ts +0 -94
- package/modules/fs.js +0 -264
- package/modules/git.d.ts +0 -76
- package/modules/git.js +0 -240
- package/modules/history.d.ts +0 -19
- package/modules/history.js +0 -46
- package/modules/knowledge.d.ts +0 -2
- package/modules/knowledge.js +0 -6
- package/modules/llm.d.ts +0 -18
- package/modules/llm.js +0 -39
- package/modules/outputparsers.d.ts +0 -24
- package/modules/outputparsers.js +0 -32
- package/modules/project.d.ts +0 -21
- package/modules/project.js +0 -72
- package/modules/rag.d.ts +0 -22
- package/modules/rag.js +0 -30
- package/modules/search.d.ts +0 -23
- package/modules/search.js +0 -37
- package/modules/state.d.ts +0 -21
- package/modules/state.js +0 -68
- package/modules/task.d.ts +0 -23
- package/modules/task.js +0 -75
- package/modules/terminal.d.ts +0 -46
- package/modules/terminal.js +0 -108
- package/modules/tokenizer.d.ts +0 -19
- package/modules/tokenizer.js +0 -56
- package/modules/vectordb.d.ts +0 -33
- package/modules/vectordb.js +0 -103
- package/modules/websocket.d.ts +0 -27
- package/modules/websocket.js +0 -88
- package/src/modules/browser.ts +0 -352
- package/src/modules/chat.ts +0 -182
- package/src/modules/codeparsers.ts +0 -30
- package/src/modules/codeutils.ts +0 -181
- package/src/modules/crawler.ts +0 -121
- package/src/modules/dbmemory.ts +0 -52
- package/src/modules/debug.ts +0 -68
- package/src/modules/docutils.ts +0 -18
- package/src/modules/fs.ts +0 -263
- package/src/modules/git.ts +0 -237
- package/src/modules/history.ts +0 -61
- package/src/modules/knowledge.ts +0 -5
- package/src/modules/llm.ts +0 -36
- package/src/modules/outputparsers.ts +0 -30
- package/src/modules/project.ts +0 -68
- package/src/modules/rag.ts +0 -28
- package/src/modules/search.ts +0 -35
- package/src/modules/state.ts +0 -69
- package/src/modules/task.ts +0 -73
- package/src/modules/terminal.ts +0 -114
- package/src/modules/tokenizer.ts +0 -56
- package/src/modules/vectordb.ts +0 -102
- package/src/modules/websocket.ts +0 -89
package/modules/dbmemory.d.ts
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import { MemorySetResponse, MemoryGetResponse } from '@codebolt/types';
|
|
2
|
-
/**
|
|
3
|
-
* A module for handling in-memory database operations via WebSocket.
|
|
4
|
-
*/
|
|
5
|
-
declare const dbmemory: {
|
|
6
|
-
/**
|
|
7
|
-
* Adds a key-value pair to the in-memory database.
|
|
8
|
-
* @param {string} key - The key under which to store the value.
|
|
9
|
-
* @param {any} value - The value to be stored.
|
|
10
|
-
* @returns {Promise<MemorySetResponse>} A promise that resolves with the response from the memory set event.
|
|
11
|
-
*/
|
|
12
|
-
addKnowledge: (key: string, value: any) => Promise<MemorySetResponse>;
|
|
13
|
-
/**
|
|
14
|
-
* Retrieves a value from the in-memory database by key.
|
|
15
|
-
* @param {string} key - The key of the value to retrieve.
|
|
16
|
-
* @returns {Promise<MemoryGetResponse>} A promise that resolves with the response from the memory get event.
|
|
17
|
-
*/
|
|
18
|
-
getKnowledge: (key: string) => Promise<MemoryGetResponse>;
|
|
19
|
-
};
|
|
20
|
-
export default dbmemory;
|
package/modules/dbmemory.js
DELETED
|
@@ -1,54 +0,0 @@
|
|
|
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
|
-
* A module for handling in-memory database operations via WebSocket.
|
|
9
|
-
*/
|
|
10
|
-
const dbmemory = {
|
|
11
|
-
/**
|
|
12
|
-
* Adds a key-value pair to the in-memory database.
|
|
13
|
-
* @param {string} key - The key under which to store the value.
|
|
14
|
-
* @param {any} value - The value to be stored.
|
|
15
|
-
* @returns {Promise<MemorySetResponse>} A promise that resolves with the response from the memory set event.
|
|
16
|
-
*/
|
|
17
|
-
addKnowledge: (key, value) => {
|
|
18
|
-
return new Promise((resolve, reject) => {
|
|
19
|
-
websocket_1.default.getWebsocket.send(JSON.stringify({
|
|
20
|
-
"type": "memoryEvent",
|
|
21
|
-
'action': 'set',
|
|
22
|
-
key,
|
|
23
|
-
value
|
|
24
|
-
}));
|
|
25
|
-
websocket_1.default.getWebsocket.on('message', (data) => {
|
|
26
|
-
const response = JSON.parse(data);
|
|
27
|
-
if (response.type === "memorySetResponse") {
|
|
28
|
-
resolve(response); // Resolve the Promise with the response data
|
|
29
|
-
}
|
|
30
|
-
});
|
|
31
|
-
});
|
|
32
|
-
},
|
|
33
|
-
/**
|
|
34
|
-
* Retrieves a value from the in-memory database by key.
|
|
35
|
-
* @param {string} key - The key of the value to retrieve.
|
|
36
|
-
* @returns {Promise<MemoryGetResponse>} A promise that resolves with the response from the memory get event.
|
|
37
|
-
*/
|
|
38
|
-
getKnowledge: (key) => {
|
|
39
|
-
return new Promise((resolve, reject) => {
|
|
40
|
-
websocket_1.default.getWebsocket.send(JSON.stringify({
|
|
41
|
-
"type": "memoryEvent",
|
|
42
|
-
'action': 'get',
|
|
43
|
-
key
|
|
44
|
-
}));
|
|
45
|
-
websocket_1.default.getWebsocket.on('message', (data) => {
|
|
46
|
-
const response = JSON.parse(data);
|
|
47
|
-
if (response.type === "memoryGetResponse") {
|
|
48
|
-
resolve(response); // Resolve the Promise with the response data
|
|
49
|
-
}
|
|
50
|
-
});
|
|
51
|
-
});
|
|
52
|
-
}
|
|
53
|
-
};
|
|
54
|
-
exports.default = dbmemory;
|
package/modules/debug.d.ts
DELETED
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import { DebugAddLogResponse, OpenDebugBrowserResponse } from '@codebolt/types';
|
|
2
|
-
export declare enum logType {
|
|
3
|
-
info = "info",
|
|
4
|
-
error = "error",
|
|
5
|
-
warning = "warning"
|
|
6
|
-
}
|
|
7
|
-
export declare const debug: {
|
|
8
|
-
/**
|
|
9
|
-
* Sends a log message to the debug websocket and waits for a response.
|
|
10
|
-
* @param {string} log - The log message to send.
|
|
11
|
-
* @param {logType} type - The type of the log message (info, error, warning).
|
|
12
|
-
* @returns {Promise<DebugAddLogResponse>} A promise that resolves with the response from the debug event.
|
|
13
|
-
*/
|
|
14
|
-
debug: (log: string, type: logType) => Promise<DebugAddLogResponse>;
|
|
15
|
-
/**
|
|
16
|
-
* Requests to open a debug browser at the specified URL and port.
|
|
17
|
-
* @param {string} url - The URL where the debug browser should be opened.
|
|
18
|
-
* @param {number} port - The port on which the debug browser will listen.
|
|
19
|
-
* @returns {Promise<OpenDebugBrowserResponse>} A promise that resolves with the response from the open debug browser event.
|
|
20
|
-
*/
|
|
21
|
-
openDebugBrowser: (url: string, port: number) => Promise<OpenDebugBrowserResponse>;
|
|
22
|
-
};
|
|
23
|
-
export default debug;
|
package/modules/debug.js
DELETED
|
@@ -1,64 +0,0 @@
|
|
|
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
|
-
exports.debug = exports.logType = void 0;
|
|
7
|
-
const websocket_1 = __importDefault(require("./websocket"));
|
|
8
|
-
var logType;
|
|
9
|
-
(function (logType) {
|
|
10
|
-
logType["info"] = "info";
|
|
11
|
-
logType["error"] = "error";
|
|
12
|
-
logType["warning"] = "warning";
|
|
13
|
-
})(logType || (exports.logType = logType = {}));
|
|
14
|
-
exports.debug = {
|
|
15
|
-
/**
|
|
16
|
-
* Sends a log message to the debug websocket and waits for a response.
|
|
17
|
-
* @param {string} log - The log message to send.
|
|
18
|
-
* @param {logType} type - The type of the log message (info, error, warning).
|
|
19
|
-
* @returns {Promise<DebugAddLogResponse>} A promise that resolves with the response from the debug event.
|
|
20
|
-
*/
|
|
21
|
-
debug: (log, type) => {
|
|
22
|
-
return new Promise((resolve, reject) => {
|
|
23
|
-
websocket_1.default.getWebsocket.send(JSON.stringify({
|
|
24
|
-
"type": "debugEvent",
|
|
25
|
-
"action": "addLog",
|
|
26
|
-
message: {
|
|
27
|
-
log,
|
|
28
|
-
type
|
|
29
|
-
}
|
|
30
|
-
}));
|
|
31
|
-
websocket_1.default.getWebsocket.on('message', (data) => {
|
|
32
|
-
const response = JSON.parse(data);
|
|
33
|
-
if (response.type === "debugEventResponse") {
|
|
34
|
-
resolve(response); // Resolve the Promise with the response data
|
|
35
|
-
}
|
|
36
|
-
});
|
|
37
|
-
});
|
|
38
|
-
},
|
|
39
|
-
/**
|
|
40
|
-
* Requests to open a debug browser at the specified URL and port.
|
|
41
|
-
* @param {string} url - The URL where the debug browser should be opened.
|
|
42
|
-
* @param {number} port - The port on which the debug browser will listen.
|
|
43
|
-
* @returns {Promise<OpenDebugBrowserResponse>} A promise that resolves with the response from the open debug browser event.
|
|
44
|
-
*/
|
|
45
|
-
openDebugBrowser: (url, port) => {
|
|
46
|
-
return new Promise((resolve, reject) => {
|
|
47
|
-
websocket_1.default.getWebsocket.send(JSON.stringify({
|
|
48
|
-
"type": "debugEvent",
|
|
49
|
-
"action": "openDebugBrowser",
|
|
50
|
-
message: {
|
|
51
|
-
url,
|
|
52
|
-
port
|
|
53
|
-
}
|
|
54
|
-
}));
|
|
55
|
-
websocket_1.default.getWebsocket.on('message', (data) => {
|
|
56
|
-
const response = JSON.parse(data);
|
|
57
|
-
if (response.type === "openDebugBrowserResponse") {
|
|
58
|
-
resolve(response); // Resolve the Promise with the response data
|
|
59
|
-
}
|
|
60
|
-
});
|
|
61
|
-
});
|
|
62
|
-
}
|
|
63
|
-
};
|
|
64
|
-
exports.default = exports.debug;
|
package/modules/docutils.d.ts
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* A module for document utility functions.
|
|
3
|
-
*/
|
|
4
|
-
declare const cbdocutils: {
|
|
5
|
-
/**
|
|
6
|
-
* Converts a PDF document to text.
|
|
7
|
-
* @param pdf_path - The file path to the PDF document to be converted.
|
|
8
|
-
* @returns {Promise<string>} A promise that resolves with the converted text.
|
|
9
|
-
*/
|
|
10
|
-
pdf_to_text: (pdf_path: any) => Promise<string>;
|
|
11
|
-
};
|
|
12
|
-
export default cbdocutils;
|
package/modules/docutils.js
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
/**
|
|
4
|
-
* A module for document utility functions.
|
|
5
|
-
*/
|
|
6
|
-
const cbdocutils = {
|
|
7
|
-
/**
|
|
8
|
-
* Converts a PDF document to text.
|
|
9
|
-
* @param pdf_path - The file path to the PDF document to be converted.
|
|
10
|
-
* @returns {Promise<string>} A promise that resolves with the converted text.
|
|
11
|
-
*/
|
|
12
|
-
pdf_to_text: (pdf_path) => {
|
|
13
|
-
// Implementation would go here
|
|
14
|
-
return new Promise((resolve, reject) => {
|
|
15
|
-
// PDF to text conversion logic
|
|
16
|
-
});
|
|
17
|
-
}
|
|
18
|
-
};
|
|
19
|
-
exports.default = cbdocutils;
|
package/modules/fs.d.ts
DELETED
|
@@ -1,94 +0,0 @@
|
|
|
1
|
-
import { CreateFileResponse, CreateFolderResponse, ReadFileResponse, UpdateFileResponse, DeleteFileResponse, DeleteFolderResponse } from '@codebolt/types';
|
|
2
|
-
/**
|
|
3
|
-
* @module cbfs
|
|
4
|
-
* @description This module provides functionality to interact with the filesystem.
|
|
5
|
-
*/
|
|
6
|
-
declare const cbfs: {
|
|
7
|
-
/**
|
|
8
|
-
* @function createFile
|
|
9
|
-
* @description Creates a new file.
|
|
10
|
-
* @param {string} fileName - The name of the file to create.
|
|
11
|
-
* @param {string} source - The source content to write into the file.
|
|
12
|
-
* @param {string} filePath - The path where the file should be created.
|
|
13
|
-
* @returns {Promise<CreateFileResponse>} A promise that resolves with the server response.
|
|
14
|
-
*/
|
|
15
|
-
createFile: (fileName: string, source: string, filePath: string) => Promise<CreateFileResponse>;
|
|
16
|
-
/**
|
|
17
|
-
* @function createFolder
|
|
18
|
-
* @description Creates a new folder.
|
|
19
|
-
* @param {string} folderName - The name of the folder to create.
|
|
20
|
-
* @param {string} folderPath - The path where the folder should be created.
|
|
21
|
-
* @returns {Promise<CreateFolderResponse>} A promise that resolves with the server response.
|
|
22
|
-
*/
|
|
23
|
-
createFolder: (folderName: string, folderPath: string) => Promise<CreateFolderResponse>;
|
|
24
|
-
/**
|
|
25
|
-
* @function readFile
|
|
26
|
-
* @description Reads the content of a file.
|
|
27
|
-
* @param {string} filename - The name of the file to read.
|
|
28
|
-
* @param {string} filePath - The path of the file to read.
|
|
29
|
-
* @returns {Promise<ReadFileResponse>} A promise that resolves with the server response.
|
|
30
|
-
*/
|
|
31
|
-
readFile: (filePath: string) => Promise<ReadFileResponse>;
|
|
32
|
-
/**
|
|
33
|
-
* @function updateFile
|
|
34
|
-
* @description Updates the content of a file.
|
|
35
|
-
* @param {string} filename - The name of the file to update.
|
|
36
|
-
* @param {string} filePath - The path of the file to update.
|
|
37
|
-
* @param {string} newContent - The new content to write into the file.
|
|
38
|
-
* @returns {Promise<UpdateFileResponse>} A promise that resolves with the server response.
|
|
39
|
-
*/
|
|
40
|
-
updateFile: (filename: string, filePath: string, newContent: string) => Promise<UpdateFileResponse>;
|
|
41
|
-
/**
|
|
42
|
-
* @function deleteFile
|
|
43
|
-
* @description Deletes a file.
|
|
44
|
-
* @param {string} filename - The name of the file to delete.
|
|
45
|
-
* @param {string} filePath - The path of the file to delete.
|
|
46
|
-
* @returns {Promise<DeleteFileResponse>} A promise that resolves with the server response.
|
|
47
|
-
*/
|
|
48
|
-
deleteFile: (filename: string, filePath: string) => Promise<DeleteFileResponse>;
|
|
49
|
-
/**
|
|
50
|
-
* @function deleteFolder
|
|
51
|
-
* @description Deletes a folder.
|
|
52
|
-
* @param {string} foldername - The name of the folder to delete.
|
|
53
|
-
* @param {string} folderpath - The path of the folder to delete.
|
|
54
|
-
* @returns {Promise<DeleteFolderResponse>} A promise that resolves with the server response.
|
|
55
|
-
*/
|
|
56
|
-
deleteFolder: (foldername: string, folderpath: string) => Promise<DeleteFolderResponse>;
|
|
57
|
-
/**
|
|
58
|
-
* @function listFile
|
|
59
|
-
* @description Lists all files.
|
|
60
|
-
* @returns {Promise<FileListResponse>} A promise that resolves with the list of files.
|
|
61
|
-
*/
|
|
62
|
-
listFile: (folderPath: string, isRecursive?: boolean) => Promise<unknown>;
|
|
63
|
-
/**
|
|
64
|
-
* @function listCodeDefinitionNames
|
|
65
|
-
* @description Lists all code definition names in a given path.
|
|
66
|
-
* @param {string} path - The path to search for code definitions.
|
|
67
|
-
* @returns {Promise<{success: boolean, result: any}>} A promise that resolves with the list of code definition names.
|
|
68
|
-
*/
|
|
69
|
-
listCodeDefinitionNames: (path: string) => Promise<{
|
|
70
|
-
success: boolean;
|
|
71
|
-
result: any;
|
|
72
|
-
}>;
|
|
73
|
-
/**
|
|
74
|
-
* @function searchFiles
|
|
75
|
-
* @description Searches files in a given path using a regex pattern.
|
|
76
|
-
* @param {string} path - The path to search within.
|
|
77
|
-
* @param {string} regex - The regex pattern to search for.
|
|
78
|
-
* @param {string} filePattern - The file pattern to match files.
|
|
79
|
-
* @returns {Promise<{success: boolean, result: any}>} A promise that resolves with the search results.
|
|
80
|
-
*/
|
|
81
|
-
searchFiles: (path: string, regex: string, filePattern: string) => Promise<{
|
|
82
|
-
success: boolean;
|
|
83
|
-
result: any;
|
|
84
|
-
}>;
|
|
85
|
-
/**
|
|
86
|
-
* @function writeToFile
|
|
87
|
-
* @description Writes content to a file.
|
|
88
|
-
* @param {string} relPath - The relative path of the file to write to.
|
|
89
|
-
* @param {string} newContent - The new content to write into the file.
|
|
90
|
-
* @returns {Promise<{success: boolean, result: any}>} A promise that resolves with the write operation result.
|
|
91
|
-
*/
|
|
92
|
-
writeToFile: (relPath: string, newContent: string) => Promise<unknown>;
|
|
93
|
-
};
|
|
94
|
-
export default cbfs;
|
package/modules/fs.js
DELETED
|
@@ -1,264 +0,0 @@
|
|
|
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
|
-
* @module cbfs
|
|
9
|
-
* @description This module provides functionality to interact with the filesystem.
|
|
10
|
-
*/
|
|
11
|
-
const cbfs = {
|
|
12
|
-
/**
|
|
13
|
-
* @function createFile
|
|
14
|
-
* @description Creates a new file.
|
|
15
|
-
* @param {string} fileName - The name of the file to create.
|
|
16
|
-
* @param {string} source - The source content to write into the file.
|
|
17
|
-
* @param {string} filePath - The path where the file should be created.
|
|
18
|
-
* @returns {Promise<CreateFileResponse>} A promise that resolves with the server response.
|
|
19
|
-
*/
|
|
20
|
-
createFile: (fileName, source, filePath) => {
|
|
21
|
-
return new Promise((resolve, reject) => {
|
|
22
|
-
websocket_1.default.getWebsocket.send(JSON.stringify({
|
|
23
|
-
"type": "fsEvent",
|
|
24
|
-
"action": "createFile",
|
|
25
|
-
"message": {
|
|
26
|
-
fileName,
|
|
27
|
-
source,
|
|
28
|
-
filePath
|
|
29
|
-
},
|
|
30
|
-
}));
|
|
31
|
-
websocket_1.default.getWebsocket.on('message', (data) => {
|
|
32
|
-
const response = JSON.parse(data);
|
|
33
|
-
if (response.type === "createFileResponse") {
|
|
34
|
-
resolve(response);
|
|
35
|
-
}
|
|
36
|
-
});
|
|
37
|
-
});
|
|
38
|
-
},
|
|
39
|
-
/**
|
|
40
|
-
* @function createFolder
|
|
41
|
-
* @description Creates a new folder.
|
|
42
|
-
* @param {string} folderName - The name of the folder to create.
|
|
43
|
-
* @param {string} folderPath - The path where the folder should be created.
|
|
44
|
-
* @returns {Promise<CreateFolderResponse>} A promise that resolves with the server response.
|
|
45
|
-
*/
|
|
46
|
-
createFolder: (folderName, folderPath) => {
|
|
47
|
-
return new Promise((resolve, reject) => {
|
|
48
|
-
websocket_1.default.getWebsocket.send(JSON.stringify({
|
|
49
|
-
"type": "fsEvent",
|
|
50
|
-
"action": "createFolder",
|
|
51
|
-
"message": {
|
|
52
|
-
folderName,
|
|
53
|
-
folderPath
|
|
54
|
-
},
|
|
55
|
-
}));
|
|
56
|
-
websocket_1.default.getWebsocket.on('message', (data) => {
|
|
57
|
-
const response = JSON.parse(data);
|
|
58
|
-
if (response.type === "createFolderResponse") {
|
|
59
|
-
resolve(response);
|
|
60
|
-
}
|
|
61
|
-
});
|
|
62
|
-
});
|
|
63
|
-
},
|
|
64
|
-
/**
|
|
65
|
-
* @function readFile
|
|
66
|
-
* @description Reads the content of a file.
|
|
67
|
-
* @param {string} filename - The name of the file to read.
|
|
68
|
-
* @param {string} filePath - The path of the file to read.
|
|
69
|
-
* @returns {Promise<ReadFileResponse>} A promise that resolves with the server response.
|
|
70
|
-
*/
|
|
71
|
-
readFile: (filePath) => {
|
|
72
|
-
return new Promise((resolve, reject) => {
|
|
73
|
-
websocket_1.default.getWebsocket.send(JSON.stringify({
|
|
74
|
-
"type": "fsEvent",
|
|
75
|
-
"action": "readFile",
|
|
76
|
-
"message": {
|
|
77
|
-
filePath
|
|
78
|
-
},
|
|
79
|
-
}));
|
|
80
|
-
websocket_1.default.getWebsocket.on('message', (data) => {
|
|
81
|
-
const response = JSON.parse(data);
|
|
82
|
-
if (response.type === "readFileResponse") {
|
|
83
|
-
resolve(response);
|
|
84
|
-
}
|
|
85
|
-
});
|
|
86
|
-
});
|
|
87
|
-
},
|
|
88
|
-
/**
|
|
89
|
-
* @function updateFile
|
|
90
|
-
* @description Updates the content of a file.
|
|
91
|
-
* @param {string} filename - The name of the file to update.
|
|
92
|
-
* @param {string} filePath - The path of the file to update.
|
|
93
|
-
* @param {string} newContent - The new content to write into the file.
|
|
94
|
-
* @returns {Promise<UpdateFileResponse>} A promise that resolves with the server response.
|
|
95
|
-
*/
|
|
96
|
-
updateFile: (filename, filePath, newContent) => {
|
|
97
|
-
return new Promise((resolve, reject) => {
|
|
98
|
-
websocket_1.default.getWebsocket.send(JSON.stringify({
|
|
99
|
-
"type": "fsEvent",
|
|
100
|
-
"action": "updateFile",
|
|
101
|
-
"message": {
|
|
102
|
-
filename,
|
|
103
|
-
filePath,
|
|
104
|
-
newContent
|
|
105
|
-
},
|
|
106
|
-
}));
|
|
107
|
-
websocket_1.default.getWebsocket.on('message', (data) => {
|
|
108
|
-
const response = JSON.parse(data);
|
|
109
|
-
if (response.type === "commandOutput") {
|
|
110
|
-
resolve(response);
|
|
111
|
-
}
|
|
112
|
-
});
|
|
113
|
-
});
|
|
114
|
-
},
|
|
115
|
-
/**
|
|
116
|
-
* @function deleteFile
|
|
117
|
-
* @description Deletes a file.
|
|
118
|
-
* @param {string} filename - The name of the file to delete.
|
|
119
|
-
* @param {string} filePath - The path of the file to delete.
|
|
120
|
-
* @returns {Promise<DeleteFileResponse>} A promise that resolves with the server response.
|
|
121
|
-
*/
|
|
122
|
-
deleteFile: (filename, filePath) => {
|
|
123
|
-
return new Promise((resolve, reject) => {
|
|
124
|
-
websocket_1.default.getWebsocket.send(JSON.stringify({
|
|
125
|
-
"type": "fsEvent",
|
|
126
|
-
"action": "deleteFile",
|
|
127
|
-
"message": {
|
|
128
|
-
filename,
|
|
129
|
-
filePath
|
|
130
|
-
},
|
|
131
|
-
}));
|
|
132
|
-
websocket_1.default.getWebsocket.on('message', (data) => {
|
|
133
|
-
const response = JSON.parse(data);
|
|
134
|
-
if (response.type === "deleteFileResponse") {
|
|
135
|
-
resolve(response);
|
|
136
|
-
}
|
|
137
|
-
});
|
|
138
|
-
});
|
|
139
|
-
},
|
|
140
|
-
/**
|
|
141
|
-
* @function deleteFolder
|
|
142
|
-
* @description Deletes a folder.
|
|
143
|
-
* @param {string} foldername - The name of the folder to delete.
|
|
144
|
-
* @param {string} folderpath - The path of the folder to delete.
|
|
145
|
-
* @returns {Promise<DeleteFolderResponse>} A promise that resolves with the server response.
|
|
146
|
-
*/
|
|
147
|
-
deleteFolder: (foldername, folderpath) => {
|
|
148
|
-
return new Promise((resolve, reject) => {
|
|
149
|
-
websocket_1.default.getWebsocket.send(JSON.stringify({
|
|
150
|
-
"type": "fsEvent",
|
|
151
|
-
"action": "deleteFolder",
|
|
152
|
-
"message": {
|
|
153
|
-
foldername,
|
|
154
|
-
folderpath
|
|
155
|
-
},
|
|
156
|
-
}));
|
|
157
|
-
websocket_1.default.getWebsocket.on('message', (data) => {
|
|
158
|
-
const response = JSON.parse(data);
|
|
159
|
-
if (response.type === "deleteFolderResponse") {
|
|
160
|
-
resolve(response);
|
|
161
|
-
}
|
|
162
|
-
});
|
|
163
|
-
});
|
|
164
|
-
},
|
|
165
|
-
/**
|
|
166
|
-
* @function listFile
|
|
167
|
-
* @description Lists all files.
|
|
168
|
-
* @returns {Promise<FileListResponse>} A promise that resolves with the list of files.
|
|
169
|
-
*/
|
|
170
|
-
listFile: (folderPath, isRecursive = false) => {
|
|
171
|
-
return new Promise((resolve, reject) => {
|
|
172
|
-
websocket_1.default.getWebsocket.send(JSON.stringify({
|
|
173
|
-
"type": "fsEvent",
|
|
174
|
-
"action": "fileList",
|
|
175
|
-
message: {
|
|
176
|
-
folderPath,
|
|
177
|
-
isRecursive
|
|
178
|
-
}
|
|
179
|
-
}));
|
|
180
|
-
websocket_1.default.getWebsocket.on('message', (data) => {
|
|
181
|
-
const response = JSON.parse(data);
|
|
182
|
-
if (response.type === "fileListResponse") {
|
|
183
|
-
resolve(response);
|
|
184
|
-
}
|
|
185
|
-
});
|
|
186
|
-
});
|
|
187
|
-
},
|
|
188
|
-
/**
|
|
189
|
-
* @function listCodeDefinitionNames
|
|
190
|
-
* @description Lists all code definition names in a given path.
|
|
191
|
-
* @param {string} path - The path to search for code definitions.
|
|
192
|
-
* @returns {Promise<{success: boolean, result: any}>} A promise that resolves with the list of code definition names.
|
|
193
|
-
*/
|
|
194
|
-
listCodeDefinitionNames: (path) => {
|
|
195
|
-
return new Promise((resolve, reject) => {
|
|
196
|
-
websocket_1.default.getWebsocket.send(JSON.stringify({
|
|
197
|
-
"type": "fsEvent",
|
|
198
|
-
"action": "listCodeDefinitionNames",
|
|
199
|
-
"message": {
|
|
200
|
-
path
|
|
201
|
-
}
|
|
202
|
-
}));
|
|
203
|
-
websocket_1.default.getWebsocket.on('message', (data) => {
|
|
204
|
-
const response = JSON.parse(data);
|
|
205
|
-
if (response.type === "listCodeDefinitionNamesResponse") {
|
|
206
|
-
resolve(response);
|
|
207
|
-
}
|
|
208
|
-
});
|
|
209
|
-
});
|
|
210
|
-
},
|
|
211
|
-
/**
|
|
212
|
-
* @function searchFiles
|
|
213
|
-
* @description Searches files in a given path using a regex pattern.
|
|
214
|
-
* @param {string} path - The path to search within.
|
|
215
|
-
* @param {string} regex - The regex pattern to search for.
|
|
216
|
-
* @param {string} filePattern - The file pattern to match files.
|
|
217
|
-
* @returns {Promise<{success: boolean, result: any}>} A promise that resolves with the search results.
|
|
218
|
-
*/
|
|
219
|
-
searchFiles: (path, regex, filePattern) => {
|
|
220
|
-
return new Promise((resolve, reject) => {
|
|
221
|
-
websocket_1.default.getWebsocket.send(JSON.stringify({
|
|
222
|
-
"type": "fsEvent",
|
|
223
|
-
"action": "searchFiles",
|
|
224
|
-
"message": {
|
|
225
|
-
path,
|
|
226
|
-
regex,
|
|
227
|
-
filePattern
|
|
228
|
-
}
|
|
229
|
-
}));
|
|
230
|
-
websocket_1.default.getWebsocket.on('message', (data) => {
|
|
231
|
-
const response = JSON.parse(data);
|
|
232
|
-
if (response.type === "searchFilesResponse") {
|
|
233
|
-
resolve(response);
|
|
234
|
-
}
|
|
235
|
-
});
|
|
236
|
-
});
|
|
237
|
-
},
|
|
238
|
-
/**
|
|
239
|
-
* @function writeToFile
|
|
240
|
-
* @description Writes content to a file.
|
|
241
|
-
* @param {string} relPath - The relative path of the file to write to.
|
|
242
|
-
* @param {string} newContent - The new content to write into the file.
|
|
243
|
-
* @returns {Promise<{success: boolean, result: any}>} A promise that resolves with the write operation result.
|
|
244
|
-
*/
|
|
245
|
-
writeToFile: (relPath, newContent) => {
|
|
246
|
-
return new Promise((resolve, reject) => {
|
|
247
|
-
websocket_1.default.getWebsocket.send(JSON.stringify({
|
|
248
|
-
"type": "fsEvent",
|
|
249
|
-
"action": "writeToFile",
|
|
250
|
-
"message": {
|
|
251
|
-
relPath,
|
|
252
|
-
newContent
|
|
253
|
-
}
|
|
254
|
-
}));
|
|
255
|
-
websocket_1.default.getWebsocket.on('message', (data) => {
|
|
256
|
-
const response = JSON.parse(data);
|
|
257
|
-
if (response.type === "writeToFileResponse") {
|
|
258
|
-
resolve(response);
|
|
259
|
-
}
|
|
260
|
-
});
|
|
261
|
-
});
|
|
262
|
-
},
|
|
263
|
-
};
|
|
264
|
-
exports.default = cbfs;
|
package/modules/git.d.ts
DELETED
|
@@ -1,76 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* A service for interacting with Git operations via WebSocket messages.
|
|
3
|
-
*/
|
|
4
|
-
declare const gitService: {
|
|
5
|
-
/**
|
|
6
|
-
* Initializes a new Git repository at the given path.
|
|
7
|
-
* @param {string} path - The file system path where the Git repository should be initialized.
|
|
8
|
-
* @returns {Promise<any>} A promise that resolves with the response from the init event.
|
|
9
|
-
*/
|
|
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
|
-
/**
|
|
19
|
-
* Pulls the latest changes from the remote repository to the local repository at the given path.
|
|
20
|
-
* @param {string} path - The file system path of the local Git repository.
|
|
21
|
-
* @returns {Promise<any>} A promise that resolves with the response from the pull event.
|
|
22
|
-
*/
|
|
23
|
-
pull: (path: string) => Promise<any>;
|
|
24
|
-
/**
|
|
25
|
-
* Pushes local repository changes to the remote repository at the given path.
|
|
26
|
-
* @param {string} path - The file system path of the local Git repository.
|
|
27
|
-
* @returns {Promise<any>} A promise that resolves with the response from the push event.
|
|
28
|
-
*/
|
|
29
|
-
push: (path: string) => Promise<any>;
|
|
30
|
-
/**
|
|
31
|
-
* Retrieves the status of the local repository at the given path.
|
|
32
|
-
* @param {string} path - The file system path of the local Git repository.
|
|
33
|
-
* @returns {Promise<any>} A promise that resolves with the response from the status event.
|
|
34
|
-
*/
|
|
35
|
-
status: (path: string) => Promise<any>;
|
|
36
|
-
/**
|
|
37
|
-
* Adds changes in the local repository to the staging area at the given path.
|
|
38
|
-
* @param {string} path - The file system path of the local Git repository.
|
|
39
|
-
* @returns {Promise<any>} A promise that resolves with the response from the add event.
|
|
40
|
-
*/
|
|
41
|
-
add: (path: string) => Promise<any>;
|
|
42
|
-
/**
|
|
43
|
-
* Commits the staged changes in the local repository with the given commit message.
|
|
44
|
-
* @param {string} message - The commit message to use for the commit.
|
|
45
|
-
* @returns {Promise<any>} A promise that resolves with the response from the commit event.
|
|
46
|
-
*/
|
|
47
|
-
commit: (message: string) => Promise<any>;
|
|
48
|
-
/**
|
|
49
|
-
* Checks out a branch or commit in the local repository at the given path.
|
|
50
|
-
* @param {string} path - The file system path of the local Git repository.
|
|
51
|
-
* @param {string} branch - The name of the branch or commit to check out.
|
|
52
|
-
* @returns {Promise<any>} A promise that resolves with the response from the checkout event.
|
|
53
|
-
*/
|
|
54
|
-
checkout: (path: string, branch: string) => Promise<any>;
|
|
55
|
-
/**
|
|
56
|
-
* Creates a new branch in the local repository at the given path.
|
|
57
|
-
* @param {string} path - The file system path of the local Git repository.
|
|
58
|
-
* @param {string} branch - The name of the new branch to create.
|
|
59
|
-
* @returns {Promise<any>} A promise that resolves with the response from the branch event.
|
|
60
|
-
*/
|
|
61
|
-
branch: (path: string, branch: string) => Promise<any>;
|
|
62
|
-
/**
|
|
63
|
-
* Retrieves the commit logs for the local repository at the given path.
|
|
64
|
-
* @param {string} path - The file system path of the local Git repository.
|
|
65
|
-
* @returns {Promise<any>} A promise that resolves with the response from the logs event.
|
|
66
|
-
*/
|
|
67
|
-
logs: (path: string) => Promise<any>;
|
|
68
|
-
/**
|
|
69
|
-
* Retrieves the diff of changes for a specific commit in the local repository.
|
|
70
|
-
* @param {string} commitHash - The hash of the commit to retrieve the diff for.
|
|
71
|
-
* @param {string} path - The file system path of the local Git repository.
|
|
72
|
-
* @returns {Promise<any>} A promise that resolves with the response from the diff event.
|
|
73
|
-
*/
|
|
74
|
-
diff: (commitHash: string, path: string) => Promise<any>;
|
|
75
|
-
};
|
|
76
|
-
export default gitService;
|