A social knowledge tool for researchers built on ATProto
45
fork

Configure Feed

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

format and linting

+106 -59
+31 -14
src/modules/atproto/domain/DIDOrHandle.ts
··· 34 34 super(props); 35 35 } 36 36 37 - public static create(value: string): Result<DIDOrHandle, InvalidDIDOrHandleError> { 37 + public static create( 38 + value: string, 39 + ): Result<DIDOrHandle, InvalidDIDOrHandleError> { 38 40 if (!value || value.trim().length === 0) { 39 41 return err(new InvalidDIDOrHandleError('Value cannot be empty')); 40 42 } ··· 45 47 if (trimmedValue.startsWith('did:')) { 46 48 const didResult = DID.create(trimmedValue); 47 49 if (didResult.isErr()) { 48 - return err(new InvalidDIDOrHandleError(`Invalid DID: ${didResult.error.message}`)); 50 + return err( 51 + new InvalidDIDOrHandleError( 52 + `Invalid DID: ${didResult.error.message}`, 53 + ), 54 + ); 49 55 } 50 56 51 - return ok(new DIDOrHandle({ 52 - value: trimmedValue, 53 - isDID: true, 54 - did: didResult.value, 55 - })); 57 + return ok( 58 + new DIDOrHandle({ 59 + value: trimmedValue, 60 + isDID: true, 61 + did: didResult.value, 62 + }), 63 + ); 56 64 } 57 65 58 66 // Otherwise, try to parse as handle 59 67 const handleResult = Handle.create(trimmedValue); 60 68 if (handleResult.isErr()) { 61 - return err(new InvalidDIDOrHandleError(`Invalid handle: ${handleResult.error.message}`)); 69 + return err( 70 + new InvalidDIDOrHandleError( 71 + `Invalid handle: ${handleResult.error.message}`, 72 + ), 73 + ); 62 74 } 63 75 64 - return ok(new DIDOrHandle({ 65 - value: trimmedValue, 66 - isDID: false, 67 - handle: handleResult.value, 68 - })); 76 + return ok( 77 + new DIDOrHandle({ 78 + value: trimmedValue, 79 + isDID: false, 80 + handle: handleResult.value, 81 + }), 82 + ); 69 83 } 70 84 71 85 public getDID(): DID | undefined { ··· 81 95 } 82 96 83 97 public equals(other: DIDOrHandle): boolean { 84 - return this.props.value === other.props.value && this.props.isDID === other.props.isDID; 98 + return ( 99 + this.props.value === other.props.value && 100 + this.props.isDID === other.props.isDID 101 + ); 85 102 } 86 103 }
+6 -2
src/modules/atproto/domain/Handle.ts
··· 44 44 } 45 45 46 46 // Must not start or end with dot or hyphen 47 - if (domain.startsWith('.') || domain.endsWith('.') || 48 - domain.startsWith('-') || domain.endsWith('-')) { 47 + if ( 48 + domain.startsWith('.') || 49 + domain.endsWith('.') || 50 + domain.startsWith('-') || 51 + domain.endsWith('-') 52 + ) { 49 53 return false; 50 54 } 51 55
+4 -4
src/modules/atproto/infrastructure/publishers/ATProtoCardPublisher.ts
··· 23 23 try { 24 24 const record = CardMapper.toCreateRecordDTO(card); 25 25 const curatorDidResult = DID.create(curatorId.value); 26 - 26 + 27 27 if (curatorDidResult.isErr()) { 28 28 return err( 29 29 new Error(`Invalid curator DID: ${curatorDidResult.error.message}`), 30 30 ); 31 31 } 32 - 32 + 33 33 const curatorDid = curatorDidResult.value; 34 34 35 35 // Get an authenticated agent for this curator ··· 105 105 const strongRef = new StrongRef(publishedRecordId); 106 106 const atUri = strongRef.atUri; 107 107 const curatorDidResult = DID.create(curatorId.value); 108 - 108 + 109 109 if (curatorDidResult.isErr()) { 110 110 return err( 111 111 new Error(`Invalid curator DID: ${curatorDidResult.error.message}`), 112 112 ); 113 113 } 114 - 114 + 115 115 const curatorDid = curatorDidResult.value; 116 116 const repo = curatorDid.value; 117 117 const rkey = atUri.rkey;
+4 -4
src/modules/atproto/infrastructure/publishers/ATProtoCollectionPublisher.ts
··· 25 25 ): Promise<Result<PublishedRecordId, UseCaseError>> { 26 26 try { 27 27 const curatorDidResult = DID.create(collection.authorId.value); 28 - 28 + 29 29 if (curatorDidResult.isErr()) { 30 30 return err( 31 31 new Error(`Invalid curator DID: ${curatorDidResult.error.message}`), 32 32 ); 33 33 } 34 - 34 + 35 35 const curatorDid = curatorDidResult.value; 36 36 37 37 // Get an authenticated agent for this curator ··· 103 103 ): Promise<Result<PublishedRecordId, UseCaseError>> { 104 104 try { 105 105 const curatorDidResult = DID.create(curatorId.value); 106 - 106 + 107 107 if (curatorDidResult.isErr()) { 108 108 return err( 109 109 new Error(`Invalid curator DID: ${curatorDidResult.error.message}`), 110 110 ); 111 111 } 112 - 112 + 113 113 const curatorDid = curatorDidResult.value; 114 114 115 115 // Get an authenticated agent for this curator
+3 -1
src/modules/atproto/infrastructure/services/ATProtoIdentityResolutionService.ts
··· 4 4 import { DIDOrHandle } from '../../domain/DIDOrHandle'; 5 5 import { IAgentService } from '../../application/IAgentService'; 6 6 7 - export class ATProtoIdentityResolutionService implements IIdentityResolutionService { 7 + export class ATProtoIdentityResolutionService 8 + implements IIdentityResolutionService 9 + { 8 10 constructor(private readonly agentService: IAgentService) {} 9 11 10 12 async resolveToDID(identifier: DIDOrHandle): Promise<Result<DID>> {
+2 -4
src/modules/atproto/infrastructure/services/BlueskyProfileService.ts
··· 21 21 const didResult = DID.create(callerDid); 22 22 if (didResult.isErr()) { 23 23 return err( 24 - new Error( 25 - `Invalid caller DID: ${didResult.error.message}`, 26 - ), 24 + new Error(`Invalid caller DID: ${didResult.error.message}`), 27 25 ); 28 26 } 29 - 27 + 30 28 const agentResult = await this.agentService.getAuthenticatedAgent( 31 29 didResult.value, 32 30 );
+3 -1
src/modules/atproto/tests/domain/DID.test.ts
··· 73 73 }); 74 74 75 75 it('should reject unsupported DID method', () => { 76 - const result = DID.create('did:key:z6MkhaXgBZDvotDkL5257faiztiGiC2QtKLGpbnnEGta2doK'); 76 + const result = DID.create( 77 + 'did:key:z6MkhaXgBZDvotDkL5257faiztiGiC2QtKLGpbnnEGta2doK', 78 + ); 77 79 78 80 expect(result.isErr()).toBe(true); 79 81 if (result.isErr()) {
+16 -15
src/modules/cards/application/useCases/queries/GetCollectionsUseCase.ts
··· 80 80 } 81 81 82 82 // Resolve to DID 83 - const didResult = await this.identityResolver.resolveToDID(identifierResult.value); 83 + const didResult = await this.identityResolver.resolveToDID( 84 + identifierResult.value, 85 + ); 84 86 if (didResult.isErr()) { 85 - return err(new ValidationError(`Could not resolve curator identifier: ${didResult.error.message}`)); 87 + return err( 88 + new ValidationError( 89 + `Could not resolve curator identifier: ${didResult.error.message}`, 90 + ), 91 + ); 86 92 } 87 93 88 94 const resolvedDid = didResult.value.value; 89 95 90 96 try { 91 97 // Execute query to get raw collection data using the resolved DID 92 - const result = await this.collectionQueryRepo.findByCreator( 93 - resolvedDid, 94 - { 95 - page, 96 - limit, 97 - sortBy, 98 - sortOrder, 99 - searchText: query.searchText, 100 - }, 101 - ); 98 + const result = await this.collectionQueryRepo.findByCreator(resolvedDid, { 99 + page, 100 + limit, 101 + sortBy, 102 + sortOrder, 103 + searchText: query.searchText, 104 + }); 102 105 103 106 // Get user profile for the curator using the resolved DID 104 - const profileResult = await this.profileService.getProfile( 105 - resolvedDid, 106 - ); 107 + const profileResult = await this.profileService.getProfile(resolvedDid); 107 108 108 109 if (profileResult.isErr()) { 109 110 return err(
+11 -3
src/modules/cards/application/useCases/queries/GetProfileUseCase.ts
··· 44 44 } 45 45 46 46 // Resolve to DID 47 - const didResult = await this.identityResolver.resolveToDID(identifierResult.value); 47 + const didResult = await this.identityResolver.resolveToDID( 48 + identifierResult.value, 49 + ); 48 50 if (didResult.isErr()) { 49 - return err(new ValidationError(`Could not resolve user identifier: ${didResult.error.message}`)); 51 + return err( 52 + new ValidationError( 53 + `Could not resolve user identifier: ${didResult.error.message}`, 54 + ), 55 + ); 50 56 } 51 57 52 58 try { 53 59 // Fetch user profile using the resolved DID 54 - const profileResult = await this.profileService.getProfile(didResult.value.value); 60 + const profileResult = await this.profileService.getProfile( 61 + didResult.value.value, 62 + ); 55 63 56 64 if (profileResult.isErr()) { 57 65 return err(
+17 -8
src/modules/cards/application/useCases/queries/GetUrlCardsUseCase.ts
··· 64 64 } 65 65 66 66 // Resolve to DID 67 - const didResult = await this.identityResolver.resolveToDID(identifierResult.value); 67 + const didResult = await this.identityResolver.resolveToDID( 68 + identifierResult.value, 69 + ); 68 70 if (didResult.isErr()) { 69 - return err(new ValidationError(`Could not resolve user identifier: ${didResult.error.message}`)); 71 + return err( 72 + new ValidationError( 73 + `Could not resolve user identifier: ${didResult.error.message}`, 74 + ), 75 + ); 70 76 } 71 77 72 78 try { 73 79 // Execute query to get raw card data using the resolved DID 74 - const result = await this.cardQueryRepo.getUrlCardsOfUser(didResult.value.value, { 75 - page, 76 - limit, 77 - sortBy, 78 - sortOrder, 79 - }); 80 + const result = await this.cardQueryRepo.getUrlCardsOfUser( 81 + didResult.value.value, 82 + { 83 + page, 84 + limit, 85 + sortBy, 86 + sortOrder, 87 + }, 88 + ); 80 89 81 90 // Transform raw data to enriched DTOs 82 91 const enrichedCards: UrlCardListItemDTO[] = result.items;
+6 -2
src/modules/cards/tests/utils/FakeIdentityResolutionService.ts
··· 3 3 import { DID } from 'src/modules/atproto/domain/DID'; 4 4 import { DIDOrHandle } from 'src/modules/atproto/domain/DIDOrHandle'; 5 5 6 - export class FakeIdentityResolutionService implements IIdentityResolutionService { 6 + export class FakeIdentityResolutionService 7 + implements IIdentityResolutionService 8 + { 7 9 private handleToDIDMap: Map<string, string> = new Map(); 8 10 private shouldFail = false; 9 11 ··· 37 39 // Create and return the DID 38 40 const didResult = DID.create(mappedDID); 39 41 if (didResult.isErr()) { 40 - return err(new Error(`Invalid DID in mapping: ${didResult.error.message}`)); 42 + return err( 43 + new Error(`Invalid DID in mapping: ${didResult.error.message}`), 44 + ); 41 45 } 42 46 43 47 return ok(didResult.value);
+3 -1
src/shared/infrastructure/http/factories/ServiceFactory.ts
··· 274 274 const feedService = new FeedService(repositories.feedRepository); 275 275 276 276 // Identity Resolution Service 277 - const identityResolutionService = new ATProtoIdentityResolutionService(atProtoAgentService); 277 + const identityResolutionService = new ATProtoIdentityResolutionService( 278 + atProtoAgentService, 279 + ); 278 280 279 281 return { 280 282 tokenService,