11import cbws from './websocket' ;
22import { EventEmitter } from 'events' ;
3-
3+ import { CommandError , CommandFinish , CommandOutput , TerminalInterruptResponse , TerminalInterrupted } from '@codebolt/types' ;
44/**
55 * CustomEventEmitter class that extends the Node.js EventEmitter class.
66 */
@@ -17,9 +17,9 @@ const cbterminal = {
1717 * of the executed command and resolves the promise accordingly.
1818 *
1919 * @param {string } command - The command to be executed.
20- * @returns {Promise<any > } A promise that resolves with the command's output, error, or finish signal.
20+ * @returns {Promise<CommandOutput|CommandError > } A promise that resolves with the command's output, error, or finish signal.
2121 */
22- executeCommand : async ( command : string ) : Promise < any > => {
22+ executeCommand : async ( command : string ) : Promise < CommandOutput | CommandError > => {
2323 return new Promise ( ( resolve , reject ) => {
2424 cbws . getWebsocket . send ( JSON . stringify ( {
2525 "type" : "executeCommand" ,
@@ -39,9 +39,9 @@ const cbterminal = {
3939 * Listens for messages from the WebSocket and resolves the promise when an error is encountered.
4040 *
4141 * @param {string } command - The command to be executed.
42- * @returns {Promise<any > } A promise that resolves when an error occurs during command execution.
42+ * @returns {Promise<CommandError > } A promise that resolves when an error occurs during command execution.
4343 */
44- executeCommandRunUntilError : async ( command : string ) : Promise < any > => {
44+ executeCommandRunUntilError : async ( command : string ) : Promise < CommandError > => {
4545 return new Promise ( ( resolve , reject ) => {
4646 cbws . getWebsocket . send ( JSON . stringify ( {
4747 "type" : "executeCommandRunUntilError" ,
@@ -60,9 +60,9 @@ const cbterminal = {
6060 /**
6161 * Sends a manual interrupt signal to the terminal.
6262 *
63- * @returns {void }
63+ * @returns {Promise<TerminalInterruptResponse> }
6464 */
65- sendManualInterrupt ( ) : Promise < any > {
65+ sendManualInterrupt ( ) : Promise < TerminalInterruptResponse > {
6666
6767 return new Promise ( ( resolve , reject ) => {
6868 cbws . getWebsocket . send ( JSON . stringify ( {
@@ -82,9 +82,9 @@ const cbterminal = {
8282 * Listens for messages from the WebSocket and streams the output data.
8383 *
8484 * @param {string } command - The command to be executed.
85- * @returns {Promise<any> } A promise that streams the output data during command execution.
85+ * @returns {EventEmitter } A promise that streams the output data during command execution.
8686 */
87- executeCommandWithStream ( command : string ) {
87+ executeCommandWithStream ( command : string ) : EventEmitter {
8888 // Send the process started message
8989 cbws . getWebsocket . send ( JSON . stringify ( {
9090 "type" : "executeCommandWithStream" ,
0 commit comments