From fa697c7a5c78c5c05a2fcaebb166dd81606212e1 Mon Sep 17 00:00:00 2001 From: Wesley Finck Date: Fri, 17 Apr 2026 19:11:13 -0700 Subject: [PATCH] rename xrpc mention to page parts --- .../queries/PagePartsSearchUseCase.ts | 59 ++++++++----------- .../controllers/PagePartsSearchController.ts | 8 +-- src/shared/infrastructure/http/app.ts | 2 +- .../http/factories/ControllerFactory.ts | 8 +-- .../http/factories/UseCaseFactory.ts | 8 +-- 5 files changed, 38 insertions(+), 47 deletions(-) diff --git a/src/modules/search/application/useCases/queries/PagePartsSearchUseCase.ts b/src/modules/search/application/useCases/queries/PagePartsSearchUseCase.ts index 11716335..fe70a3bd 100644 --- a/src/modules/search/application/useCases/queries/PagePartsSearchUseCase.ts +++ b/src/modules/search/application/useCases/queries/PagePartsSearchUseCase.ts @@ -19,11 +19,11 @@ import { DID } from '../../../../atproto/domain/DID'; import { CollectionId } from 'src/modules/cards/domain/value-objects/CollectionId'; // XRPC parts.page.mention.search types based on lexicon -export interface XrpcMentionLabel { +export interface PagePartsLabel { text: string; } -export interface XrpcEmbedInfo { +export interface PagePartsEmbedInfo { src: string; width?: number; height?: number; @@ -33,27 +33,27 @@ export interface XrpcEmbedInfo { }; } -export interface XrpcSubscopeInfo { +export interface PagePartsSubscopeInfo { scope: string; label: string; } -export interface XrpcMentionSearchResult { +export interface PagePartsSearchResult { uri: string; name: string; description?: string; - labels?: XrpcMentionLabel[]; + labels?: PagePartsLabel[]; href?: string; icon?: string; - embed?: XrpcEmbedInfo; - subscope?: XrpcSubscopeInfo; + embed?: PagePartsEmbedInfo; + subscope?: PagePartsSubscopeInfo; } -export interface XrpcMentionSearchResponse { - results: XrpcMentionSearchResult[]; +export interface PagePartsSearchResponse { + results: PagePartsSearchResult[]; } -export interface XrpcMentionSearchQuery { +export interface PagePartsSearchQuery { service: string; search: string; scope?: string; @@ -71,7 +71,7 @@ const CARD_SEARCH_SERVICE = /** * Encapsulates the logic for determining search parameters based on service type and scope */ -class MentionSearchContext { +class PagePartsSearchContext { private parsedScope?: DIDOrATUri; private scopeIdentifier?: string; @@ -196,12 +196,12 @@ export class ValidationError extends UseCaseError { } } -export class XrpcMentionSearchUseCase +export class PagePartsSearchUseCase implements UseCase< - XrpcMentionSearchQuery, + PagePartsSearchQuery, Result< - XrpcMentionSearchResponse, + PagePartsSearchResponse, ValidationError | AppError.UnexpectedError > > @@ -213,16 +213,13 @@ export class XrpcMentionSearchUseCase ) {} async execute( - query: XrpcMentionSearchQuery, + query: PagePartsSearchQuery, ): Promise< - Result< - XrpcMentionSearchResponse, - ValidationError | AppError.UnexpectedError - > + Result > { try { // Create and initialize search context - const context = new MentionSearchContext( + const context = new PagePartsSearchContext( query.service, query.scope, query.search, @@ -255,13 +252,10 @@ export class XrpcMentionSearchUseCase } private async handleCollectionSearch( - query: XrpcMentionSearchQuery, - context: MentionSearchContext, + query: PagePartsSearchQuery, + context: PagePartsSearchContext, ): Promise< - Result< - XrpcMentionSearchResponse, - ValidationError | AppError.UnexpectedError - > + Result > { const result = await this.searchCollectionsUseCase.execute({ searchText: query.search || '', @@ -277,7 +271,7 @@ export class XrpcMentionSearchUseCase return err(AppError.UnexpectedError.create(result.error)); } - const mappedResults: XrpcMentionSearchResult[] = []; + const mappedResults: PagePartsSearchResult[] = []; for (const collection of result.value.collections) { if (!collection.uri) { @@ -322,13 +316,10 @@ export class XrpcMentionSearchUseCase } private async handleCardSearch( - query: XrpcMentionSearchQuery, - context: MentionSearchContext, + query: PagePartsSearchQuery, + context: PagePartsSearchContext, ): Promise< - Result< - XrpcMentionSearchResponse, - ValidationError | AppError.UnexpectedError - > + Result > { const filtersResult = await context.getCardSearchFilters( this.atUriResolutionService, @@ -354,7 +345,7 @@ export class XrpcMentionSearchUseCase return err(AppError.UnexpectedError.create(result.error)); } - const mappedResults: XrpcMentionSearchResult[] = result.value.urls.map( + const mappedResults: PagePartsSearchResult[] = result.value.urls.map( (urlView) => ({ uri: urlView.url, name: urlView.metadata.title || urlView.url, diff --git a/src/modules/search/infrastructure/http/controllers/PagePartsSearchController.ts b/src/modules/search/infrastructure/http/controllers/PagePartsSearchController.ts index 454fcdf1..6ab1786c 100644 --- a/src/modules/search/infrastructure/http/controllers/PagePartsSearchController.ts +++ b/src/modules/search/infrastructure/http/controllers/PagePartsSearchController.ts @@ -1,13 +1,13 @@ import { Controller } from '../../../../../shared/infrastructure/http/Controller'; import { Response } from 'express'; -import { XrpcMentionSearchUseCase } from '../../../application/useCases/queries/PagePartsSearchUseCase'; +import { PagePartsSearchUseCase } from '../../../application/useCases/queries/PagePartsSearchUseCase'; import { AuthenticatedRequest } from '../../../../../shared/infrastructure/http/middleware/AuthMiddleware'; import { parseReqNsid, verifyJwt } from '@atproto/xrpc-server'; import { IIdentityResolutionService } from '../../../../../modules/atproto/domain/services/IIdentityResolutionService'; -export class XrpcMentionSearchController extends Controller { +export class PagePartsSearchController extends Controller { constructor( - private xrpcMentionSearchUseCase: XrpcMentionSearchUseCase, + private pagePartsSearchUseCase: PagePartsSearchUseCase, private appUrl: string, private serviceDid: string, private identityResolutionService: IIdentityResolutionService, @@ -64,7 +64,7 @@ export class XrpcMentionSearchController extends Controller { // Validate JWT and extract DID (optional) const callingUserId = await this.validateAuth(req); - const result = await this.xrpcMentionSearchUseCase.execute({ + const result = await this.pagePartsSearchUseCase.execute({ service: serviceUri, search: search || '', scope, diff --git a/src/shared/infrastructure/http/app.ts b/src/shared/infrastructure/http/app.ts index ec243d86..20a3e327 100644 --- a/src/shared/infrastructure/http/app.ts +++ b/src/shared/infrastructure/http/app.ts @@ -216,7 +216,7 @@ export const createExpressApp = ( // XRPC mention search endpoint app.get('/xrpc/parts.page.mention.search', (req, res) => { console.log('Received XRPC mention search request with query:', req.query); - return controllers.xrpcMentionSearchController.execute(req, res); + return controllers.pagePartsSearchController.execute(req, res); }); // Register routes diff --git a/src/shared/infrastructure/http/factories/ControllerFactory.ts b/src/shared/infrastructure/http/factories/ControllerFactory.ts index b6bbf309..24c61ffe 100644 --- a/src/shared/infrastructure/http/factories/ControllerFactory.ts +++ b/src/shared/infrastructure/http/factories/ControllerFactory.ts @@ -26,7 +26,7 @@ import { SemanticSearchUrlsController } from '../../../../modules/search/infrast import { SearchBskyPostsForUrlController } from '../../../../modules/search/infrastructure/http/controllers/SearchBskyPostsForUrlController'; import { SearchAtProtoAccountsController } from '../../../../modules/search/infrastructure/http/controllers/SearchAtProtoAccountsController'; import { SearchLeafletDocsForUrlController } from '../../../../modules/search/infrastructure/http/controllers/SearchLeafletDocsForUrlController'; -import { XrpcMentionSearchController } from '../../../../modules/search/infrastructure/http/controllers/PagePartsSearchController'; +import { PagePartsSearchController } from '../../../../modules/search/infrastructure/http/controllers/PagePartsSearchController'; import { UseCases } from './UseCaseFactory'; import { GetMyProfileController } from 'src/modules/cards/infrastructure/http/controllers/GetMyProfileController'; import { GetUserProfileController } from 'src/modules/cards/infrastructure/http/controllers/GetUserProfileController'; @@ -140,7 +140,7 @@ export interface Controllers { searchBskyPostsForUrlController: SearchBskyPostsForUrlController; searchAtProtoAccountsController: SearchAtProtoAccountsController; searchLeafletDocsForUrlController: SearchLeafletDocsForUrlController; - xrpcMentionSearchController: XrpcMentionSearchController; + pagePartsSearchController: PagePartsSearchController; // Notification controllers getMyNotificationsController: GetMyNotificationsController; getUnreadNotificationCountController: GetUnreadNotificationCountController; @@ -368,8 +368,8 @@ export class ControllerFactory { searchLeafletDocsForUrlController: new SearchLeafletDocsForUrlController( useCases.searchLeafletDocsForUrlUseCase, ), - xrpcMentionSearchController: new XrpcMentionSearchController( - useCases.xrpcMentionSearchUseCase, + pagePartsSearchController: new PagePartsSearchController( + useCases.pagePartsSearchUseCase, appUrl, serviceDid, services.identityResolutionService, diff --git a/src/shared/infrastructure/http/factories/UseCaseFactory.ts b/src/shared/infrastructure/http/factories/UseCaseFactory.ts index c65880c1..d3eae005 100644 --- a/src/shared/infrastructure/http/factories/UseCaseFactory.ts +++ b/src/shared/infrastructure/http/factories/UseCaseFactory.ts @@ -42,7 +42,7 @@ import { SemanticSearchUrlsUseCase } from '../../../../modules/search/applicatio import { SearchBskyPostsForUrlUseCase } from '../../../../modules/search/application/use-cases/SearchBskyPostsForUrlUseCase'; import { SearchAtProtoAccountsUseCase } from '../../../../modules/search/application/use-cases/SearchAtProtoAccountsUseCase'; import { SearchLeafletDocsForUrlUseCase } from '../../../../modules/search/application/use-cases/SearchLeafletDocsForUrlUseCase'; -import { XrpcMentionSearchUseCase } from '../../../../modules/search/application/useCases/queries/PagePartsSearchUseCase'; +import { PagePartsSearchUseCase } from '../../../../modules/search/application/useCases/queries/PagePartsSearchUseCase'; import { ProcessCardFirehoseEventUseCase } from '../../../../modules/atproto/application/useCases/ProcessCardFirehoseEventUseCase'; import { ProcessCollectionFirehoseEventUseCase } from '../../../../modules/atproto/application/useCases/ProcessCollectionFirehoseEventUseCase'; import { ProcessCollectionLinkFirehoseEventUseCase } from '../../../../modules/atproto/application/useCases/ProcessCollectionLinkFirehoseEventUseCase'; @@ -169,7 +169,7 @@ export interface UseCases { searchBskyPostsForUrlUseCase: SearchBskyPostsForUrlUseCase; searchAtProtoAccountsUseCase: SearchAtProtoAccountsUseCase; searchLeafletDocsForUrlUseCase: SearchLeafletDocsForUrlUseCase; - xrpcMentionSearchUseCase: XrpcMentionSearchUseCase; + pagePartsSearchUseCase: PagePartsSearchUseCase; // Notification use cases getMyNotificationsUseCase: GetMyNotificationsUseCase; getUnreadNotificationCountUseCase: GetUnreadNotificationCountUseCase; @@ -204,7 +204,7 @@ export class UseCaseFactory { repositories.followsRepository, ); - const xrpcMentionSearchUseCase = new XrpcMentionSearchUseCase( + const pagePartsSearchUseCase = new PagePartsSearchUseCase( searchUrlsUseCase, searchCollectionsUseCase, repositories.atUriResolutionService, @@ -510,7 +510,7 @@ export class UseCaseFactory { services.leafletSearchService, repositories.cardQueryRepository, ), - xrpcMentionSearchUseCase, + pagePartsSearchUseCase, // Notification use cases getMyNotificationsUseCase: new GetMyNotificationsUseCase( repositories.notificationRepository, -- 2.51.2