-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcontainer.ts
212 lines (178 loc) · 5.99 KB
/
container.ts
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
"use strict";
import { CodeStreamAgent } from "agent";
import { DocumentManager } from "./documentManager";
import { ErrorReporter } from "./errorReporter";
import { GitService } from "./git/gitService";
import { Logger } from "./logger";
import { CodemarksManager } from "./managers/codemarksManager";
import { CompaniesManager } from "./managers/companiesManager";
import { DocumentMarkerManager } from "./managers/documentMarkerManager";
import { FilesManager } from "./managers/filesManager";
import { IgnoreFilesManager } from "./managers/ignoreFilesManager";
import { MarkerLocationManager } from "./managers/markerLocationManager";
import { MarkersManager } from "./managers/markersManager";
import { PostsManager } from "./managers/postsManager";
import { RepositoryMappingManager } from "./managers/repositoryMappingManager";
import { ReposManager } from "./managers/reposManager";
import { ReviewsManager } from "./managers/reviewsManager";
import { ScmManager } from "./managers/scmManager";
import { StreamsManager } from "./managers/streamsManager";
import { TeamsManager } from "./managers/teamsManager";
import { TelemetryManager } from "./managers/telemetryManager";
import { UnauthenticatedScmManager } from "./managers/unauthenticatedScmManager";
import { UrlManager } from "./managers/urlManager";
import { UsersManager } from "./managers/usersManager";
import { ThirdPartyProviderRegistry } from "./providers/registry";
import { CodeStreamSession } from "./session";
class SessionServiceContainer {
private readonly _git: GitService;
get git() {
return this._git;
}
private readonly _files: FilesManager;
get files(): FilesManager {
return this._files;
}
private readonly _codemarks: CodemarksManager;
get codemarks(): CodemarksManager {
return this._codemarks;
}
private readonly _markerLocations: MarkerLocationManager;
get markerLocations(): MarkerLocationManager {
return this._markerLocations;
}
private readonly _markers: MarkersManager;
get markers(): MarkersManager {
return this._markers;
}
private readonly _posts: PostsManager;
get posts(): PostsManager {
return this._posts;
}
private readonly _repos: ReposManager;
get repos(): ReposManager {
return this._repos;
}
private readonly _scm: ScmManager;
get scm() {
return this._scm;
}
private readonly _streams: StreamsManager;
get streams(): StreamsManager {
return this._streams;
}
private readonly _teams: TeamsManager;
get teams(): TeamsManager {
return this._teams;
}
private readonly _companies: CompaniesManager;
get companies(): CompaniesManager {
return this._companies;
}
private readonly _users: UsersManager;
get users(): UsersManager {
return this._users;
}
private readonly _documentMarkers: DocumentMarkerManager;
get documentMarkers() {
return this._documentMarkers;
}
private readonly _providerRegistry: ThirdPartyProviderRegistry;
get providerRegistry() {
return this._providerRegistry;
}
private readonly _repositoryMappings: RepositoryMappingManager;
get repositoryMappings() {
return this._repositoryMappings;
}
private readonly _ignoreFiles: IgnoreFilesManager;
get ignoreFiles() {
return this._ignoreFiles;
}
private readonly _reviews: ReviewsManager;
get reviews() {
return this._reviews;
}
constructor(public readonly session: CodeStreamSession) {
this._git = new GitService(session);
this._scm = new ScmManager();
this._files = new FilesManager(session);
this._markerLocations = new MarkerLocationManager(session);
this._codemarks = new CodemarksManager(session);
this._markers = new MarkersManager(session);
this._posts = new PostsManager(session);
this._repos = new ReposManager(session);
this._streams = new StreamsManager(session);
this._teams = new TeamsManager(session);
this._users = new UsersManager(session);
this._documentMarkers = new DocumentMarkerManager(session);
this._providerRegistry = new ThirdPartyProviderRegistry(session);
this._repositoryMappings = new RepositoryMappingManager(session);
this._companies = new CompaniesManager(session);
this._ignoreFiles = new IgnoreFilesManager(session);
this._reviews = new ReviewsManager(session);
}
}
class ServiceContainer {
// TODO: [EA] I think we should try to rework this to avoid the need of the session here
constructor(public readonly agent: CodeStreamAgent, session: CodeStreamSession) {
this._documents = agent.documents;
this._unauthenticatedScm = new UnauthenticatedScmManager();
this._errorReporter = new ErrorReporter(session);
this._telemetry = new TelemetryManager(session);
this._urls = new UrlManager();
}
private readonly _unauthenticatedScm: UnauthenticatedScmManager;
get unauthenticatedScm() {
return this._unauthenticatedScm;
}
private readonly _errorReporter: ErrorReporter;
get errorReporter() {
return this._errorReporter;
}
private readonly _documents: DocumentManager;
get documents() {
return this._documents;
}
private readonly _telemetry: TelemetryManager;
get telemetry() {
return this._telemetry;
}
private readonly _urls: UrlManager;
get urls() {
return this._urls;
}
}
let container: ServiceContainer | undefined;
export namespace Container {
export function initialize(agent: CodeStreamAgent, session: CodeStreamSession) {
container = new ServiceContainer(agent, session);
}
export function instance(): ServiceContainer {
if (container === undefined) {
debugger;
const ex = new Error("Container not yet initialized.");
Logger.error(ex);
throw ex;
}
return container;
}
}
let sessionContainer: SessionServiceContainer | undefined;
export namespace SessionContainer {
export function initialize(session: CodeStreamSession) {
sessionContainer = new SessionServiceContainer(session);
}
export function isInitialized() {
return sessionContainer ? true : false;
}
export function instance(): SessionServiceContainer {
if (sessionContainer === undefined) {
debugger;
const ex = new Error("SessionContainer not yet initialized.");
Logger.error(ex);
throw ex;
}
return sessionContainer;
}
}