-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathServiceMapping.ts
More file actions
217 lines (196 loc) · 7.01 KB
/
ServiceMapping.ts
File metadata and controls
217 lines (196 loc) · 7.01 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
/**
* @module ServiceMapping
* @description
* Defines the dependency injection container and service composition.
* Orchestrates the initialization of all Core, Infrastructure, and UI services.
* Provides both old-style service layers and new Effect-TS service layers.
*/
import { Layer } from "effect";
// ============================================================================
// EFFECT-TS SERVICE LAYERS
// ============================================================================
import {
BootstrapLive,
ExtensionLive,
HealthLive,
ModuleInterceptorLive,
MountainClientLive,
RPCServerLive,
TelemetryLive,
} from "./Effect/index.js";
// ============================================================================
// OLD-STYLE SERVICE INTERFACES
// ============================================================================
import { IConfigurationService } from "./Interfaces/IConfigurationService.js";
import { IErrorHandlingService } from "./Interfaces/IErrorHandlingService.js";
import { IExtensionHostService } from "./Interfaces/IExtensionHostService.js";
import { IIPCService } from "./Interfaces/IIPCService.js";
import { IModuleInterceptorService } from "./Interfaces/IModuleInterceptorService.js";
import { IMountainClientService } from "./Interfaces/IMountainClientService.js";
import { IPerformanceMonitoringService } from "./Interfaces/IPerformanceMonitoringService.js";
import { ISecurityService } from "./Interfaces/ISecurityService.js";
import { ITerminalService } from "./Interfaces/ITerminalService.js";
import {
APIFactoryLayer,
IAPIFactoryService,
} from "./Services/APIFactoryService.js";
// ============================================================================
// OLD-STYLE SERVICE LAYERS
// ============================================================================
import { ConfigurationLayer } from "./Services/Configuration.js";
import { ErrorHandlingServiceLive } from "./Services/ErrorHandlingService.js";
import { ExtensionHostLayer } from "./Services/ExtensionHostService.js";
import { IPCServiceLayer } from "./Services/IPCService.js";
import { ModuleInterceptorServiceLayer } from "./Services/ModuleInterceptorService.js";
import { MountainClientServiceLayer } from "./Services/MountainClientService.js";
import { MountainGRPCClientLayer } from "./Services/MountainGRPCClient.js";
import { PerformanceMonitoringServiceLive } from "./Services/PerformanceMonitoringService.js";
import { SecurityServiceLive } from "./Services/SecurityService.js";
import { TerminalServiceLayer } from "./Services/TerminalService.js";
// ============================================================================
// SERVICE MAPPING - OLD STYLE SERVICES
// ============================================================================
/**
* Old Style Services
*
* Provides dependency injection for traditional service-based architecture.
* Legacy services that use Promise-based async patterns.
*/
export const OldStyleServices = {
/**
* Validate dependencies for old-style services
*/
validateDependencies: () =>
Layer.mergeAll(
MountainClientServiceLayer,
IPCServiceLayer,
ConfigurationLayer,
ModuleInterceptorServiceLayer,
ExtensionHostLayer,
APIFactoryLayer,
TerminalServiceLayer,
SecurityServiceLive,
PerformanceMonitoringServiceLive,
ErrorHandlingServiceLive,
),
/**
* Compose application layer for old-style services
*/
composeAppLayer: () => {
// Base Infrastructure
const Base = Layer.mergeAll(
MountainClientServiceLayer,
MountainGRPCClientLayer,
IPCServiceLayer,
SecurityServiceLive,
PerformanceMonitoringServiceLive,
ErrorHandlingServiceLive,
);
// Core Capabilities (Depend on Base)
const Config = ConfigurationLayer.pipe(Layer.provide(Base));
const Terminal = TerminalServiceLayer.pipe(Layer.provide(Base));
const ModuleInt = ModuleInterceptorServiceLayer.pipe(
Layer.provide(Base),
);
// API Factory (Depends on Config, Terminal, ModuleInt)
const API = APIFactoryLayer.pipe(
Layer.provide(Base),
Layer.provide(Config),
Layer.provide(Terminal),
Layer.provide(ModuleInt),
);
// Extension Host (Depends on API, Config, ModuleInt)
const ExtHost = ExtensionHostLayer.pipe(
Layer.provide(Base),
Layer.provide(Config),
Layer.provide(API),
Layer.provide(ModuleInt),
);
return Layer.mergeAll(Base, Config, Terminal, API, ExtHost, ModuleInt);
},
};
// ============================================================================
// SERVICE MAPPING - EFFECT-TS SERVICES
// ============================================================================
/**
* Effect-TS Services
*
* Provides dependency injection for Effect-TS service-based architecture.
* Modern services that use Effect-based async patterns with proper composable effects.
*/
export const EffectServices = {
/**
* Compose the main Effect-TS application layer
*
* Layer dependencies:
* - Telemetry (base, no dependencies)
* - Health (depends on Telemetry)
* - MountainClient (depends on Telemetry)
* - ModuleInterceptor (depends on Telemetry)
* - Extension (depends on Telemetry)
* - RPCServer (depends on Telemetry)
* - Bootstrap (depends on all above)
*/
composeAppLayer: () => {
// Base layer: Telemetry (no dependencies)
const Telemetry = TelemetryLive;
// Layer 1: Services that depend only on Telemetry
const Health = HealthLive.pipe(Layer.provide(Telemetry));
const MountainClient = MountainClientLive.pipe(
Layer.provide(Telemetry),
);
const ModuleInterceptor = ModuleInterceptorLive.pipe(
Layer.provide(Telemetry),
);
const Extension = ExtensionLive.pipe(Layer.provide(Telemetry));
const RPCServer = RPCServerLive.pipe(Layer.provide(Telemetry));
// Layer 2: Bootstrap depends on all services
const Bootstrap = BootstrapLive.pipe(
Layer.provide(Telemetry),
Layer.provide(Health),
Layer.provide(MountainClient),
Layer.provide(ModuleInterceptor),
Layer.provide(Extension),
Layer.provide(RPCServer),
);
// Merge all layers into a single application layer
return Layer.mergeAll(
Telemetry,
Health,
MountainClient,
ModuleInterceptor,
Extension,
RPCServer,
Bootstrap,
);
},
/**
* Get individual service layers for fine-grained composition
*/
getTelemetry: () => TelemetryLive,
getHealth: () => HealthLive,
getMountainClient: () => MountainClientLive,
getModuleInterceptor: () => ModuleInterceptorLive,
getExtension: () => ExtensionLive,
getRPCServer: () => RPCServerLive,
getBootstrap: () => BootstrapLive,
};
// ============================================================================
// BACKWARDS COMPATIBILITY
// ============================================================================
/**
* Backwards compatibility - keep old ServiceMapping class
* @deprecated Use OldStyleServices or EffectServices instead
*/
export class ServiceMapping {
/**
* Validate dependencies
*/
static validateDependencies = () => OldStyleServices.validateDependencies();
/**
* Compose application layer
*/
static composeAppLayer = () => {
return OldStyleServices.composeAppLayer();
};
}