From 64e24cea4e31a8ada8a51d9c51484ed59694ae90 Mon Sep 17 00:00:00 2001 From: Wesley Finck Date: Fri, 3 Oct 2025 10:31:01 -0700 Subject: [PATCH 1/2] remove dummy did usage and note title --- .../ATProtoCardPublisher.integration.test.ts | 6 ++--- .../commands/UpdateNoteCardUseCase.ts | 1 - src/modules/cards/domain/CardFactory.ts | 3 +-- .../cards/domain/value-objects/CardContent.ts | 5 ++-- .../repositories/mappers/CardMapper.ts | 5 +++- .../GetCollectionPageUseCase.test.ts | 1 + .../application/GetUrlCardViewUseCase.test.ts | 1 + ...y.getCardsInCollection.integration.test.ts | 8 +++---- ...ository.getUrlCardView.integration.test.ts | 7 +++--- ...tory.getUrlCardsOfUser.integration.test.ts | 4 ++-- .../DrizzleCardRepository.integration.test.ts | 24 ++++++++++++++----- .../cards/tests/utils/builders/CardBuilder.ts | 9 +++---- 12 files changed, 44 insertions(+), 30 deletions(-) diff --git a/src/modules/atproto/infrastructure/__tests__/ATProtoCardPublisher.integration.test.ts b/src/modules/atproto/infrastructure/__tests__/ATProtoCardPublisher.integration.test.ts index 4010aa6c..a565c562 100644 --- a/src/modules/atproto/infrastructure/__tests__/ATProtoCardPublisher.integration.test.ts +++ b/src/modules/atproto/infrastructure/__tests__/ATProtoCardPublisher.integration.test.ts @@ -144,7 +144,7 @@ describe('ATProtoCardPublisher', () => { // Create a note card const noteCard = new CardBuilder() .withCuratorId(curatorId.value) - .withNoteCard('This is a test note for publishing', 'Test Note Title') + .withNoteCard('This is a test note for publishing') .buildOrThrow(); // Add card to curator's library first @@ -201,7 +201,7 @@ describe('ATProtoCardPublisher', () => { // Create a note card with optional URL const noteCard = new CardBuilder() .withCuratorId(curatorId.value) - .withNoteCard('This note references a URL', 'Note with URL') + .withNoteCard('This note references a URL') .withUrl(referenceUrl) .buildOrThrow(); @@ -302,7 +302,7 @@ describe('ATProtoCardPublisher', () => { // 2. Create a note card that references the parent URL card const noteCard = new CardBuilder() .withCuratorId(curatorId.value) - .withNoteCard('This is my note about the parent article', 'My Notes') + .withNoteCard('This is my note about the parent article') .withParentCard(parentUrlCard.cardId) .withUrl(parentUrl) // Optional: include the same URL as reference .buildOrThrow(); diff --git a/src/modules/cards/application/useCases/commands/UpdateNoteCardUseCase.ts b/src/modules/cards/application/useCases/commands/UpdateNoteCardUseCase.ts index c9615e20..3528d79f 100644 --- a/src/modules/cards/application/useCases/commands/UpdateNoteCardUseCase.ts +++ b/src/modules/cards/application/useCases/commands/UpdateNoteCardUseCase.ts @@ -110,7 +110,6 @@ export class UpdateNoteCardUseCase // Create new card content with updated note const updatedCardContentResult = CardContent.createNoteContent( request.note, - undefined, curatorId, ); if (updatedCardContentResult.isErr()) { diff --git a/src/modules/cards/domain/CardFactory.ts b/src/modules/cards/domain/CardFactory.ts index d0c7a287..9462e4fb 100644 --- a/src/modules/cards/domain/CardFactory.ts +++ b/src/modules/cards/domain/CardFactory.ts @@ -17,7 +17,6 @@ export interface IUrlCardInput { export interface INoteCardInput { type: CardTypeEnum.NOTE; text: string; - title?: string; parentCardId?: string; url?: string; } @@ -160,7 +159,7 @@ export class CardFactory { input: INoteCardInput, curatorId: CuratorId, ): Result { - return CardContent.createNoteContent(input.text, input.title, curatorId); + return CardContent.createNoteContent(input.text, curatorId); } // Type guards diff --git a/src/modules/cards/domain/value-objects/CardContent.ts b/src/modules/cards/domain/value-objects/CardContent.ts index 82afaed3..29760ca7 100644 --- a/src/modules/cards/domain/value-objects/CardContent.ts +++ b/src/modules/cards/domain/value-objects/CardContent.ts @@ -59,11 +59,10 @@ export class CardContent extends ValueObject<{ content: CardContentUnion }> { public static createNoteContent( text: string, - title?: string, - curatorId?: CuratorId, + curatorId: CuratorId, ): Result { // Use provided curatorId or create a dummy one for backward compatibility - const authorId = curatorId || CuratorId.create('did:plc:dummy').unwrap(); + const authorId = curatorId; const noteContentResult = NoteCardContent.create(authorId, text); if (noteContentResult.isErr()) { return err( diff --git a/src/modules/cards/infrastructure/repositories/mappers/CardMapper.ts b/src/modules/cards/infrastructure/repositories/mappers/CardMapper.ts index 74145e3e..958954a4 100644 --- a/src/modules/cards/infrastructure/repositories/mappers/CardMapper.ts +++ b/src/modules/cards/infrastructure/repositories/mappers/CardMapper.ts @@ -208,7 +208,10 @@ export class CardMapper { const noteData = data as NoteContentData; const authorIdResult = CuratorId.create(noteData.authorId); if (authorIdResult.isErr()) return err(authorIdResult.error); - return CardContent.createNoteContent(noteData.text); + return CardContent.createNoteContent( + noteData.text, + authorIdResult.value, + ); } default: diff --git a/src/modules/cards/tests/application/GetCollectionPageUseCase.test.ts b/src/modules/cards/tests/application/GetCollectionPageUseCase.test.ts index 933c91c7..2bb0a48c 100644 --- a/src/modules/cards/tests/application/GetCollectionPageUseCase.test.ts +++ b/src/modules/cards/tests/application/GetCollectionPageUseCase.test.ts @@ -255,6 +255,7 @@ describe('GetCollectionPageUseCase', () => { type: CardType.create(CardTypeEnum.NOTE).unwrap(), content: CardContent.createNoteContent( 'This is my note about the article', + curatorId, ).unwrap(), parentCardId: card.cardId, url: url, diff --git a/src/modules/cards/tests/application/GetUrlCardViewUseCase.test.ts b/src/modules/cards/tests/application/GetUrlCardViewUseCase.test.ts index d42d9da8..56df4616 100644 --- a/src/modules/cards/tests/application/GetUrlCardViewUseCase.test.ts +++ b/src/modules/cards/tests/application/GetUrlCardViewUseCase.test.ts @@ -107,6 +107,7 @@ describe('GetUrlCardViewUseCase', () => { type: CardType.create(CardTypeEnum.NOTE).unwrap(), content: CardContent.createNoteContent( 'This is my note about the article', + curatorId, ).unwrap(), parentCardId: card.cardId, url: url, diff --git a/src/modules/cards/tests/infrastructure/DrizzleCardQueryRepository.getCardsInCollection.integration.test.ts b/src/modules/cards/tests/infrastructure/DrizzleCardQueryRepository.getCardsInCollection.integration.test.ts index 44fec2d4..00a0ccb4 100644 --- a/src/modules/cards/tests/infrastructure/DrizzleCardQueryRepository.getCardsInCollection.integration.test.ts +++ b/src/modules/cards/tests/infrastructure/DrizzleCardQueryRepository.getCardsInCollection.integration.test.ts @@ -206,7 +206,7 @@ describe('DrizzleCardQueryRepository - getCardsInCollection', () => { // Create note by collection author const authorNote = new CardBuilder() .withCuratorId(curatorId.value) - .withNoteCard('Note by collection author', 'Author Note') + .withNoteCard('Note by collection author') .withParentCard(urlCard.cardId) .buildOrThrow(); @@ -217,7 +217,7 @@ describe('DrizzleCardQueryRepository - getCardsInCollection', () => { // Create note by different user on the same URL card const otherUserNote = new CardBuilder() .withCuratorId(otherCuratorId.value) - .withNoteCard('Note by other user', 'Other User Note') + .withNoteCard('Note by other user') .withParentCard(urlCard.cardId) .buildOrThrow(); @@ -278,7 +278,7 @@ describe('DrizzleCardQueryRepository - getCardsInCollection', () => { // Create note by different user on the URL card (NO note by collection author) const otherUserNote = new CardBuilder() .withCuratorId(otherCuratorId.value) - .withNoteCard('Note by other user only', 'Other User Note') + .withNoteCard('Note by other user only') .withParentCard(urlCard.cardId) .buildOrThrow(); @@ -342,7 +342,7 @@ describe('DrizzleCardQueryRepository - getCardsInCollection', () => { // Create note card connected to the OTHER URL card (not in collection) const noteCard = new CardBuilder() .withCuratorId(curatorId.value) - .withNoteCard('This note is for the other article', 'Other Note') + .withNoteCard('This note is for the other article') .withParentCard(otherUrlCard.cardId) .buildOrThrow(); diff --git a/src/modules/cards/tests/infrastructure/DrizzleCardQueryRepository.getUrlCardView.integration.test.ts b/src/modules/cards/tests/infrastructure/DrizzleCardQueryRepository.getUrlCardView.integration.test.ts index 8b5d713a..80641aa7 100644 --- a/src/modules/cards/tests/infrastructure/DrizzleCardQueryRepository.getUrlCardView.integration.test.ts +++ b/src/modules/cards/tests/infrastructure/DrizzleCardQueryRepository.getUrlCardView.integration.test.ts @@ -88,7 +88,7 @@ describe('DrizzleCardQueryRepository - getUrlCardView', () => { // Create a note card const noteCard = new CardBuilder() .withCuratorId(curatorId.value) - .withNoteCard('This is a note', 'Note Title') + .withNoteCard('This is a note') .buildOrThrow(); await cardRepository.save(noteCard); @@ -570,7 +570,6 @@ describe('DrizzleCardQueryRepository - getUrlCardView', () => { .withCuratorId(curatorId.value) .withNoteCard( 'This is my detailed analysis of the article. It covers several key points and provides additional insights.', - 'My Analysis', ) .withParentCard(urlCard.cardId) .buildOrThrow(); @@ -637,7 +636,7 @@ describe('DrizzleCardQueryRepository - getUrlCardView', () => { // Create note card connected to the SECOND URL card const noteCard = new CardBuilder() .withCuratorId(curatorId.value) - .withNoteCard('This note is for article 2', 'Article 2 Notes') + .withNoteCard('This note is for article 2') .withParentCard(urlCard2.cardId) .buildOrThrow(); @@ -783,7 +782,7 @@ describe('DrizzleCardQueryRepository - getUrlCardView', () => { // Create note card const noteCard = new CardBuilder() .withCuratorId(curatorId.value) - .withNoteCard('Test note', 'Note Title') + .withNoteCard('Test note') .buildOrThrow(); await cardRepository.save(noteCard); diff --git a/src/modules/cards/tests/infrastructure/DrizzleCardQueryRepository.getUrlCardsOfUser.integration.test.ts b/src/modules/cards/tests/infrastructure/DrizzleCardQueryRepository.getUrlCardsOfUser.integration.test.ts index 59c70bae..539be563 100644 --- a/src/modules/cards/tests/infrastructure/DrizzleCardQueryRepository.getUrlCardsOfUser.integration.test.ts +++ b/src/modules/cards/tests/infrastructure/DrizzleCardQueryRepository.getUrlCardsOfUser.integration.test.ts @@ -173,7 +173,7 @@ describe('DrizzleCardQueryRepository - getUrlCardsOfUser', () => { // Create note card connected to URL card const noteCard = new CardBuilder() .withCuratorId(curatorId.value) - .withNoteCard('This is my note about the article', 'My Thoughts') + .withNoteCard('This is my note about the article') .withParentCard(urlCard.cardId) .buildOrThrow(); @@ -423,7 +423,7 @@ describe('DrizzleCardQueryRepository - getUrlCardsOfUser', () => { // Create connected note const noteCard = new CardBuilder() .withCuratorId(curatorId.value) - .withNoteCard('Detailed analysis of the complex article', 'Analysis') + .withNoteCard('Detailed analysis of the complex article') .withParentCard(urlCard.cardId) .buildOrThrow(); diff --git a/src/modules/cards/tests/infrastructure/DrizzleCardRepository.integration.test.ts b/src/modules/cards/tests/infrastructure/DrizzleCardRepository.integration.test.ts index 74345027..00e051be 100644 --- a/src/modules/cards/tests/infrastructure/DrizzleCardRepository.integration.test.ts +++ b/src/modules/cards/tests/infrastructure/DrizzleCardRepository.integration.test.ts @@ -109,6 +109,7 @@ describe('DrizzleCardRepository', () => { // Create a note card const noteContent = CardContent.createNoteContent( 'This is a test note', + curatorId, ).unwrap(); const cardType = CardType.create(CardTypeEnum.NOTE).unwrap(); @@ -141,6 +142,7 @@ describe('DrizzleCardRepository', () => { // Create a note card const noteContent = CardContent.createNoteContent( 'Card with library memberships', + curatorId, ).unwrap(); const cardType = CardType.create(CardTypeEnum.NOTE).unwrap(); @@ -182,6 +184,7 @@ describe('DrizzleCardRepository', () => { // Create a note card const noteContent = CardContent.createNoteContent( 'Card for membership updates', + curatorId, ).unwrap(); const cardType = CardType.create(CardTypeEnum.NOTE).unwrap(); @@ -225,8 +228,10 @@ describe('DrizzleCardRepository', () => { it('should delete a card and its library memberships', async () => { // Create a card - const noteContent = - CardContent.createNoteContent('Card to delete').unwrap(); + const noteContent = CardContent.createNoteContent( + 'Card to delete', + curatorId, + ).unwrap(); const cardType = CardType.create(CardTypeEnum.NOTE).unwrap(); const cardResult = Card.create({ @@ -257,8 +262,10 @@ describe('DrizzleCardRepository', () => { }); it('should return null when card is not found', async () => { - const noteContent = - CardContent.createNoteContent('Non-existent card').unwrap(); + const noteContent = CardContent.createNoteContent( + 'Non-existent card', + curatorId, + ).unwrap(); const cardType = CardType.create(CardTypeEnum.NOTE).unwrap(); const nonExistentCardId = Card.create({ @@ -275,6 +282,7 @@ describe('DrizzleCardRepository', () => { // Create a note card const noteContent = CardContent.createNoteContent( 'Card for publishing test', + curatorId, ).unwrap(); const cardType = CardType.create(CardTypeEnum.NOTE).unwrap(); @@ -372,8 +380,10 @@ describe('DrizzleCardRepository', () => { it('should not find note cards when searching by URL', async () => { // Create a note card with a URL (but it's not a URL card type) const url = URL.create('https://example.com/note-url').unwrap(); - const noteContent = - CardContent.createNoteContent('Note about a URL').unwrap(); + const noteContent = CardContent.createNoteContent( + 'Note about a URL', + curatorId, + ).unwrap(); const cardType = CardType.create(CardTypeEnum.NOTE).unwrap(); const cardResult = Card.create({ @@ -395,6 +405,7 @@ describe('DrizzleCardRepository', () => { // Create a note card const noteContent = CardContent.createNoteContent( 'Card for library count test', + curatorId, ).unwrap(); const cardType = CardType.create(CardTypeEnum.NOTE).unwrap(); @@ -449,6 +460,7 @@ describe('DrizzleCardRepository', () => { // Create a note card with initial library memberships const noteContent = CardContent.createNoteContent( 'Card with initial memberships', + curatorId, ).unwrap(); const cardType = CardType.create(CardTypeEnum.NOTE).unwrap(); diff --git a/src/modules/cards/tests/utils/builders/CardBuilder.ts b/src/modules/cards/tests/utils/builders/CardBuilder.ts index b889d546..a6759a29 100644 --- a/src/modules/cards/tests/utils/builders/CardBuilder.ts +++ b/src/modules/cards/tests/utils/builders/CardBuilder.ts @@ -45,7 +45,6 @@ export class CardBuilder { if (curatorIdResult.isOk()) { const contentResult = CardContent.createNoteContent( 'Default note text', - undefined, curatorIdResult.value, ); if (contentResult.isOk()) { @@ -101,9 +100,12 @@ export class CardBuilder { return this; } - withNoteCard(text: string, title?: string): CardBuilder { + withNoteCard(text: string): CardBuilder { this._type = CardTypeEnum.NOTE; - const contentResult = CardContent.createNoteContent(text, title); + const contentResult = CardContent.createNoteContent( + text, + CuratorId.create(this._curatorId).unwrap(), + ); if (contentResult.isErr()) { throw new Error( `Failed to create note content: ${contentResult.error.message}`, @@ -138,7 +140,6 @@ export class CardBuilder { } else if (this._type === CardTypeEnum.NOTE) { const contentResult = CardContent.createNoteContent( 'Default note text', - undefined, curatorIdResult.value, ); if (contentResult.isErr()) { -- 2.51.2 From ed17e1c1e8baf277d93339404660dc3459de7e24 Mon Sep 17 00:00:00 2001 From: Wesley Finck Date: Fri, 3 Oct 2025 10:32:43 -0700 Subject: [PATCH 2/2] remove title reference for note cards --- src/modules/cards/domain/Card.ts | 15 --------------- .../value-objects/content/NoteCardContent.ts | 5 ----- .../DrizzleCardRepository.integration.test.ts | 1 - 3 files changed, 21 deletions(-) diff --git a/src/modules/cards/domain/Card.ts b/src/modules/cards/domain/Card.ts index 05f47bc0..88edd04e 100644 --- a/src/modules/cards/domain/Card.ts +++ b/src/modules/cards/domain/Card.ts @@ -260,19 +260,4 @@ export class Card extends AggregateRoot { link.curatorId.equals(userId), ); } - - private getCardTitle(): string | undefined { - if (this.isUrlCard) { - const urlContent = this.props.content.content; - if ('metadata' in urlContent) { - return urlContent.metadata?.title; - } - } else if (this.isNoteCard) { - const noteContent = this.props.content.content; - if ('title' in noteContent) { - return noteContent.title; - } - } - return undefined; - } } diff --git a/src/modules/cards/domain/value-objects/content/NoteCardContent.ts b/src/modules/cards/domain/value-objects/content/NoteCardContent.ts index 312938f5..2b17e12a 100644 --- a/src/modules/cards/domain/value-objects/content/NoteCardContent.ts +++ b/src/modules/cards/domain/value-objects/content/NoteCardContent.ts @@ -27,11 +27,6 @@ export class NoteCardContent extends ValueObject { return this.props.text; } - get title(): string | undefined { - // For backward compatibility, we don't store title separately in the new model - return undefined; - } - get authorId(): CuratorId { return this.props.authorId; } diff --git a/src/modules/cards/tests/infrastructure/DrizzleCardRepository.integration.test.ts b/src/modules/cards/tests/infrastructure/DrizzleCardRepository.integration.test.ts index 00e051be..c7f3c5f0 100644 --- a/src/modules/cards/tests/infrastructure/DrizzleCardRepository.integration.test.ts +++ b/src/modules/cards/tests/infrastructure/DrizzleCardRepository.integration.test.ts @@ -135,7 +135,6 @@ describe('DrizzleCardRepository', () => { expect(retrievedCard?.content.noteContent?.text).toBe( 'This is a test note', ); - expect(retrievedCard?.content.noteContent?.title).toBeUndefined(); }); it('should save and retrieve a card with library memberships', async () => { -- 2.51.2