11import * as vscode from "vscode" ;
22import * as _ from "lodash" ;
3- import http from "../../http/requests" ;
3+
44import DeepCode from "../../../interfaces/DeepCodeInterfaces" ;
55import { IQueueAnalysisCheckResult } from "@deepcode/tsc" ;
66import { checkIfBundleIsEmpty } from "../../utils/bundlesUtils" ;
@@ -17,8 +17,7 @@ abstract class BundlesModule extends LoginModule
1717 runningAnalysis = false ;
1818
1919 files : string [ ] = [ ] ;
20- serviceAI = http . getServiceAI ( ) ;
21-
20+
2221 constructor ( ) {
2322 super ( ) ;
2423
@@ -30,7 +29,30 @@ abstract class BundlesModule extends LoginModule
3029 this . onAnalyseFinish = this . onAnalyseFinish . bind ( this ) ;
3130 this . onError = this . onError . bind ( this ) ;
3231
33- this . serviceAI . on ( BUNDLE_EVENTS . error , this . onError ) ;
32+ this . serviceAI . on ( BUNDLE_EVENTS . buildBundleProgress , ( processed : number , total : number ) => {
33+ this . onBuildBundleProgress ( processed , total ) ;
34+ } ) ;
35+ this . serviceAI . on ( BUNDLE_EVENTS . buildBundleFinish , ( ) => {
36+ this . onBuildBundleFinish ( ) ;
37+ } ) ;
38+ this . serviceAI . on ( BUNDLE_EVENTS . uploadBundleProgress , ( processed : number , total : number ) => {
39+ this . onUploadBundleProgress ( processed , total ) ;
40+ } ) ;
41+ this . serviceAI . on ( BUNDLE_EVENTS . uploadFilesFinish , ( ) => {
42+ this . onUploadBundleFinish ( ) ;
43+ } ) ;
44+ this . serviceAI . on ( BUNDLE_EVENTS . analyseProgress , ( analysisResults : IQueueAnalysisCheckResult ) => {
45+ this . onAnalyseProgress ( analysisResults ) ;
46+ } ) ;
47+ this . serviceAI . on (
48+ BUNDLE_EVENTS . analyseFinish ,
49+ ( analysisResults : IQueueAnalysisCheckResult ) => {
50+ this . onAnalyseFinish ( analysisResults ) ;
51+ }
52+ ) ;
53+ this . serviceAI . on ( BUNDLE_EVENTS . error , ( error : Error ) => {
54+ this . onError ( error ) ;
55+ } ) ;
3456 }
3557
3658 updateStatus ( status : string , progress ?: number ) {
@@ -134,7 +156,10 @@ abstract class BundlesModule extends LoginModule
134156 // procesing filter list of files, acceptable for server
135157 public async createFilesFilterList ( ) : Promise < void > {
136158 try {
137- this . serverFilesFilterList = await http . getFilters ( this . baseURL , this . token ) ;
159+ this . serverFilesFilterList = await this . serviceAI . getFilters ( {
160+ baseURL : this . baseURL ,
161+ sessionToken : this . token
162+ } ) ;
138163 } catch ( err ) {
139164 await this . processError ( err , {
140165 message : errorsLogs . filtersFiles
@@ -165,53 +190,35 @@ abstract class BundlesModule extends LoginModule
165190 this . filesWatcher . activate ( this ) ;
166191 }
167192
168- if ( ! this . token || ! this . uploadApproved ) {
193+ if ( ! this . token ) {
169194 await this . checkSession ( ) ;
195+ return ;
196+ }
197+
198+ if ( ! this . uploadApproved ) {
170199 await this . checkApproval ( ) ;
171200 return ;
172201 }
173202
174- const bundle = await this . startCollectingFiles ( path , this . serverFilesFilterList ) ;
203+ const bundle = await this . startCollectingFiles ( path ) ;
175204 const removedFiles = ( this . files || [ ] ) . filter ( f => ! bundle . includes ( f ) ) ;
176205 this . files = bundle ;
177206
178- this . serviceAI . on ( BUNDLE_EVENTS . buildBundleProgress , ( processed : number , total : number ) => {
179- this . onBuildBundleProgress ( processed , total ) ;
180- } ) ;
181- this . serviceAI . on ( BUNDLE_EVENTS . buildBundleFinish , ( ) => {
182- this . onBuildBundleFinish ( ) ;
183- } ) ;
184- this . serviceAI . on ( BUNDLE_EVENTS . uploadBundleProgress , ( processed : number , total : number ) => {
185- this . onUploadBundleProgress ( processed , total ) ;
186- } ) ;
187- this . serviceAI . on ( BUNDLE_EVENTS . uploadFilesFinish , ( ) => {
188- this . onUploadBundleFinish ( ) ;
189- } ) ;
190- this . serviceAI . on ( BUNDLE_EVENTS . analyseProgress , ( analysisResults : IQueueAnalysisCheckResult ) => {
191- this . onAnalyseProgress ( analysisResults ) ;
192- } ) ;
193- this . serviceAI . on (
194- BUNDLE_EVENTS . analyseFinish ,
195- ( analysisResults : IQueueAnalysisCheckResult ) => {
196- this . onAnalyseFinish ( analysisResults ) ;
197- }
198- ) ;
199- this . serviceAI . on ( BUNDLE_EVENTS . error , ( error : Error ) => {
200- this . onError ( error ) ;
201- } ) ;
202-
203- http . analyse ( this . baseURL , this . token , path , this . files , removedFiles ) . catch (
207+ this . serviceAI . analyse ( {
208+ baseURL : this . baseURL ,
209+ sessionToken : this . token ,
210+ baseDir : path ,
211+ files : this . files ,
212+ removedFiles : removedFiles
213+ } ) . catch (
204214 // no need to wait for processError since catch is called asynchronously as well
205215 ( error ) => this . processError ( error , {
206216 message : errorsLogs . analyse
207217 } )
208218 ) ;
209219 }
210220
211- private async startCollectingFiles (
212- folderPath : string ,
213- serverFilesFilterList : DeepCode . AllowedServerFilterListInterface
214- ) : Promise < string [ ] > {
221+ private async startCollectingFiles ( folderPath : string ) : Promise < string [ ] > {
215222 this . updateStatus ( DEEPCODE_ANALYSIS_STATUS . COLLECTING , 0 ) ;
216223 console . log ( "COLLECTING" ) ;
217224 const bundle = await createListOfDirFiles ( {
0 commit comments