This repository has no description
0

Configure Feed

Select the types of activity you want to include in your feed.

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