@@ -182,6 +182,57 @@ const cbfs = {
182
182
} ) ;
183
183
} ) ;
184
184
} ,
185
+ /**
186
+ * @function listCodeDefinitionNames
187
+ * @description Lists all code definition names in a given path.
188
+ * @param {string } path - The path to search for code definitions.
189
+ * @returns {Promise<{success: boolean, result: any}> } A promise that resolves with the list of code definition names.
190
+ */
191
+ listCodeDefinitionNames : ( path : string ) : Promise < { success : boolean , result : any } > => {
192
+ return new Promise ( ( resolve , reject ) => {
193
+ cbws . getWebsocket . send ( JSON . stringify ( {
194
+ "type" : "fsEvent" ,
195
+ "action" : "listCodeDefinitionNames" ,
196
+ "message" : {
197
+ path
198
+ }
199
+ } ) ) ;
200
+ cbws . getWebsocket . on ( 'message' , ( data : string ) => {
201
+ const response = JSON . parse ( data ) ;
202
+ if ( response . type === "listCodeDefinitionNamesResponse" ) {
203
+ resolve ( response ) ;
204
+ }
205
+ } ) ;
206
+ } ) ;
207
+ } ,
208
+
209
+ /**
210
+ * @function searchFiles
211
+ * @description Searches files in a given path using a regex pattern.
212
+ * @param {string } path - The path to search within.
213
+ * @param {string } regex - The regex pattern to search for.
214
+ * @param {string } filePattern - The file pattern to match files.
215
+ * @returns {Promise<{success: boolean, result: any}> } A promise that resolves with the search results.
216
+ */
217
+ searchFiles : ( path : string , regex : string , filePattern : string ) : Promise < { success : boolean , result : any } > => {
218
+ return new Promise ( ( resolve , reject ) => {
219
+ cbws . getWebsocket . send ( JSON . stringify ( {
220
+ "type" : "fsEvent" ,
221
+ "action" : "searchFiles" ,
222
+ "message" : {
223
+ path,
224
+ regex,
225
+ filePattern
226
+ }
227
+ } ) ) ;
228
+ cbws . getWebsocket . on ( 'message' , ( data : string ) => {
229
+ const response = JSON . parse ( data ) ;
230
+ if ( response . type === "searchFilesResponse" ) {
231
+ resolve ( response ) ;
232
+ }
233
+ } ) ;
234
+ } ) ;
235
+ } ,
185
236
186
237
} ;
187
238
0 commit comments