refactor use cases

This commit is contained in:
2026-01-08 15:34:51 +01:00
parent d984ab24a8
commit 52e9a2f6a7
362 changed files with 5192 additions and 8409 deletions

View File

@@ -1,4 +1,4 @@
import type { Logger, UseCaseOutputPort } from '@core/shared/application';
import type { Logger } from '@core/shared/application';
import { Result } from '@core/shared/application/Result';
import type { ApplicationErrorCode } from '@core/shared/errors/ApplicationErrorCode';
import type { ISocialGraphRepository } from '../../domain/repositories/ISocialGraphRepository';
@@ -26,18 +26,18 @@ export type GetCurrentUserSocialApplicationError = ApplicationErrorCode<
* Application-level use case to retrieve the current user's social context.
*
* Keeps orchestration in the social bounded context while delegating
* data access to domain repositories and presenting via an output port.
* data access to domain repositories.
* Returns Result directly without calling presenter.
*/
export class GetCurrentUserSocialUseCase {
constructor(
private readonly socialGraphRepository: ISocialGraphRepository,
private readonly logger: Logger,
private readonly output: UseCaseOutputPort<GetCurrentUserSocialResult>,
) {}
async execute(
input: GetCurrentUserSocialInput,
): Promise<Result<void, GetCurrentUserSocialApplicationError>> {
): Promise<Result<GetCurrentUserSocialResult, GetCurrentUserSocialApplicationError>> {
this.logger.debug('GetCurrentUserSocialUseCase.execute: Starting execution', { input });
try {
@@ -81,12 +81,11 @@ export class GetCurrentUserSocialUseCase {
friends,
};
this.output.present(result);
this.logger.info(
'GetCurrentUserSocialUseCase.execute: Successfully presented current user social data',
'GetCurrentUserSocialUseCase.execute: Successfully retrieved current user social data',
);
return Result.ok(undefined);
return Result.ok(result);
} catch (error) {
const err = error instanceof Error ? error : new Error(String(error));