Skip to content

Commit aa8c41c

Browse files
committed
refactor: rename DBTIntegrationAdapter to DBTProjectIntegrationAdapter
1 parent 78e999b commit aa8c41c

File tree

12 files changed

+77
-74
lines changed

12 files changed

+77
-74
lines changed

src/dbt_integration/dbtIntegrationAdapter.ts renamed to src/dbt_integration/dbtProjectIntegrationAdapter.ts

Lines changed: 48 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -82,11 +82,14 @@ export interface RunResultsEventData {
8282
}
8383

8484
/**
85-
* DBTIntegrationAdapter provides a framework-agnostic implementation of DBTFacade
85+
* DBTProjectIntegrationAdapter provides a framework-agnostic implementation of DBTFacade
8686
* that delegates to the appropriate dbt integration (core, cloud, fusion, corecommand)
8787
* based on configuration. This class has no VSCode dependencies.
8888
*/
89-
export class DBTIntegrationAdapter extends EventEmitter implements DBTFacade {
89+
export class DBTProjectIntegrationAdapter
90+
extends EventEmitter
91+
implements DBTFacade
92+
{
9093
private currentIntegration: DBTProjectIntegration;
9194
private consecutiveReadFailures = 0;
9295
private sourceFileWatchers: FSWatcher[] = [];
@@ -283,7 +286,7 @@ export class DBTIntegrationAdapter extends EventEmitter implements DBTFacade {
283286

284287
async refreshProjectConfig(): Promise<void> {
285288
this.terminal.debug(
286-
"DBTIntegrationAdapter",
289+
"DBTProjectIntegrationAdapter",
287290
`Going to refresh the project "${this.getProjectName()}" at ${
288291
this.projectRoot
289292
} configuration`,
@@ -327,7 +330,7 @@ export class DBTIntegrationAdapter extends EventEmitter implements DBTFacade {
327330
}
328331

329332
this.terminal.debug(
330-
"DBTIntegrationAdapter",
333+
"DBTProjectIntegrationAdapter",
331334
`An error occurred while trying to refresh the project "${this.getProjectName()}" at ${
332335
this.projectRoot
333336
} configuration`,
@@ -346,7 +349,7 @@ export class DBTIntegrationAdapter extends EventEmitter implements DBTFacade {
346349

347350
if (sourcePaths && macroPaths && seedPaths) {
348351
this.terminal.debug(
349-
"DBTIntegrationAdapter",
352+
"DBTProjectIntegrationAdapter",
350353
`Project config refreshed successfully for "${this.getProjectName()}" at ${
351354
this.projectRoot
352355
}`,
@@ -367,15 +370,15 @@ export class DBTIntegrationAdapter extends EventEmitter implements DBTFacade {
367370
);
368371
} else {
369372
this.terminal.warn(
370-
"DBTIntegrationAdapter",
373+
"DBTProjectIntegrationAdapter",
371374
"Could not complete project config refresh because project is not initialized properly. dbt path settings cannot be determined",
372375
);
373376
}
374377
}
375378

376379
async rebuildManifest(): Promise<void> {
377380
this.terminal.debug(
378-
"DBTIntegrationAdapter",
381+
"DBTProjectIntegrationAdapter",
379382
`Going to rebuild the manifest for project at ${this.projectRoot}`,
380383
);
381384

@@ -390,15 +393,15 @@ export class DBTIntegrationAdapter extends EventEmitter implements DBTFacade {
390393
if (!this.depsInitialized && installDepsOnProjectInitialization) {
391394
try {
392395
this.terminal.debug(
393-
"DBTIntegrationAdapter",
396+
"DBTProjectIntegrationAdapter",
394397
"Installing dbt dependencies before first manifest rebuild",
395398
);
396399
await this.installDeps(true);
397400
this.depsInitialized = true;
398401
} catch (error: any) {
399402
// this is best effort
400403
this.terminal.warn(
401-
"DBTIntegrationAdapter",
404+
"DBTProjectIntegrationAdapter",
402405
"An error occurred while installing dependencies",
403406
error,
404407
);
@@ -408,7 +411,7 @@ export class DBTIntegrationAdapter extends EventEmitter implements DBTFacade {
408411
try {
409412
await this.currentIntegration.rebuildManifest();
410413
this.terminal.debug(
411-
"DBTIntegrationAdapter",
414+
"DBTProjectIntegrationAdapter",
412415
`Finished rebuilding the manifest for project at ${this.projectRoot}`,
413416
);
414417

@@ -419,7 +422,7 @@ export class DBTIntegrationAdapter extends EventEmitter implements DBTFacade {
419422
}
420423
} catch (error) {
421424
this.terminal.error(
422-
"DBTIntegrationAdapter",
425+
"DBTProjectIntegrationAdapter",
423426
"Error rebuilding manifest",
424427
error,
425428
);
@@ -434,14 +437,14 @@ export class DBTIntegrationAdapter extends EventEmitter implements DBTFacade {
434437

435438
async parseManifest(): Promise<ParsedManifest | undefined> {
436439
this.terminal.debug(
437-
"DBTIntegrationAdapter",
440+
"DBTProjectIntegrationAdapter",
438441
`Going to parse manifest for project at ${this.projectRoot}`,
439442
);
440443

441444
const targetPath = this.getTargetPath();
442445
if (!targetPath) {
443446
this.terminal.debug(
444-
"DBTIntegrationAdapter",
447+
"DBTProjectIntegrationAdapter",
445448
"targetPath should be defined at this stage for project " +
446449
this.projectRoot,
447450
);
@@ -542,7 +545,7 @@ export class DBTIntegrationAdapter extends EventEmitter implements DBTFacade {
542545
const manifestLocation = path.join(...pathParts, MANIFEST_FILE);
543546

544547
this.terminal.debug(
545-
"DBTIntegrationAdapter",
548+
"DBTProjectIntegrationAdapter",
546549
`Reading manifest at ${manifestLocation} for project at ${this.projectRoot}`,
547550
);
548551

@@ -556,7 +559,7 @@ export class DBTIntegrationAdapter extends EventEmitter implements DBTFacade {
556559
this.consecutiveReadFailures++;
557560
if (this.consecutiveReadFailures > 3) {
558561
this.terminal.error(
559-
"DBTIntegrationAdapter",
562+
"DBTProjectIntegrationAdapter",
560563
`Could not read/parse manifest file at ${manifestLocation} after ${this.consecutiveReadFailures} attempts`,
561564
error,
562565
);
@@ -571,7 +574,7 @@ export class DBTIntegrationAdapter extends EventEmitter implements DBTFacade {
571574
}
572575

573576
this.terminal.debug(
574-
"DBTIntegrationAdapter",
577+
"DBTProjectIntegrationAdapter",
575578
`Starting Node.js file watchers for project at ${this.projectRoot}`,
576579
);
577580

@@ -585,7 +588,7 @@ export class DBTIntegrationAdapter extends EventEmitter implements DBTFacade {
585588
}
586589

587590
this.terminal.debug(
588-
"DBTIntegrationAdapter",
591+
"DBTProjectIntegrationAdapter",
589592
`Stopping Node.js file watchers for project at ${this.projectRoot}`,
590593
);
591594

@@ -604,7 +607,7 @@ export class DBTIntegrationAdapter extends EventEmitter implements DBTFacade {
604607

605608
if (!sourcePaths || !macroPaths || !seedPaths) {
606609
this.terminal.debug(
607-
"DBTIntegrationAdapter",
610+
"DBTProjectIntegrationAdapter",
608611
"Cannot update file watchers - source paths not available",
609612
);
610613
return;
@@ -621,7 +624,7 @@ export class DBTIntegrationAdapter extends EventEmitter implements DBTFacade {
621624
}
622625

623626
this.terminal.debug(
624-
"DBTIntegrationAdapter",
627+
"DBTProjectIntegrationAdapter",
625628
"Updating Node.js file watchers with new paths",
626629
allPaths,
627630
);
@@ -641,7 +644,7 @@ export class DBTIntegrationAdapter extends EventEmitter implements DBTFacade {
641644

642645
if (!sourcePaths || !macroPaths || !seedPaths) {
643646
this.terminal.debug(
644-
"DBTIntegrationAdapter",
647+
"DBTProjectIntegrationAdapter",
645648
"Cannot setup file watchers - source paths not available",
646649
);
647650
return;
@@ -652,15 +655,15 @@ export class DBTIntegrationAdapter extends EventEmitter implements DBTFacade {
652655

653656
const debouncedFileChangeHandler = debounce(async () => {
654657
this.terminal.debug(
655-
"DBTIntegrationAdapter",
658+
"DBTProjectIntegrationAdapter",
656659
`SourceFileChanged event fired for "${this.getProjectName()}" at ${this.projectRoot}`,
657660
);
658661
this.emit("sourceFileChanged");
659662
try {
660663
await this.rebuildManifest();
661664
} catch (error) {
662665
this.terminal.error(
663-
"DBTIntegrationAdapterError",
666+
"DBTProjectIntegrationAdapterError",
664667
`Failed to rebuild manifest after file change: ${error instanceof Error ? error.message : String(error)}`,
665668
error,
666669
);
@@ -676,7 +679,7 @@ export class DBTIntegrationAdapter extends EventEmitter implements DBTFacade {
676679
(eventType, filename) => {
677680
if (filename && this.isDbtFile(filename)) {
678681
this.terminal.debug(
679-
"DBTIntegrationAdapter",
682+
"DBTProjectIntegrationAdapter",
680683
`File ${eventType}: ${filename} in ${sourcePath}`,
681684
);
682685
debouncedFileChangeHandler();
@@ -687,12 +690,12 @@ export class DBTIntegrationAdapter extends EventEmitter implements DBTFacade {
687690
this.sourceFileWatchers.push(watcher);
688691

689692
this.terminal.debug(
690-
"DBTIntegrationAdapter",
693+
"DBTProjectIntegrationAdapter",
691694
`Started Node.js file watcher for ${sourcePath}`,
692695
);
693696
} catch (error) {
694697
this.terminal.error(
695-
"DBTIntegrationAdapter",
698+
"DBTProjectIntegrationAdapter",
696699
`Failed to create file watcher for ${sourcePath}`,
697700
error,
698701
);
@@ -706,7 +709,7 @@ export class DBTIntegrationAdapter extends EventEmitter implements DBTFacade {
706709
watcher.close();
707710
} catch (error) {
708711
this.terminal.error(
709-
"DBTIntegrationAdapter",
712+
"DBTProjectIntegrationAdapter",
710713
"Error closing file watcher",
711714
error,
712715
);
@@ -738,14 +741,14 @@ export class DBTIntegrationAdapter extends EventEmitter implements DBTFacade {
738741
const dbtProjectFilePath = this.getDBTProjectFilePath();
739742

740743
this.terminal.debug(
741-
"DBTIntegrationAdapter",
744+
"DBTProjectIntegrationAdapter",
742745
`Starting Node.js project config watcher for ${dbtProjectFilePath}`,
743746
);
744747

745748
try {
746749
const debouncedConfigChangeHandler = debounce(async () => {
747750
this.terminal.debug(
748-
"DBTIntegrationAdapter",
751+
"DBTProjectIntegrationAdapter",
749752
"dbt_project.yml changed, refreshing project config",
750753
);
751754

@@ -755,7 +758,7 @@ export class DBTIntegrationAdapter extends EventEmitter implements DBTFacade {
755758
await this.rebuildManifest();
756759
} catch (error) {
757760
this.terminal.error(
758-
"DBTIntegrationAdapter",
761+
"DBTProjectIntegrationAdapter",
759762
"Error refreshing project config after file change",
760763
error,
761764
);
@@ -765,20 +768,20 @@ export class DBTIntegrationAdapter extends EventEmitter implements DBTFacade {
765768
this.projectConfigWatcher = watch(dbtProjectFilePath, (eventType) => {
766769
if (eventType === "change") {
767770
this.terminal.debug(
768-
"DBTIntegrationAdapter",
771+
"DBTProjectIntegrationAdapter",
769772
`dbt_project.yml ${eventType} detected`,
770773
);
771774
debouncedConfigChangeHandler();
772775
}
773776
});
774777

775778
this.terminal.debug(
776-
"DBTIntegrationAdapter",
779+
"DBTProjectIntegrationAdapter",
777780
`Started Node.js project config watcher for ${dbtProjectFilePath}`,
778781
);
779782
} catch (error) {
780783
this.terminal.error(
781-
"DBTIntegrationAdapter",
784+
"DBTProjectIntegrationAdapter",
782785
`Failed to create project config watcher for ${dbtProjectFilePath}`,
783786
error,
784787
);
@@ -791,12 +794,12 @@ export class DBTIntegrationAdapter extends EventEmitter implements DBTFacade {
791794
this.projectConfigWatcher.close();
792795
this.projectConfigWatcher = undefined;
793796
this.terminal.debug(
794-
"DBTIntegrationAdapter",
797+
"DBTProjectIntegrationAdapter",
795798
"Stopped Node.js project config watcher",
796799
);
797800
} catch (error) {
798801
this.terminal.error(
799-
"DBTIntegrationAdapter",
802+
"DBTProjectIntegrationAdapter",
800803
"Error closing project config watcher",
801804
error,
802805
);
@@ -1223,14 +1226,14 @@ export class DBTIntegrationAdapter extends EventEmitter implements DBTFacade {
12231226
const targetPath = this.getTargetPath();
12241227
if (!targetPath) {
12251228
this.terminal.debug(
1226-
"DBTIntegrationAdapter",
1229+
"DBTProjectIntegrationAdapter",
12271230
"Cannot start target watchers - target path not available",
12281231
);
12291232
return;
12301233
}
12311234

12321235
this.terminal.debug(
1233-
"DBTIntegrationAdapter",
1236+
"DBTProjectIntegrationAdapter",
12341237
`Starting Node.js target watchers for project at ${this.projectRoot}`,
12351238
);
12361239

@@ -1245,7 +1248,7 @@ export class DBTIntegrationAdapter extends EventEmitter implements DBTFacade {
12451248
}
12461249

12471250
this.terminal.debug(
1248-
"DBTIntegrationAdapter",
1251+
"DBTProjectIntegrationAdapter",
12491252
`Stopping Node.js target watchers for project at ${this.projectRoot}`,
12501253
);
12511254

@@ -1262,7 +1265,7 @@ export class DBTIntegrationAdapter extends EventEmitter implements DBTFacade {
12621265
const targetPath = this.getTargetPath();
12631266
if (!targetPath) {
12641267
this.terminal.debug(
1265-
"DBTIntegrationAdapter",
1268+
"DBTProjectIntegrationAdapter",
12661269
"Cannot update target watchers - target path not available",
12671270
);
12681271
this.stopTargetWatchers();
@@ -1275,7 +1278,7 @@ export class DBTIntegrationAdapter extends EventEmitter implements DBTFacade {
12751278
}
12761279

12771280
this.terminal.debug(
1278-
"DBTIntegrationAdapter",
1281+
"DBTProjectIntegrationAdapter",
12791282
"Updating Node.js target watchers with new target path",
12801283
targetPath,
12811284
);
@@ -1301,7 +1304,7 @@ export class DBTIntegrationAdapter extends EventEmitter implements DBTFacade {
13011304
}
13021305
} catch (error) {
13031306
this.terminal.error(
1304-
"DBTIntegrationAdapter",
1307+
"DBTProjectIntegrationAdapter",
13051308
"Error setting up target watchers",
13061309
error,
13071310
);
@@ -1342,7 +1345,7 @@ export class DBTIntegrationAdapter extends EventEmitter implements DBTFacade {
13421345
(filename === MANIFEST_FILE || filename === RUN_RESULTS_FILE)
13431346
) {
13441347
this.terminal.debug(
1345-
"DBTIntegrationAdapter",
1348+
"DBTProjectIntegrationAdapter",
13461349
`Target folder ${eventType} detected: ${filename} in ${targetPath}`,
13471350
);
13481351
handleFileChange();
@@ -1351,13 +1354,13 @@ export class DBTIntegrationAdapter extends EventEmitter implements DBTFacade {
13511354
);
13521355

13531356
this.terminal.debug(
1354-
"DBTIntegrationAdapter",
1357+
"DBTProjectIntegrationAdapter",
13551358
`Started Node.js target folder watcher for ${targetPath}`,
13561359
);
13571360
return watcher;
13581361
} catch (error) {
13591362
this.terminal.error(
1360-
"DBTIntegrationAdapter",
1363+
"DBTProjectIntegrationAdapter",
13611364
`Failed to create target folder watcher for ${targetPath}`,
13621365
error,
13631366
);
@@ -1379,7 +1382,7 @@ export class DBTIntegrationAdapter extends EventEmitter implements DBTFacade {
13791382
};
13801383
} catch (error) {
13811384
this.terminal.error(
1382-
"DBTIntegrationAdapter",
1385+
"DBTProjectIntegrationAdapter",
13831386
`Unable to parse run_results.json: ${error}`,
13841387
error,
13851388
);
@@ -1393,7 +1396,7 @@ export class DBTIntegrationAdapter extends EventEmitter implements DBTFacade {
13931396
watcher.close();
13941397
} catch (error) {
13951398
this.terminal.error(
1396-
"DBTIntegrationAdapter",
1399+
"DBTProjectIntegrationAdapter",
13971400
"Error closing target watcher",
13981401
error,
13991402
);

0 commit comments

Comments
 (0)