diff --git a/src/modules/atproto/domain/ATUri.ts b/src/modules/atproto/domain/ATUri.ts index 2d584279..e76b3fe4 100644 --- a/src/modules/atproto/domain/ATUri.ts +++ b/src/modules/atproto/domain/ATUri.ts @@ -50,12 +50,20 @@ export class ATUri extends ValueObject { const parts = trimmedUri.split('/'); if (parts.length !== 5) { - return err(new InvalidATUriError('AT URI must have exactly 5 parts separated by "/"')); + return err( + new InvalidATUriError( + 'AT URI must have exactly 5 parts separated by "/"', + ), + ); } const didResult = DID.create(parts[2]!); if (didResult.isErr()) { - return err(new InvalidATUriError(`Invalid DID in AT URI: ${didResult.error.message}`)); + return err( + new InvalidATUriError( + `Invalid DID in AT URI: ${didResult.error.message}`, + ), + ); } const collection = parts[3]!; @@ -69,15 +77,21 @@ export class ATUri extends ValueObject { return err(new InvalidATUriError('Record key cannot be empty')); } - return ok(new ATUri({ - value: trimmedUri, - did: didResult.value, - collection, - rkey, - })); + return ok( + new ATUri({ + value: trimmedUri, + did: didResult.value, + collection, + rkey, + }), + ); } - public static fromParts(did: DID, collection: string, rkey: string): Result { + public static fromParts( + did: DID, + collection: string, + rkey: string, + ): Result { if (!collection || collection.length === 0) { return err(new InvalidATUriError('Collection cannot be empty')); } @@ -87,13 +101,15 @@ export class ATUri extends ValueObject { } const uri = `at://${did.value}/${collection}/${rkey}`; - - return ok(new ATUri({ - value: uri, - did, - collection, - rkey, - })); + + return ok( + new ATUri({ + value: uri, + did, + collection, + rkey, + }), + ); } public toString(): string { diff --git a/src/modules/cards/application/useCases/queries/GetCollectionPageUseCase.ts b/src/modules/cards/application/useCases/queries/GetCollectionPageUseCase.ts index 7216b3fb..0611ace7 100644 --- a/src/modules/cards/application/useCases/queries/GetCollectionPageUseCase.ts +++ b/src/modules/cards/application/useCases/queries/GetCollectionPageUseCase.ts @@ -19,7 +19,6 @@ export interface GetCollectionPageQuery { sortOrder?: SortOrder; } - export type CollectionPageUrlCardDTO = UrlCardView; export interface GetCollectionPageResult { id: string; @@ -165,5 +164,4 @@ export class GetCollectionPageUseCase ); } } - } diff --git a/src/modules/cards/infrastructure/http/routes/collectionRoutes.ts b/src/modules/cards/infrastructure/http/routes/collectionRoutes.ts index eed6f31c..5d79277e 100644 --- a/src/modules/cards/infrastructure/http/routes/collectionRoutes.ts +++ b/src/modules/cards/infrastructure/http/routes/collectionRoutes.ts @@ -32,8 +32,10 @@ export function createCollectionRoutes( ); // GET /api/collections/at/:handle/:recordKey - Get collection by AT URI - router.get('/at/:handle/:recordKey', authMiddleware.optionalAuth(), (req, res) => - getCollectionPageByAtUriController.execute(req, res), + router.get( + '/at/:handle/:recordKey', + authMiddleware.optionalAuth(), + (req, res) => getCollectionPageByAtUriController.execute(req, res), ); // GET /api/collections/:collectionId - Get collection page diff --git a/src/modules/cards/tests/utils/InMemoryAtUriResolutionService.ts b/src/modules/cards/tests/utils/InMemoryAtUriResolutionService.ts index 9643351f..8b3b93f5 100644 --- a/src/modules/cards/tests/utils/InMemoryAtUriResolutionService.ts +++ b/src/modules/cards/tests/utils/InMemoryAtUriResolutionService.ts @@ -16,7 +16,7 @@ export class InMemoryAtUriResolutionService implements IAtUriResolutionService { try { // Get all collections and check if any have a published record with this URI const allCollections = this.collectionRepository.getAllCollections(); - + for (const collection of allCollections) { if (collection.publishedRecordId?.uri === atUri) { return ok({ diff --git a/src/shared/infrastructure/database/migrations/meta/0003_snapshot.json b/src/shared/infrastructure/database/migrations/meta/0003_snapshot.json index 3e4803da..92b71bea 100644 --- a/src/shared/infrastructure/database/migrations/meta/0003_snapshot.json +++ b/src/shared/infrastructure/database/migrations/meta/0003_snapshot.json @@ -117,12 +117,8 @@ "name": "cards_parent_card_id_cards_id_fk", "tableFrom": "cards", "tableTo": "cards", - "columnsFrom": [ - "parent_card_id" - ], - "columnsTo": [ - "id" - ], + "columnsFrom": ["parent_card_id"], + "columnsTo": ["id"], "onDelete": "no action", "onUpdate": "no action" }, @@ -130,12 +126,8 @@ "name": "cards_original_published_record_id_published_records_id_fk", "tableFrom": "cards", "tableTo": "published_records", - "columnsFrom": [ - "original_published_record_id" - ], - "columnsTo": [ - "id" - ], + "columnsFrom": ["original_published_record_id"], + "columnsTo": ["id"], "onDelete": "no action", "onUpdate": "no action" } @@ -194,12 +186,8 @@ "name": "collection_cards_collection_id_collections_id_fk", "tableFrom": "collection_cards", "tableTo": "collections", - "columnsFrom": [ - "collection_id" - ], - "columnsTo": [ - "id" - ], + "columnsFrom": ["collection_id"], + "columnsTo": ["id"], "onDelete": "cascade", "onUpdate": "no action" }, @@ -207,12 +195,8 @@ "name": "collection_cards_card_id_cards_id_fk", "tableFrom": "collection_cards", "tableTo": "cards", - "columnsFrom": [ - "card_id" - ], - "columnsTo": [ - "id" - ], + "columnsFrom": ["card_id"], + "columnsTo": ["id"], "onDelete": "cascade", "onUpdate": "no action" }, @@ -220,12 +204,8 @@ "name": "collection_cards_published_record_id_published_records_id_fk", "tableFrom": "collection_cards", "tableTo": "published_records", - "columnsFrom": [ - "published_record_id" - ], - "columnsTo": [ - "id" - ], + "columnsFrom": ["published_record_id"], + "columnsTo": ["id"], "onDelete": "no action", "onUpdate": "no action" } @@ -265,12 +245,8 @@ "name": "collection_collaborators_collection_id_collections_id_fk", "tableFrom": "collection_collaborators", "tableTo": "collections", - "columnsFrom": [ - "collection_id" - ], - "columnsTo": [ - "id" - ], + "columnsFrom": ["collection_id"], + "columnsTo": ["id"], "onDelete": "cascade", "onUpdate": "no action" } @@ -349,12 +325,8 @@ "name": "collections_published_record_id_published_records_id_fk", "tableFrom": "collections", "tableTo": "published_records", - "columnsFrom": [ - "published_record_id" - ], - "columnsTo": [ - "id" - ], + "columnsFrom": ["published_record_id"], + "columnsTo": ["id"], "onDelete": "no action", "onUpdate": "no action" } @@ -432,12 +404,8 @@ "name": "library_memberships_card_id_cards_id_fk", "tableFrom": "library_memberships", "tableTo": "cards", - "columnsFrom": [ - "card_id" - ], - "columnsTo": [ - "id" - ], + "columnsFrom": ["card_id"], + "columnsTo": ["id"], "onDelete": "cascade", "onUpdate": "no action" }, @@ -445,12 +413,8 @@ "name": "library_memberships_published_record_id_published_records_id_fk", "tableFrom": "library_memberships", "tableTo": "published_records", - "columnsFrom": [ - "published_record_id" - ], - "columnsTo": [ - "id" - ], + "columnsFrom": ["published_record_id"], + "columnsTo": ["id"], "onDelete": "no action", "onUpdate": "no action" } @@ -458,10 +422,7 @@ "compositePrimaryKeys": { "library_memberships_card_id_user_id_pk": { "name": "library_memberships_card_id_user_id_pk", - "columns": [ - "card_id", - "user_id" - ] + "columns": ["card_id", "user_id"] } }, "uniqueConstraints": {}, @@ -693,12 +654,8 @@ "name": "auth_refresh_tokens_user_did_users_id_fk", "tableFrom": "auth_refresh_tokens", "tableTo": "users", - "columnsFrom": [ - "user_did" - ], - "columnsTo": [ - "id" - ], + "columnsFrom": ["user_did"], + "columnsTo": ["id"], "onDelete": "no action", "onUpdate": "no action" } @@ -758,4 +715,4 @@ "schemas": {}, "tables": {} } -} \ No newline at end of file +} diff --git a/src/shared/infrastructure/database/migrations/meta/_journal.json b/src/shared/infrastructure/database/migrations/meta/_journal.json index 94ce0117..c3c0457e 100644 --- a/src/shared/infrastructure/database/migrations/meta/_journal.json +++ b/src/shared/infrastructure/database/migrations/meta/_journal.json @@ -31,4 +31,4 @@ "breakpoints": true } ] -} \ No newline at end of file +} diff --git a/src/shared/infrastructure/http/factories/ControllerFactory.ts b/src/shared/infrastructure/http/factories/ControllerFactory.ts index 1db54f02..bfbd11c8 100644 --- a/src/shared/infrastructure/http/factories/ControllerFactory.ts +++ b/src/shared/infrastructure/http/factories/ControllerFactory.ts @@ -134,9 +134,10 @@ export class ControllerFactory { getCollectionPageController: new GetCollectionPageController( useCases.getCollectionPageUseCase, ), - getCollectionPageByAtUriController: new GetCollectionPageByAtUriController( - useCases.getCollectionPageByAtUriUseCase, - ), + getCollectionPageByAtUriController: + new GetCollectionPageByAtUriController( + useCases.getCollectionPageByAtUriUseCase, + ), getMyCollectionsController: new GetMyCollectionsController( useCases.getCollectionsUseCase, ), diff --git a/src/webapp/api-client/clients/QueryClient.ts b/src/webapp/api-client/clients/QueryClient.ts index b7c8473a..5a21f258 100644 --- a/src/webapp/api-client/clients/QueryClient.ts +++ b/src/webapp/api-client/clients/QueryClient.ts @@ -106,11 +106,13 @@ export class QueryClient extends BaseClient { ): Promise { const { handle, recordKey, ...queryParams } = params; const searchParams = new URLSearchParams(); - + if (queryParams.page) searchParams.set('page', queryParams.page.toString()); - if (queryParams.limit) searchParams.set('limit', queryParams.limit.toString()); + if (queryParams.limit) + searchParams.set('limit', queryParams.limit.toString()); if (queryParams.sortBy) searchParams.set('sortBy', queryParams.sortBy); - if (queryParams.sortOrder) searchParams.set('sortOrder', queryParams.sortOrder); + if (queryParams.sortOrder) + searchParams.set('sortOrder', queryParams.sortOrder); const queryString = searchParams.toString(); const endpoint = queryString