This repository has no description
1import { InitiateOAuthSignInUseCase } from '../../../../modules/user/application/use-cases/InitiateOAuthSignInUseCase';
2import { CompleteOAuthSignInUseCase } from '../../../../modules/user/application/use-cases/CompleteOAuthSignInUseCase';
3import { RefreshAccessTokenUseCase } from '../../../../modules/user/application/use-cases/RefreshAccessTokenUseCase';
4import { AddUrlToLibraryUseCase } from '../../../../modules/cards/application/useCases/commands/AddUrlToLibraryUseCase';
5import { AddCardToLibraryUseCase } from '../../../../modules/cards/application/useCases/commands/AddCardToLibraryUseCase';
6import { AddCardToCollectionUseCase } from '../../../../modules/cards/application/useCases/commands/AddCardToCollectionUseCase';
7import { UpdateNoteCardUseCase } from '../../../../modules/cards/application/useCases/commands/UpdateNoteCardUseCase';
8import { UpdateUrlCardAssociationsUseCase } from '../../../../modules/cards/application/useCases/commands/UpdateUrlCardAssociationsUseCase';
9import { RemoveCardFromLibraryUseCase } from '../../../../modules/cards/application/useCases/commands/RemoveCardFromLibraryUseCase';
10import { RemoveCardFromCollectionUseCase } from '../../../../modules/cards/application/useCases/commands/RemoveCardFromCollectionUseCase';
11import { GetUrlMetadataUseCase } from '../../../../modules/cards/application/useCases/queries/GetUrlMetadataUseCase';
12import { GetUrlCardViewUseCase } from '../../../../modules/cards/application/useCases/queries/GetUrlCardViewUseCase';
13import { GetLibrariesForCardUseCase } from '../../../../modules/cards/application/useCases/queries/GetLibrariesForCardUseCase';
14import { GetUrlCardsUseCase } from '../../../../modules/cards/application/useCases/queries/GetUrlCardsUseCase';
15import { CreateCollectionUseCase } from '../../../../modules/cards/application/useCases/commands/CreateCollectionUseCase';
16import { UpdateCollectionUseCase } from '../../../../modules/cards/application/useCases/commands/UpdateCollectionUseCase';
17import { DeleteCollectionUseCase } from '../../../../modules/cards/application/useCases/commands/DeleteCollectionUseCase';
18import { GetCollectionPageUseCase } from '../../../../modules/cards/application/useCases/queries/GetCollectionPageUseCase';
19import { Repositories } from './RepositoryFactory';
20import { Services, SharedServices } from './ServiceFactory';
21import { GetProfileUseCase } from 'src/modules/cards/application/useCases/queries/GetProfileUseCase';
22import { LoginWithAppPasswordUseCase } from 'src/modules/user/application/use-cases/LoginWithAppPasswordUseCase';
23import { LogoutUseCase } from 'src/modules/user/application/use-cases/LogoutUseCase';
24import { GenerateExtensionTokensUseCase } from 'src/modules/user/application/use-cases/GenerateExtensionTokensUseCase';
25import { GetGlobalFeedUseCase } from '../../../../modules/feeds/application/useCases/queries/GetGlobalFeedUseCase';
26import { GetGemActivityFeedUseCase } from '../../../../modules/feeds/application/useCases/queries/GetGemActivityFeedUseCase';
27import { GetFollowingFeedUseCase } from '../../../../modules/feeds/application/useCases/queries/GetFollowingFeedUseCase';
28import { AddActivityToFeedUseCase } from '../../../../modules/feeds/application/useCases/commands/AddActivityToFeedUseCase';
29import { GetCollectionsUseCase } from 'src/modules/cards/application/useCases/queries/GetCollectionsUseCase';
30import { SearchCollectionsUseCase } from 'src/modules/cards/application/useCases/queries/SearchCollectionsUseCase';
31import { GetOpenCollectionsWithContributorUseCase } from 'src/modules/cards/application/useCases/queries/GetOpenCollectionsWithContributorUseCase';
32import { GetCollectionPageByAtUriUseCase } from 'src/modules/cards/application/useCases/queries/GetCollectionPageByAtUriUseCase';
33import { GetUrlStatusForMyLibraryUseCase } from '../../../../modules/cards/application/useCases/queries/GetUrlStatusForMyLibraryUseCase';
34import { GetLibrariesForUrlUseCase } from '../../../../modules/cards/application/useCases/queries/GetLibrariesForUrlUseCase';
35import { GetCollectionsForUrlUseCase } from '../../../../modules/cards/application/useCases/queries/GetCollectionsForUrlUseCase';
36import { GetNoteCardsForUrlUseCase } from '../../../../modules/cards/application/useCases/queries/GetNoteCardsForUrlUseCase';
37import { GetForwardConnectionsForUrlUseCase } from '../../../../modules/cards/application/useCases/queries/GetForwardConnectionsForUrlUseCase';
38import { GetBackwardConnectionsForUrlUseCase } from '../../../../modules/cards/application/useCases/queries/GetBackwardConnectionsForUrlUseCase';
39import { GetConnectionsUseCase } from '../../../../modules/cards/application/useCases/queries/GetConnectionsUseCase';
40import { IndexUrlForSearchUseCase } from '../../../../modules/search/application/useCases/commands/IndexUrlForSearchUseCase';
41import { GetSimilarUrlsForUrlUseCase } from '../../../../modules/search/application/useCases/queries/GetSimilarUrlsForUrlUseCase';
42import { SemanticSearchUrlsUseCase } from '../../../../modules/search/application/useCases/queries/SemanticSearchUrlsUseCase';
43import { SearchBskyPostsForUrlUseCase } from '../../../../modules/search/application/use-cases/SearchBskyPostsForUrlUseCase';
44import { SearchAtProtoAccountsUseCase } from '../../../../modules/search/application/use-cases/SearchAtProtoAccountsUseCase';
45import { SearchLeafletDocsForUrlUseCase } from '../../../../modules/search/application/use-cases/SearchLeafletDocsForUrlUseCase';
46import { ProcessCardFirehoseEventUseCase } from '../../../../modules/atproto/application/useCases/ProcessCardFirehoseEventUseCase';
47import { ProcessCollectionFirehoseEventUseCase } from '../../../../modules/atproto/application/useCases/ProcessCollectionFirehoseEventUseCase';
48import { ProcessCollectionLinkFirehoseEventUseCase } from '../../../../modules/atproto/application/useCases/ProcessCollectionLinkFirehoseEventUseCase';
49import { ProcessMarginBookmarkFirehoseEventUseCase } from '../../../../modules/atproto/application/useCases/ProcessMarginBookmarkFirehoseEventUseCase';
50import { ProcessMarginCollectionFirehoseEventUseCase } from '../../../../modules/atproto/application/useCases/ProcessMarginCollectionFirehoseEventUseCase';
51import { ProcessMarginCollectionItemFirehoseEventUseCase } from '../../../../modules/atproto/application/useCases/ProcessMarginCollectionItemFirehoseEventUseCase';
52import { ProcessCollectionLinkRemovalFirehoseEventUseCase } from '../../../../modules/atproto/application/useCases/ProcessCollectionLinkRemovalFirehoseEventUseCase';
53import { ProcessFollowFirehoseEventUseCase } from '../../../../modules/atproto/application/useCases/ProcessFollowFirehoseEventUseCase';
54import { ProcessConnectionFirehoseEventUseCase } from '../../../../modules/atproto/application/useCases/ProcessConnectionFirehoseEventUseCase';
55import { CreateConnectionUseCase } from '../../../../modules/cards/application/useCases/commands/CreateConnectionUseCase';
56import { UpdateConnectionUseCase } from '../../../../modules/cards/application/useCases/commands/UpdateConnectionUseCase';
57import { DeleteConnectionUseCase } from '../../../../modules/cards/application/useCases/commands/DeleteConnectionUseCase';
58import { GetMyNotificationsUseCase } from '../../../../modules/notifications/application/useCases/queries/GetMyNotificationsUseCase';
59import { GetUnreadNotificationCountUseCase } from '../../../../modules/notifications/application/useCases/queries/GetUnreadNotificationCountUseCase';
60import { MarkNotificationsAsReadUseCase } from '../../../../modules/notifications/application/useCases/commands/MarkNotificationsAsReadUseCase';
61import { MarkAllNotificationsAsReadUseCase } from '../../../../modules/notifications/application/useCases/commands/MarkAllNotificationsAsReadUseCase';
62import { CreateNotificationUseCase } from '../../../../modules/notifications/application/useCases/commands/CreateNotificationUseCase';
63import { SyncAccountDataUseCase } from '../../../../modules/sync/application/useCases/SyncAccountDataUseCase';
64import { FollowTargetUseCase } from '../../../../modules/user/application/useCases/commands/FollowTargetUseCase';
65import { UnfollowTargetUseCase } from '../../../../modules/user/application/useCases/commands/UnfollowTargetUseCase';
66import { GetFollowingUsersUseCase } from '../../../../modules/user/application/useCases/queries/GetFollowingUsersUseCase';
67import { GetFollowersUseCase } from '../../../../modules/user/application/useCases/queries/GetFollowersUseCase';
68import { GetFollowingCollectionsUseCase } from '../../../../modules/user/application/useCases/queries/GetFollowingCollectionsUseCase';
69import { GetCollectionFollowersUseCase } from '../../../../modules/user/application/useCases/queries/GetCollectionFollowersUseCase';
70import { GetFollowingCountUseCase } from '../../../../modules/user/application/useCases/queries/GetFollowingCountUseCase';
71import { GetFollowersCountUseCase } from '../../../../modules/user/application/useCases/queries/GetFollowersCountUseCase';
72import { GetFollowingCollectionsCountUseCase } from '../../../../modules/user/application/useCases/queries/GetFollowingCollectionsCountUseCase';
73import { GetCollectionFollowersCountUseCase } from '../../../../modules/user/application/useCases/queries/GetCollectionFollowersCountUseCase';
74import { GetCollectionContributorsUseCase } from '../../../../modules/cards/application/useCases/queries/GetCollectionContributorsUseCase';
75import { SearchUrlsUseCase } from '../../../../modules/cards/application/useCases/queries/SearchUrlsUseCase';
76import { GetGraphDataUseCase } from '../../../../modules/cards/application/useCases/queries/GetGraphDataUseCase';
77
78export interface WorkerUseCases {
79 addActivityToFeedUseCase: AddActivityToFeedUseCase;
80 indexUrlForSearchUseCase: IndexUrlForSearchUseCase;
81 createNotificationUseCase: CreateNotificationUseCase;
82 syncAccountDataUseCase: SyncAccountDataUseCase;
83 // Firehose-specific use cases
84 addUrlToLibraryUseCase: AddUrlToLibraryUseCase;
85 updateUrlCardAssociationsUseCase: UpdateUrlCardAssociationsUseCase;
86 removeCardFromLibraryUseCase: RemoveCardFromLibraryUseCase;
87 createCollectionUseCase: CreateCollectionUseCase;
88 updateCollectionUseCase: UpdateCollectionUseCase;
89 deleteCollectionUseCase: DeleteCollectionUseCase;
90 processCardFirehoseEventUseCase: ProcessCardFirehoseEventUseCase;
91 processCollectionFirehoseEventUseCase: ProcessCollectionFirehoseEventUseCase;
92 processCollectionLinkFirehoseEventUseCase: ProcessCollectionLinkFirehoseEventUseCase;
93 processMarginBookmarkFirehoseEventUseCase: ProcessMarginBookmarkFirehoseEventUseCase;
94 processMarginCollectionFirehoseEventUseCase: ProcessMarginCollectionFirehoseEventUseCase;
95 processMarginCollectionItemFirehoseEventUseCase: ProcessMarginCollectionItemFirehoseEventUseCase;
96 processCollectionLinkRemovalFirehoseEventUseCase: ProcessCollectionLinkRemovalFirehoseEventUseCase;
97 processFollowFirehoseEventUseCase: ProcessFollowFirehoseEventUseCase;
98 processConnectionFirehoseEventUseCase: ProcessConnectionFirehoseEventUseCase;
99}
100
101export interface UseCases {
102 // User use cases
103 loginWithAppPasswordUseCase: LoginWithAppPasswordUseCase;
104 logoutUseCase: LogoutUseCase;
105 initiateOAuthSignInUseCase: InitiateOAuthSignInUseCase;
106 completeOAuthSignInUseCase: CompleteOAuthSignInUseCase;
107 getProfileUseCase: GetProfileUseCase;
108 refreshAccessTokenUseCase: RefreshAccessTokenUseCase;
109 generateExtensionTokensUseCase: GenerateExtensionTokensUseCase;
110 followTargetUseCase: FollowTargetUseCase;
111 unfollowTargetUseCase: UnfollowTargetUseCase;
112 getFollowingUsersUseCase: GetFollowingUsersUseCase;
113 getFollowersUseCase: GetFollowersUseCase;
114 getFollowingCollectionsUseCase: GetFollowingCollectionsUseCase;
115 getCollectionFollowersUseCase: GetCollectionFollowersUseCase;
116 getFollowingCountUseCase: GetFollowingCountUseCase;
117 getFollowersCountUseCase: GetFollowersCountUseCase;
118 getFollowingCollectionsCountUseCase: GetFollowingCollectionsCountUseCase;
119 getCollectionFollowersCountUseCase: GetCollectionFollowersCountUseCase;
120 getCollectionContributorsUseCase: GetCollectionContributorsUseCase;
121 // Card use cases
122 addUrlToLibraryUseCase: AddUrlToLibraryUseCase;
123 addCardToLibraryUseCase: AddCardToLibraryUseCase;
124 addCardToCollectionUseCase: AddCardToCollectionUseCase;
125 updateNoteCardUseCase: UpdateNoteCardUseCase;
126 updateUrlCardAssociationsUseCase: UpdateUrlCardAssociationsUseCase;
127 removeCardFromLibraryUseCase: RemoveCardFromLibraryUseCase;
128 removeCardFromCollectionUseCase: RemoveCardFromCollectionUseCase;
129 getUrlMetadataUseCase: GetUrlMetadataUseCase;
130 getUrlCardViewUseCase: GetUrlCardViewUseCase;
131 getLibrariesForCardUseCase: GetLibrariesForCardUseCase;
132 getMyUrlCardsUseCase: GetUrlCardsUseCase;
133 createCollectionUseCase: CreateCollectionUseCase;
134 updateCollectionUseCase: UpdateCollectionUseCase;
135 deleteCollectionUseCase: DeleteCollectionUseCase;
136 getCollectionPageUseCase: GetCollectionPageUseCase;
137 getCollectionPageByAtUriUseCase: GetCollectionPageByAtUriUseCase;
138 getCollectionsUseCase: GetCollectionsUseCase;
139 searchCollectionsUseCase: SearchCollectionsUseCase;
140 getOpenCollectionsWithContributorUseCase: GetOpenCollectionsWithContributorUseCase;
141 getUrlStatusForMyLibraryUseCase: GetUrlStatusForMyLibraryUseCase;
142 getLibrariesForUrlUseCase: GetLibrariesForUrlUseCase;
143 getCollectionsForUrlUseCase: GetCollectionsForUrlUseCase;
144 getNoteCardsForUrlUseCase: GetNoteCardsForUrlUseCase;
145 getForwardConnectionsForUrlUseCase: GetForwardConnectionsForUrlUseCase;
146 getBackwardConnectionsForUrlUseCase: GetBackwardConnectionsForUrlUseCase;
147 // Connection use cases
148 getConnectionsUseCase: GetConnectionsUseCase;
149 createConnectionUseCase: CreateConnectionUseCase;
150 updateConnectionUseCase: UpdateConnectionUseCase;
151 deleteConnectionUseCase: DeleteConnectionUseCase;
152 // Graph use cases
153 getGraphDataUseCase: GetGraphDataUseCase;
154 // Search use cases
155 searchUrlsUseCase: SearchUrlsUseCase;
156 // Feed use cases
157 getGlobalFeedUseCase: GetGlobalFeedUseCase;
158 getGemActivityFeedUseCase: GetGemActivityFeedUseCase;
159 getFollowingFeedUseCase: GetFollowingFeedUseCase;
160 addActivityToFeedUseCase: AddActivityToFeedUseCase;
161 // Search use cases
162 getSimilarUrlsForUrlUseCase: GetSimilarUrlsForUrlUseCase;
163 semanticSearchUrlsUseCase: SemanticSearchUrlsUseCase;
164 searchBskyPostsForUrlUseCase: SearchBskyPostsForUrlUseCase;
165 searchAtProtoAccountsUseCase: SearchAtProtoAccountsUseCase;
166 searchLeafletDocsForUrlUseCase: SearchLeafletDocsForUrlUseCase;
167 // Notification use cases
168 getMyNotificationsUseCase: GetMyNotificationsUseCase;
169 getUnreadNotificationCountUseCase: GetUnreadNotificationCountUseCase;
170 markNotificationsAsReadUseCase: MarkNotificationsAsReadUseCase;
171 markAllNotificationsAsReadUseCase: MarkAllNotificationsAsReadUseCase;
172}
173
174export class UseCaseFactory {
175 static create(repositories: Repositories, services: Services): UseCases {
176 return this.createForWebApp(repositories, services);
177 }
178
179 static createForWebApp(
180 repositories: Repositories,
181 services: Services,
182 ): UseCases {
183 const getCollectionPageUseCase = new GetCollectionPageUseCase(
184 repositories.collectionRepository,
185 repositories.cardQueryRepository,
186 services.profileService,
187 repositories.followsRepository,
188 );
189
190 return {
191 // User use cases
192 loginWithAppPasswordUseCase: new LoginWithAppPasswordUseCase(
193 services.appPasswordProcessor,
194 services.tokenService,
195 repositories.userRepository,
196 services.userAuthService,
197 ),
198 logoutUseCase: new LogoutUseCase(services.tokenService),
199 initiateOAuthSignInUseCase: new InitiateOAuthSignInUseCase(
200 services.oauthProcessor,
201 ),
202 completeOAuthSignInUseCase: new CompleteOAuthSignInUseCase(
203 services.oauthProcessor,
204 services.tokenService,
205 repositories.userRepository,
206 services.userAuthService,
207 ),
208 getProfileUseCase: new GetProfileUseCase(
209 services.profileService,
210 services.identityResolutionService,
211 repositories.followsRepository,
212 ),
213 refreshAccessTokenUseCase: new RefreshAccessTokenUseCase(
214 services.tokenService,
215 ),
216 generateExtensionTokensUseCase: new GenerateExtensionTokensUseCase(
217 services.tokenService,
218 ),
219 followTargetUseCase: new FollowTargetUseCase(
220 repositories.followsRepository,
221 repositories.userRepository,
222 repositories.collectionRepository,
223 services.followPublisher,
224 services.profileService,
225 repositories.cardQueryRepository,
226 services.eventPublisher,
227 ),
228 unfollowTargetUseCase: new UnfollowTargetUseCase(
229 repositories.followsRepository,
230 services.followPublisher,
231 services.profileService,
232 services.eventPublisher,
233 ),
234 getFollowingUsersUseCase: new GetFollowingUsersUseCase(
235 repositories.followsRepository,
236 services.identityResolutionService,
237 services.profileService,
238 ),
239 getFollowersUseCase: new GetFollowersUseCase(
240 repositories.followsRepository,
241 services.identityResolutionService,
242 services.profileService,
243 ),
244 getFollowingCollectionsUseCase: new GetFollowingCollectionsUseCase(
245 repositories.followsRepository,
246 services.identityResolutionService,
247 services.profileService,
248 repositories.collectionRepository,
249 ),
250 getCollectionFollowersUseCase: new GetCollectionFollowersUseCase(
251 repositories.followsRepository,
252 services.profileService,
253 repositories.collectionRepository,
254 ),
255 getFollowingCountUseCase: new GetFollowingCountUseCase(
256 repositories.followsRepository,
257 services.identityResolutionService,
258 ),
259 getFollowersCountUseCase: new GetFollowersCountUseCase(
260 repositories.followsRepository,
261 services.identityResolutionService,
262 ),
263 getFollowingCollectionsCountUseCase:
264 new GetFollowingCollectionsCountUseCase(
265 repositories.followsRepository,
266 services.identityResolutionService,
267 ),
268 getCollectionFollowersCountUseCase:
269 new GetCollectionFollowersCountUseCase(
270 repositories.followsRepository,
271 repositories.collectionRepository,
272 ),
273 getCollectionContributorsUseCase: new GetCollectionContributorsUseCase(
274 repositories.collectionQueryRepository,
275 services.profileService,
276 repositories.collectionRepository,
277 ),
278
279 // Card use cases
280 addUrlToLibraryUseCase: new AddUrlToLibraryUseCase(
281 repositories.cardRepository,
282 services.metadataService,
283 services.cardLibraryService,
284 services.cardCollectionService,
285 services.eventPublisher,
286 ),
287 addCardToLibraryUseCase: new AddCardToLibraryUseCase(
288 repositories.cardRepository,
289 services.cardLibraryService,
290 services.cardCollectionService,
291 ),
292 addCardToCollectionUseCase: new AddCardToCollectionUseCase(
293 repositories.cardRepository,
294 services.cardCollectionService,
295 services.eventPublisher,
296 ),
297 updateNoteCardUseCase: new UpdateNoteCardUseCase(
298 repositories.cardRepository,
299 services.cardPublisher,
300 ),
301 updateUrlCardAssociationsUseCase: new UpdateUrlCardAssociationsUseCase(
302 repositories.cardRepository,
303 services.cardLibraryService,
304 services.cardCollectionService,
305 services.eventPublisher,
306 ),
307 removeCardFromLibraryUseCase: new RemoveCardFromLibraryUseCase(
308 repositories.cardRepository,
309 services.cardLibraryService,
310 services.eventPublisher,
311 ),
312 removeCardFromCollectionUseCase: new RemoveCardFromCollectionUseCase(
313 repositories.cardRepository,
314 services.cardCollectionService,
315 services.eventPublisher,
316 ),
317 getUrlMetadataUseCase: new GetUrlMetadataUseCase(
318 services.metadataService,
319 repositories.cardRepository,
320 ),
321 getUrlCardViewUseCase: new GetUrlCardViewUseCase(
322 repositories.cardQueryRepository,
323 services.profileService,
324 repositories.collectionRepository,
325 ),
326 getLibrariesForCardUseCase: new GetLibrariesForCardUseCase(
327 repositories.cardQueryRepository,
328 services.profileService,
329 ),
330 getMyUrlCardsUseCase: new GetUrlCardsUseCase(
331 repositories.cardQueryRepository,
332 services.identityResolutionService,
333 services.profileService,
334 ),
335 createCollectionUseCase: new CreateCollectionUseCase(
336 repositories.collectionRepository,
337 services.collectionPublisher,
338 ),
339 updateCollectionUseCase: new UpdateCollectionUseCase(
340 repositories.collectionRepository,
341 services.collectionPublisher,
342 ),
343 deleteCollectionUseCase: new DeleteCollectionUseCase(
344 repositories.collectionRepository,
345 services.collectionPublisher,
346 ),
347 getCollectionPageUseCase,
348 getCollectionPageByAtUriUseCase: new GetCollectionPageByAtUriUseCase(
349 services.identityResolutionService,
350 repositories.atUriResolutionService,
351 getCollectionPageUseCase,
352 services.configService.getAtProtoCollections().collection,
353 services.configService.getAtProtoCollections().marginCollection,
354 ),
355 getCollectionsUseCase: new GetCollectionsUseCase(
356 repositories.collectionQueryRepository,
357 services.profileService,
358 services.identityResolutionService,
359 repositories.followsRepository,
360 ),
361 searchCollectionsUseCase: new SearchCollectionsUseCase(
362 repositories.collectionQueryRepository,
363 services.profileService,
364 services.identityResolutionService,
365 repositories.followsRepository,
366 ),
367 getOpenCollectionsWithContributorUseCase:
368 new GetOpenCollectionsWithContributorUseCase(
369 repositories.collectionQueryRepository,
370 services.profileService,
371 services.identityResolutionService,
372 repositories.followsRepository,
373 ),
374 getUrlStatusForMyLibraryUseCase: new GetUrlStatusForMyLibraryUseCase(
375 repositories.cardRepository,
376 repositories.cardQueryRepository,
377 repositories.collectionQueryRepository,
378 repositories.collectionRepository,
379 services.profileService,
380 repositories.followsRepository,
381 services.eventPublisher,
382 ),
383 getLibrariesForUrlUseCase: new GetLibrariesForUrlUseCase(
384 repositories.cardQueryRepository,
385 services.profileService,
386 ),
387 getCollectionsForUrlUseCase: new GetCollectionsForUrlUseCase(
388 repositories.collectionQueryRepository,
389 services.profileService,
390 repositories.collectionRepository,
391 repositories.followsRepository,
392 ),
393 getNoteCardsForUrlUseCase: new GetNoteCardsForUrlUseCase(
394 repositories.cardQueryRepository,
395 services.profileService,
396 ),
397 getForwardConnectionsForUrlUseCase:
398 new GetForwardConnectionsForUrlUseCase(
399 repositories.connectionQueryRepository,
400 repositories.cardQueryRepository,
401 services.profileService,
402 services.metadataService,
403 ),
404 getBackwardConnectionsForUrlUseCase:
405 new GetBackwardConnectionsForUrlUseCase(
406 repositories.connectionQueryRepository,
407 repositories.cardQueryRepository,
408 services.profileService,
409 services.metadataService,
410 ),
411
412 // Connection use cases
413 getConnectionsUseCase: new GetConnectionsUseCase(
414 repositories.connectionQueryRepository,
415 repositories.cardQueryRepository,
416 services.identityResolutionService,
417 services.metadataService,
418 ),
419 createConnectionUseCase: new CreateConnectionUseCase(
420 repositories.connectionRepository,
421 services.connectionPublisher,
422 services.eventPublisher,
423 ),
424 updateConnectionUseCase: new UpdateConnectionUseCase(
425 repositories.connectionRepository,
426 services.connectionPublisher,
427 ),
428 deleteConnectionUseCase: new DeleteConnectionUseCase(
429 repositories.connectionRepository,
430 services.connectionPublisher,
431 services.eventPublisher,
432 ),
433
434 // Graph use cases
435 getGraphDataUseCase: new GetGraphDataUseCase(
436 repositories.graphQueryRepository,
437 ),
438
439 // Search use cases
440 searchUrlsUseCase: new SearchUrlsUseCase(
441 repositories.cardQueryRepository,
442 ),
443
444 // Feed use cases
445 getGlobalFeedUseCase: new GetGlobalFeedUseCase(
446 repositories.feedRepository,
447 services.profileService,
448 repositories.cardQueryRepository,
449 repositories.collectionRepository,
450 repositories.followsRepository,
451 ),
452 getGemActivityFeedUseCase: new GetGemActivityFeedUseCase(
453 repositories.feedRepository,
454 services.profileService,
455 repositories.cardQueryRepository,
456 repositories.collectionRepository,
457 repositories.collectionQueryRepository,
458 ),
459 getFollowingFeedUseCase: new GetFollowingFeedUseCase(
460 repositories.feedRepository,
461 services.profileService,
462 repositories.cardQueryRepository,
463 repositories.collectionRepository,
464 ),
465 addActivityToFeedUseCase: new AddActivityToFeedUseCase(
466 services.feedService,
467 repositories.cardRepository,
468 repositories.followsRepository,
469 repositories.feedRepository,
470 ),
471 // Search use cases
472 getSimilarUrlsForUrlUseCase: new GetSimilarUrlsForUrlUseCase(
473 services.searchService,
474 ),
475 semanticSearchUrlsUseCase: new SemanticSearchUrlsUseCase(
476 services.searchService,
477 services.identityResolutionService,
478 ),
479 searchBskyPostsForUrlUseCase: new SearchBskyPostsForUrlUseCase(
480 services.atProtoAgentService,
481 ),
482 searchAtProtoAccountsUseCase: new SearchAtProtoAccountsUseCase(
483 services.atProtoAgentService,
484 ),
485 searchLeafletDocsForUrlUseCase: new SearchLeafletDocsForUrlUseCase(
486 services.leafletSearchService,
487 repositories.cardQueryRepository,
488 ),
489 // Notification use cases
490 getMyNotificationsUseCase: new GetMyNotificationsUseCase(
491 repositories.notificationRepository,
492 services.profileService,
493 ),
494 getUnreadNotificationCountUseCase: new GetUnreadNotificationCountUseCase(
495 repositories.notificationRepository,
496 ),
497 markNotificationsAsReadUseCase: new MarkNotificationsAsReadUseCase(
498 repositories.notificationRepository,
499 ),
500 markAllNotificationsAsReadUseCase: new MarkAllNotificationsAsReadUseCase(
501 repositories.notificationRepository,
502 ),
503 };
504 }
505
506 static createForWorker(
507 repositories: Repositories,
508 services: SharedServices,
509 ): WorkerUseCases {
510 // ========================================
511 // LEVEL 1: Leaf use cases (no use case dependencies)
512 // ========================================
513
514 // Feed use cases
515 const addActivityToFeedUseCase = new AddActivityToFeedUseCase(
516 services.feedService,
517 repositories.cardRepository,
518 repositories.followsRepository,
519 repositories.feedRepository,
520 );
521
522 // Search use cases
523 const indexUrlForSearchUseCase = new IndexUrlForSearchUseCase(
524 services.searchService,
525 );
526
527 // Notification use cases
528 const createNotificationUseCase = new CreateNotificationUseCase(
529 services.notificationService,
530 );
531
532 // Card library use cases
533 const addUrlToLibraryUseCase = new AddUrlToLibraryUseCase(
534 repositories.cardRepository,
535 services.metadataService,
536 services.cardLibraryService,
537 services.cardCollectionService,
538 services.eventPublisher,
539 );
540
541 const updateUrlCardAssociationsUseCase =
542 new UpdateUrlCardAssociationsUseCase(
543 repositories.cardRepository,
544 services.cardLibraryService,
545 services.cardCollectionService,
546 services.eventPublisher,
547 );
548
549 const removeCardFromLibraryUseCase = new RemoveCardFromLibraryUseCase(
550 repositories.cardRepository,
551 services.cardLibraryService,
552 services.eventPublisher,
553 );
554
555 // Collection use cases
556 const createCollectionUseCase = new CreateCollectionUseCase(
557 repositories.collectionRepository,
558 services.collectionPublisher,
559 );
560
561 const updateCollectionUseCase = new UpdateCollectionUseCase(
562 repositories.collectionRepository,
563 services.collectionPublisher,
564 );
565
566 const deleteCollectionUseCase = new DeleteCollectionUseCase(
567 repositories.collectionRepository,
568 services.collectionPublisher,
569 );
570
571 // Connection use cases
572 const createConnectionUseCase = new CreateConnectionUseCase(
573 repositories.connectionRepository,
574 services.connectionPublisher,
575 services.eventPublisher,
576 );
577
578 const updateConnectionUseCase = new UpdateConnectionUseCase(
579 repositories.connectionRepository,
580 services.connectionPublisher,
581 );
582
583 const deleteConnectionUseCase = new DeleteConnectionUseCase(
584 repositories.connectionRepository,
585 services.connectionPublisher,
586 services.eventPublisher,
587 );
588
589 // Follow use cases
590 const followTargetUseCase = new FollowTargetUseCase(
591 repositories.followsRepository,
592 repositories.userRepository,
593 repositories.collectionRepository,
594 services.followPublisher,
595 services.profileService,
596 repositories.cardQueryRepository,
597 services.eventPublisher,
598 );
599
600 const unfollowTargetUseCase = new UnfollowTargetUseCase(
601 repositories.followsRepository,
602 services.followPublisher,
603 services.profileService,
604 services.eventPublisher,
605 );
606
607 // ========================================
608 // LEVEL 2: Process use cases (depend on Level 1)
609 // ========================================
610
611 const processCardFirehoseEventUseCase = new ProcessCardFirehoseEventUseCase(
612 repositories.atUriResolutionService,
613 addUrlToLibraryUseCase,
614 updateUrlCardAssociationsUseCase,
615 removeCardFromLibraryUseCase,
616 repositories.cardRepository,
617 );
618
619 const processCollectionFirehoseEventUseCase =
620 new ProcessCollectionFirehoseEventUseCase(
621 repositories.atUriResolutionService,
622 createCollectionUseCase,
623 updateCollectionUseCase,
624 deleteCollectionUseCase,
625 );
626
627 const processCollectionLinkFirehoseEventUseCase =
628 new ProcessCollectionLinkFirehoseEventUseCase(
629 repositories.atUriResolutionService,
630 updateUrlCardAssociationsUseCase,
631 );
632
633 const processCollectionLinkRemovalFirehoseEventUseCase =
634 new ProcessCollectionLinkRemovalFirehoseEventUseCase(
635 repositories.atUriResolutionService,
636 updateUrlCardAssociationsUseCase,
637 );
638
639 const processMarginBookmarkFirehoseEventUseCase =
640 new ProcessMarginBookmarkFirehoseEventUseCase(
641 repositories.atUriResolutionService,
642 addUrlToLibraryUseCase,
643 removeCardFromLibraryUseCase,
644 );
645
646 const processMarginCollectionFirehoseEventUseCase =
647 new ProcessMarginCollectionFirehoseEventUseCase(
648 repositories.atUriResolutionService,
649 createCollectionUseCase,
650 updateCollectionUseCase,
651 deleteCollectionUseCase,
652 );
653
654 const processMarginCollectionItemFirehoseEventUseCase =
655 new ProcessMarginCollectionItemFirehoseEventUseCase(
656 repositories.atUriResolutionService,
657 updateUrlCardAssociationsUseCase,
658 );
659
660 const processFollowFirehoseEventUseCase =
661 new ProcessFollowFirehoseEventUseCase(
662 repositories.atUriResolutionService,
663 followTargetUseCase,
664 unfollowTargetUseCase,
665 repositories.followsRepository,
666 repositories.userRepository,
667 repositories.collectionRepository,
668 );
669
670 const processConnectionFirehoseEventUseCase =
671 new ProcessConnectionFirehoseEventUseCase(
672 repositories.atUriResolutionService,
673 createConnectionUseCase,
674 updateConnectionUseCase,
675 deleteConnectionUseCase,
676 );
677
678 // ========================================
679 // LEVEL 3: Sync use cases (depend on Level 2)
680 // ========================================
681
682 const syncAccountDataUseCase = new SyncAccountDataUseCase(
683 repositories.syncStatusRepository,
684 services.atProtoRepoService,
685 repositories.atUriResolutionService,
686 processMarginBookmarkFirehoseEventUseCase,
687 processMarginCollectionFirehoseEventUseCase,
688 processMarginCollectionItemFirehoseEventUseCase,
689 );
690
691 // ========================================
692 // Return all use cases
693 // ========================================
694
695 return {
696 // Level 1
697 addActivityToFeedUseCase,
698 indexUrlForSearchUseCase,
699 createNotificationUseCase,
700 addUrlToLibraryUseCase,
701 updateUrlCardAssociationsUseCase,
702 removeCardFromLibraryUseCase,
703 createCollectionUseCase,
704 updateCollectionUseCase,
705 deleteCollectionUseCase,
706 // Level 2
707 processCardFirehoseEventUseCase,
708 processCollectionFirehoseEventUseCase,
709 processCollectionLinkFirehoseEventUseCase,
710 processCollectionLinkRemovalFirehoseEventUseCase,
711 processMarginBookmarkFirehoseEventUseCase,
712 processMarginCollectionFirehoseEventUseCase,
713 processMarginCollectionItemFirehoseEventUseCase,
714 processFollowFirehoseEventUseCase,
715 processConnectionFirehoseEventUseCase,
716 // Level 3
717 syncAccountDataUseCase,
718 };
719 }
720}