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