@@ -82,11 +82,14 @@ export interface RunResultsEventData {
82
82
}
83
83
84
84
/**
85
- * DBTIntegrationAdapter provides a framework-agnostic implementation of DBTFacade
85
+ * DBTProjectIntegrationAdapter provides a framework-agnostic implementation of DBTFacade
86
86
* that delegates to the appropriate dbt integration (core, cloud, fusion, corecommand)
87
87
* based on configuration. This class has no VSCode dependencies.
88
88
*/
89
- export class DBTIntegrationAdapter extends EventEmitter implements DBTFacade {
89
+ export class DBTProjectIntegrationAdapter
90
+ extends EventEmitter
91
+ implements DBTFacade
92
+ {
90
93
private currentIntegration : DBTProjectIntegration ;
91
94
private consecutiveReadFailures = 0 ;
92
95
private sourceFileWatchers : FSWatcher [ ] = [ ] ;
@@ -283,7 +286,7 @@ export class DBTIntegrationAdapter extends EventEmitter implements DBTFacade {
283
286
284
287
async refreshProjectConfig ( ) : Promise < void > {
285
288
this . terminal . debug (
286
- "DBTIntegrationAdapter " ,
289
+ "DBTProjectIntegrationAdapter " ,
287
290
`Going to refresh the project "${ this . getProjectName ( ) } " at ${
288
291
this . projectRoot
289
292
} configuration`,
@@ -327,7 +330,7 @@ export class DBTIntegrationAdapter extends EventEmitter implements DBTFacade {
327
330
}
328
331
329
332
this . terminal . debug (
330
- "DBTIntegrationAdapter " ,
333
+ "DBTProjectIntegrationAdapter " ,
331
334
`An error occurred while trying to refresh the project "${ this . getProjectName ( ) } " at ${
332
335
this . projectRoot
333
336
} configuration`,
@@ -346,7 +349,7 @@ export class DBTIntegrationAdapter extends EventEmitter implements DBTFacade {
346
349
347
350
if ( sourcePaths && macroPaths && seedPaths ) {
348
351
this . terminal . debug (
349
- "DBTIntegrationAdapter " ,
352
+ "DBTProjectIntegrationAdapter " ,
350
353
`Project config refreshed successfully for "${ this . getProjectName ( ) } " at ${
351
354
this . projectRoot
352
355
} `,
@@ -367,15 +370,15 @@ export class DBTIntegrationAdapter extends EventEmitter implements DBTFacade {
367
370
) ;
368
371
} else {
369
372
this . terminal . warn (
370
- "DBTIntegrationAdapter " ,
373
+ "DBTProjectIntegrationAdapter " ,
371
374
"Could not complete project config refresh because project is not initialized properly. dbt path settings cannot be determined" ,
372
375
) ;
373
376
}
374
377
}
375
378
376
379
async rebuildManifest ( ) : Promise < void > {
377
380
this . terminal . debug (
378
- "DBTIntegrationAdapter " ,
381
+ "DBTProjectIntegrationAdapter " ,
379
382
`Going to rebuild the manifest for project at ${ this . projectRoot } ` ,
380
383
) ;
381
384
@@ -390,15 +393,15 @@ export class DBTIntegrationAdapter extends EventEmitter implements DBTFacade {
390
393
if ( ! this . depsInitialized && installDepsOnProjectInitialization ) {
391
394
try {
392
395
this . terminal . debug (
393
- "DBTIntegrationAdapter " ,
396
+ "DBTProjectIntegrationAdapter " ,
394
397
"Installing dbt dependencies before first manifest rebuild" ,
395
398
) ;
396
399
await this . installDeps ( true ) ;
397
400
this . depsInitialized = true ;
398
401
} catch ( error : any ) {
399
402
// this is best effort
400
403
this . terminal . warn (
401
- "DBTIntegrationAdapter " ,
404
+ "DBTProjectIntegrationAdapter " ,
402
405
"An error occurred while installing dependencies" ,
403
406
error ,
404
407
) ;
@@ -408,7 +411,7 @@ export class DBTIntegrationAdapter extends EventEmitter implements DBTFacade {
408
411
try {
409
412
await this . currentIntegration . rebuildManifest ( ) ;
410
413
this . terminal . debug (
411
- "DBTIntegrationAdapter " ,
414
+ "DBTProjectIntegrationAdapter " ,
412
415
`Finished rebuilding the manifest for project at ${ this . projectRoot } ` ,
413
416
) ;
414
417
@@ -419,7 +422,7 @@ export class DBTIntegrationAdapter extends EventEmitter implements DBTFacade {
419
422
}
420
423
} catch ( error ) {
421
424
this . terminal . error (
422
- "DBTIntegrationAdapter " ,
425
+ "DBTProjectIntegrationAdapter " ,
423
426
"Error rebuilding manifest" ,
424
427
error ,
425
428
) ;
@@ -434,14 +437,14 @@ export class DBTIntegrationAdapter extends EventEmitter implements DBTFacade {
434
437
435
438
async parseManifest ( ) : Promise < ParsedManifest | undefined > {
436
439
this . terminal . debug (
437
- "DBTIntegrationAdapter " ,
440
+ "DBTProjectIntegrationAdapter " ,
438
441
`Going to parse manifest for project at ${ this . projectRoot } ` ,
439
442
) ;
440
443
441
444
const targetPath = this . getTargetPath ( ) ;
442
445
if ( ! targetPath ) {
443
446
this . terminal . debug (
444
- "DBTIntegrationAdapter " ,
447
+ "DBTProjectIntegrationAdapter " ,
445
448
"targetPath should be defined at this stage for project " +
446
449
this . projectRoot ,
447
450
) ;
@@ -542,7 +545,7 @@ export class DBTIntegrationAdapter extends EventEmitter implements DBTFacade {
542
545
const manifestLocation = path . join ( ...pathParts , MANIFEST_FILE ) ;
543
546
544
547
this . terminal . debug (
545
- "DBTIntegrationAdapter " ,
548
+ "DBTProjectIntegrationAdapter " ,
546
549
`Reading manifest at ${ manifestLocation } for project at ${ this . projectRoot } ` ,
547
550
) ;
548
551
@@ -556,7 +559,7 @@ export class DBTIntegrationAdapter extends EventEmitter implements DBTFacade {
556
559
this . consecutiveReadFailures ++ ;
557
560
if ( this . consecutiveReadFailures > 3 ) {
558
561
this . terminal . error (
559
- "DBTIntegrationAdapter " ,
562
+ "DBTProjectIntegrationAdapter " ,
560
563
`Could not read/parse manifest file at ${ manifestLocation } after ${ this . consecutiveReadFailures } attempts` ,
561
564
error ,
562
565
) ;
@@ -571,7 +574,7 @@ export class DBTIntegrationAdapter extends EventEmitter implements DBTFacade {
571
574
}
572
575
573
576
this . terminal . debug (
574
- "DBTIntegrationAdapter " ,
577
+ "DBTProjectIntegrationAdapter " ,
575
578
`Starting Node.js file watchers for project at ${ this . projectRoot } ` ,
576
579
) ;
577
580
@@ -585,7 +588,7 @@ export class DBTIntegrationAdapter extends EventEmitter implements DBTFacade {
585
588
}
586
589
587
590
this . terminal . debug (
588
- "DBTIntegrationAdapter " ,
591
+ "DBTProjectIntegrationAdapter " ,
589
592
`Stopping Node.js file watchers for project at ${ this . projectRoot } ` ,
590
593
) ;
591
594
@@ -604,7 +607,7 @@ export class DBTIntegrationAdapter extends EventEmitter implements DBTFacade {
604
607
605
608
if ( ! sourcePaths || ! macroPaths || ! seedPaths ) {
606
609
this . terminal . debug (
607
- "DBTIntegrationAdapter " ,
610
+ "DBTProjectIntegrationAdapter " ,
608
611
"Cannot update file watchers - source paths not available" ,
609
612
) ;
610
613
return ;
@@ -621,7 +624,7 @@ export class DBTIntegrationAdapter extends EventEmitter implements DBTFacade {
621
624
}
622
625
623
626
this . terminal . debug (
624
- "DBTIntegrationAdapter " ,
627
+ "DBTProjectIntegrationAdapter " ,
625
628
"Updating Node.js file watchers with new paths" ,
626
629
allPaths ,
627
630
) ;
@@ -641,7 +644,7 @@ export class DBTIntegrationAdapter extends EventEmitter implements DBTFacade {
641
644
642
645
if ( ! sourcePaths || ! macroPaths || ! seedPaths ) {
643
646
this . terminal . debug (
644
- "DBTIntegrationAdapter " ,
647
+ "DBTProjectIntegrationAdapter " ,
645
648
"Cannot setup file watchers - source paths not available" ,
646
649
) ;
647
650
return ;
@@ -652,15 +655,15 @@ export class DBTIntegrationAdapter extends EventEmitter implements DBTFacade {
652
655
653
656
const debouncedFileChangeHandler = debounce ( async ( ) => {
654
657
this . terminal . debug (
655
- "DBTIntegrationAdapter " ,
658
+ "DBTProjectIntegrationAdapter " ,
656
659
`SourceFileChanged event fired for "${ this . getProjectName ( ) } " at ${ this . projectRoot } ` ,
657
660
) ;
658
661
this . emit ( "sourceFileChanged" ) ;
659
662
try {
660
663
await this . rebuildManifest ( ) ;
661
664
} catch ( error ) {
662
665
this . terminal . error (
663
- "DBTIntegrationAdapterError " ,
666
+ "DBTProjectIntegrationAdapterError " ,
664
667
`Failed to rebuild manifest after file change: ${ error instanceof Error ? error . message : String ( error ) } ` ,
665
668
error ,
666
669
) ;
@@ -676,7 +679,7 @@ export class DBTIntegrationAdapter extends EventEmitter implements DBTFacade {
676
679
( eventType , filename ) => {
677
680
if ( filename && this . isDbtFile ( filename ) ) {
678
681
this . terminal . debug (
679
- "DBTIntegrationAdapter " ,
682
+ "DBTProjectIntegrationAdapter " ,
680
683
`File ${ eventType } : ${ filename } in ${ sourcePath } ` ,
681
684
) ;
682
685
debouncedFileChangeHandler ( ) ;
@@ -687,12 +690,12 @@ export class DBTIntegrationAdapter extends EventEmitter implements DBTFacade {
687
690
this . sourceFileWatchers . push ( watcher ) ;
688
691
689
692
this . terminal . debug (
690
- "DBTIntegrationAdapter " ,
693
+ "DBTProjectIntegrationAdapter " ,
691
694
`Started Node.js file watcher for ${ sourcePath } ` ,
692
695
) ;
693
696
} catch ( error ) {
694
697
this . terminal . error (
695
- "DBTIntegrationAdapter " ,
698
+ "DBTProjectIntegrationAdapter " ,
696
699
`Failed to create file watcher for ${ sourcePath } ` ,
697
700
error ,
698
701
) ;
@@ -706,7 +709,7 @@ export class DBTIntegrationAdapter extends EventEmitter implements DBTFacade {
706
709
watcher . close ( ) ;
707
710
} catch ( error ) {
708
711
this . terminal . error (
709
- "DBTIntegrationAdapter " ,
712
+ "DBTProjectIntegrationAdapter " ,
710
713
"Error closing file watcher" ,
711
714
error ,
712
715
) ;
@@ -738,14 +741,14 @@ export class DBTIntegrationAdapter extends EventEmitter implements DBTFacade {
738
741
const dbtProjectFilePath = this . getDBTProjectFilePath ( ) ;
739
742
740
743
this . terminal . debug (
741
- "DBTIntegrationAdapter " ,
744
+ "DBTProjectIntegrationAdapter " ,
742
745
`Starting Node.js project config watcher for ${ dbtProjectFilePath } ` ,
743
746
) ;
744
747
745
748
try {
746
749
const debouncedConfigChangeHandler = debounce ( async ( ) => {
747
750
this . terminal . debug (
748
- "DBTIntegrationAdapter " ,
751
+ "DBTProjectIntegrationAdapter " ,
749
752
"dbt_project.yml changed, refreshing project config" ,
750
753
) ;
751
754
@@ -755,7 +758,7 @@ export class DBTIntegrationAdapter extends EventEmitter implements DBTFacade {
755
758
await this . rebuildManifest ( ) ;
756
759
} catch ( error ) {
757
760
this . terminal . error (
758
- "DBTIntegrationAdapter " ,
761
+ "DBTProjectIntegrationAdapter " ,
759
762
"Error refreshing project config after file change" ,
760
763
error ,
761
764
) ;
@@ -765,20 +768,20 @@ export class DBTIntegrationAdapter extends EventEmitter implements DBTFacade {
765
768
this . projectConfigWatcher = watch ( dbtProjectFilePath , ( eventType ) => {
766
769
if ( eventType === "change" ) {
767
770
this . terminal . debug (
768
- "DBTIntegrationAdapter " ,
771
+ "DBTProjectIntegrationAdapter " ,
769
772
`dbt_project.yml ${ eventType } detected` ,
770
773
) ;
771
774
debouncedConfigChangeHandler ( ) ;
772
775
}
773
776
} ) ;
774
777
775
778
this . terminal . debug (
776
- "DBTIntegrationAdapter " ,
779
+ "DBTProjectIntegrationAdapter " ,
777
780
`Started Node.js project config watcher for ${ dbtProjectFilePath } ` ,
778
781
) ;
779
782
} catch ( error ) {
780
783
this . terminal . error (
781
- "DBTIntegrationAdapter " ,
784
+ "DBTProjectIntegrationAdapter " ,
782
785
`Failed to create project config watcher for ${ dbtProjectFilePath } ` ,
783
786
error ,
784
787
) ;
@@ -791,12 +794,12 @@ export class DBTIntegrationAdapter extends EventEmitter implements DBTFacade {
791
794
this . projectConfigWatcher . close ( ) ;
792
795
this . projectConfigWatcher = undefined ;
793
796
this . terminal . debug (
794
- "DBTIntegrationAdapter " ,
797
+ "DBTProjectIntegrationAdapter " ,
795
798
"Stopped Node.js project config watcher" ,
796
799
) ;
797
800
} catch ( error ) {
798
801
this . terminal . error (
799
- "DBTIntegrationAdapter " ,
802
+ "DBTProjectIntegrationAdapter " ,
800
803
"Error closing project config watcher" ,
801
804
error ,
802
805
) ;
@@ -1223,14 +1226,14 @@ export class DBTIntegrationAdapter extends EventEmitter implements DBTFacade {
1223
1226
const targetPath = this . getTargetPath ( ) ;
1224
1227
if ( ! targetPath ) {
1225
1228
this . terminal . debug (
1226
- "DBTIntegrationAdapter " ,
1229
+ "DBTProjectIntegrationAdapter " ,
1227
1230
"Cannot start target watchers - target path not available" ,
1228
1231
) ;
1229
1232
return ;
1230
1233
}
1231
1234
1232
1235
this . terminal . debug (
1233
- "DBTIntegrationAdapter " ,
1236
+ "DBTProjectIntegrationAdapter " ,
1234
1237
`Starting Node.js target watchers for project at ${ this . projectRoot } ` ,
1235
1238
) ;
1236
1239
@@ -1245,7 +1248,7 @@ export class DBTIntegrationAdapter extends EventEmitter implements DBTFacade {
1245
1248
}
1246
1249
1247
1250
this . terminal . debug (
1248
- "DBTIntegrationAdapter " ,
1251
+ "DBTProjectIntegrationAdapter " ,
1249
1252
`Stopping Node.js target watchers for project at ${ this . projectRoot } ` ,
1250
1253
) ;
1251
1254
@@ -1262,7 +1265,7 @@ export class DBTIntegrationAdapter extends EventEmitter implements DBTFacade {
1262
1265
const targetPath = this . getTargetPath ( ) ;
1263
1266
if ( ! targetPath ) {
1264
1267
this . terminal . debug (
1265
- "DBTIntegrationAdapter " ,
1268
+ "DBTProjectIntegrationAdapter " ,
1266
1269
"Cannot update target watchers - target path not available" ,
1267
1270
) ;
1268
1271
this . stopTargetWatchers ( ) ;
@@ -1275,7 +1278,7 @@ export class DBTIntegrationAdapter extends EventEmitter implements DBTFacade {
1275
1278
}
1276
1279
1277
1280
this . terminal . debug (
1278
- "DBTIntegrationAdapter " ,
1281
+ "DBTProjectIntegrationAdapter " ,
1279
1282
"Updating Node.js target watchers with new target path" ,
1280
1283
targetPath ,
1281
1284
) ;
@@ -1301,7 +1304,7 @@ export class DBTIntegrationAdapter extends EventEmitter implements DBTFacade {
1301
1304
}
1302
1305
} catch ( error ) {
1303
1306
this . terminal . error (
1304
- "DBTIntegrationAdapter " ,
1307
+ "DBTProjectIntegrationAdapter " ,
1305
1308
"Error setting up target watchers" ,
1306
1309
error ,
1307
1310
) ;
@@ -1342,7 +1345,7 @@ export class DBTIntegrationAdapter extends EventEmitter implements DBTFacade {
1342
1345
( filename === MANIFEST_FILE || filename === RUN_RESULTS_FILE )
1343
1346
) {
1344
1347
this . terminal . debug (
1345
- "DBTIntegrationAdapter " ,
1348
+ "DBTProjectIntegrationAdapter " ,
1346
1349
`Target folder ${ eventType } detected: ${ filename } in ${ targetPath } ` ,
1347
1350
) ;
1348
1351
handleFileChange ( ) ;
@@ -1351,13 +1354,13 @@ export class DBTIntegrationAdapter extends EventEmitter implements DBTFacade {
1351
1354
) ;
1352
1355
1353
1356
this . terminal . debug (
1354
- "DBTIntegrationAdapter " ,
1357
+ "DBTProjectIntegrationAdapter " ,
1355
1358
`Started Node.js target folder watcher for ${ targetPath } ` ,
1356
1359
) ;
1357
1360
return watcher ;
1358
1361
} catch ( error ) {
1359
1362
this . terminal . error (
1360
- "DBTIntegrationAdapter " ,
1363
+ "DBTProjectIntegrationAdapter " ,
1361
1364
`Failed to create target folder watcher for ${ targetPath } ` ,
1362
1365
error ,
1363
1366
) ;
@@ -1379,7 +1382,7 @@ export class DBTIntegrationAdapter extends EventEmitter implements DBTFacade {
1379
1382
} ;
1380
1383
} catch ( error ) {
1381
1384
this . terminal . error (
1382
- "DBTIntegrationAdapter " ,
1385
+ "DBTProjectIntegrationAdapter " ,
1383
1386
`Unable to parse run_results.json: ${ error } ` ,
1384
1387
error ,
1385
1388
) ;
@@ -1393,7 +1396,7 @@ export class DBTIntegrationAdapter extends EventEmitter implements DBTFacade {
1393
1396
watcher . close ( ) ;
1394
1397
} catch ( error ) {
1395
1398
this . terminal . error (
1396
- "DBTIntegrationAdapter " ,
1399
+ "DBTProjectIntegrationAdapter " ,
1397
1400
"Error closing target watcher" ,
1398
1401
error ,
1399
1402
) ;
0 commit comments