website refactor

This commit is contained in:
2026-01-16 21:44:26 +01:00
parent 2d322b42e1
commit 83a9092c50
327 changed files with 1086 additions and 1088 deletions

View File

@@ -4,46 +4,46 @@ import { Reflector } from '@nestjs/core';
import { Test, TestingModule } from '@nestjs/testing';
import request from 'supertest';
import { vi } from 'vitest';
import { PaymentsController } from './PaymentsController';
import { PaymentsService } from './PaymentsService';
import { AuthenticationGuard } from '../auth/AuthenticationGuard';
import { AuthorizationGuard } from '../auth/AuthorizationGuard';
import type { AuthorizationService } from '../auth/AuthorizationService';
import { FeatureAvailabilityGuard } from '../policy/FeatureAvailabilityGuard';
import type { PolicyService, PolicySnapshot } from '../policy/PolicyService';
import {
GetPaymentsQuery,
CreatePaymentInput,
UpdatePaymentStatusInput,
GetMembershipFeesQuery,
UpsertMembershipFeeInput,
UpdateMemberPaymentInput,
GetPrizesQuery,
CreatePrizeInput,
AwardPrizeInput,
DeletePrizeInput,
GetWalletQuery,
ProcessWalletTransactionInput,
PaymentType,
PayerType,
PaymentStatus,
MembershipFeeType,
MemberPaymentStatus,
PrizeType,
TransactionType,
GetPaymentsOutput,
CreatePaymentOutput,
UpdatePaymentStatusOutput,
GetMembershipFeesOutput,
UpsertMembershipFeeOutput,
UpdateMemberPaymentOutput,
GetPrizesOutput,
CreatePrizeOutput,
AwardPrizeOutput,
DeletePrizeOutput,
GetWalletOutput,
ProcessWalletTransactionOutput
AwardPrizeInput,
AwardPrizeOutput,
CreatePaymentInput,
CreatePaymentOutput,
CreatePrizeInput,
CreatePrizeOutput,
DeletePrizeInput,
DeletePrizeOutput,
GetMembershipFeesOutput,
GetMembershipFeesQuery,
GetPaymentsOutput,
GetPaymentsQuery,
GetPrizesOutput,
GetPrizesQuery,
GetWalletOutput,
GetWalletQuery,
MemberPaymentStatus,
MembershipFeeType,
PayerType,
PaymentStatus,
PaymentType,
PrizeType,
ProcessWalletTransactionInput,
ProcessWalletTransactionOutput,
TransactionType,
UpdateMemberPaymentInput,
UpdateMemberPaymentOutput,
UpdatePaymentStatusInput,
UpdatePaymentStatusOutput,
UpsertMembershipFeeInput,
UpsertMembershipFeeOutput
} from './dtos/PaymentsDto';
import { PaymentsController } from './PaymentsController';
import { PaymentsService } from './PaymentsService';
describe('PaymentsController', () => {
let controller: PaymentsController;

View File

@@ -1,10 +1,10 @@
import { Controller, Get, Post, Patch, Delete, Body, Query, HttpCode, HttpStatus, Inject } from '@nestjs/common';
import { ApiTags, ApiResponse, ApiOperation } from '@nestjs/swagger';
import { Body, Controller, Delete, Get, HttpCode, HttpStatus, Inject, Patch, Post, Query } from '@nestjs/common';
import { ApiOperation, ApiResponse, ApiTags } from '@nestjs/swagger';
import { RequireAuthenticatedUser } from '../auth/RequireAuthenticatedUser';
import { RequireRoles } from '../auth/RequireRoles';
import { RequireCapability } from '../policy/RequireCapability';
import { PaymentsService } from './PaymentsService';
import { CreatePaymentInput, CreatePaymentOutput, UpdatePaymentStatusInput, UpdatePaymentStatusOutput, GetPaymentsQuery, GetPaymentsOutput, GetMembershipFeesQuery, GetMembershipFeesOutput, UpsertMembershipFeeInput, UpsertMembershipFeeOutput, UpdateMemberPaymentInput, UpdateMemberPaymentOutput, GetPrizesQuery, GetPrizesOutput, CreatePrizeInput, CreatePrizeOutput, AwardPrizeInput, AwardPrizeOutput, DeletePrizeInput, DeletePrizeOutput, GetWalletQuery, GetWalletOutput, ProcessWalletTransactionInput, ProcessWalletTransactionOutput } from './dtos/PaymentsDto';
import { AwardPrizeInput, AwardPrizeOutput, CreatePaymentInput, CreatePaymentOutput, CreatePrizeInput, CreatePrizeOutput, DeletePrizeInput, DeletePrizeOutput, GetMembershipFeesOutput, GetMembershipFeesQuery, GetPaymentsOutput, GetPaymentsQuery, GetPrizesOutput, GetPrizesQuery, GetWalletOutput, GetWalletQuery, ProcessWalletTransactionInput, ProcessWalletTransactionOutput, UpdateMemberPaymentInput, UpdateMemberPaymentOutput, UpdatePaymentStatusInput, UpdatePaymentStatusOutput, UpsertMembershipFeeInput, UpsertMembershipFeeOutput } from './dtos/PaymentsDto';
@ApiTags('payments')
@RequireAuthenticatedUser()

View File

@@ -1,6 +1,6 @@
import { Test, TestingModule } from '@nestjs/testing';
import { PaymentsModule } from './PaymentsModule';
import { PaymentsController } from './PaymentsController';
import { PaymentsModule } from './PaymentsModule';
import { PaymentsService } from './PaymentsService';
describe('PaymentsModule', () => {

View File

@@ -2,9 +2,9 @@ import { Module } from '@nestjs/common';
import { PaymentsPersistenceModule } from '../../persistence/payments/PaymentsPersistenceModule';
import { PaymentsService } from './PaymentsService';
import { PaymentsController } from './PaymentsController';
import { PaymentsProviders } from './PaymentsProviders';
import { PaymentsService } from './PaymentsService';
@Module({
imports: [PaymentsPersistenceModule],

View File

@@ -1,48 +1,48 @@
import { Provider } from '@nestjs/common';
// Import core interfaces
import type { IMemberPaymentRepository, IMembershipFeeRepository } from '@core/payments/domain/repositories/MembershipFeeRepository';
import type { IPaymentRepository } from '@core/payments/domain/repositories/PaymentRepository';
import type { IMembershipFeeRepository, IMemberPaymentRepository } from '@core/payments/domain/repositories/MembershipFeeRepository';
import type { IPrizeRepository } from '@core/payments/domain/repositories/PrizeRepository';
import type { IWalletRepository, ITransactionRepository } from '@core/payments/domain/repositories/WalletRepository';
import type { ITransactionRepository, IWalletRepository } from '@core/payments/domain/repositories/WalletRepository';
// Import use cases
import { GetPaymentsUseCase } from '@core/payments/application/use-cases/GetPaymentsUseCase';
import { CreatePaymentUseCase } from '@core/payments/application/use-cases/CreatePaymentUseCase';
import { UpdatePaymentStatusUseCase } from '@core/payments/application/use-cases/UpdatePaymentStatusUseCase';
import { GetMembershipFeesUseCase } from '@core/payments/application/use-cases/GetMembershipFeesUseCase';
import { UpsertMembershipFeeUseCase } from '@core/payments/application/use-cases/UpsertMembershipFeeUseCase';
import { UpdateMemberPaymentUseCase } from '@core/payments/application/use-cases/UpdateMemberPaymentUseCase';
import { GetPrizesUseCase } from '@core/payments/application/use-cases/GetPrizesUseCase';
import { CreatePrizeUseCase } from '@core/payments/application/use-cases/CreatePrizeUseCase';
import { AwardPrizeUseCase } from '@core/payments/application/use-cases/AwardPrizeUseCase';
import { CreatePaymentUseCase } from '@core/payments/application/use-cases/CreatePaymentUseCase';
import { CreatePrizeUseCase } from '@core/payments/application/use-cases/CreatePrizeUseCase';
import { DeletePrizeUseCase } from '@core/payments/application/use-cases/DeletePrizeUseCase';
import { GetMembershipFeesUseCase } from '@core/payments/application/use-cases/GetMembershipFeesUseCase';
import { GetPaymentsUseCase } from '@core/payments/application/use-cases/GetPaymentsUseCase';
import { GetPrizesUseCase } from '@core/payments/application/use-cases/GetPrizesUseCase';
import { GetWalletUseCase } from '@core/payments/application/use-cases/GetWalletUseCase';
import { ProcessWalletTransactionUseCase } from '@core/payments/application/use-cases/ProcessWalletTransactionUseCase';
import { UpdateMemberPaymentUseCase } from '@core/payments/application/use-cases/UpdateMemberPaymentUseCase';
import { UpdatePaymentStatusUseCase } from '@core/payments/application/use-cases/UpdatePaymentStatusUseCase';
import { UpsertMembershipFeeUseCase } from '@core/payments/application/use-cases/UpsertMembershipFeeUseCase';
// Import concrete in-memory implementations
import { ConsoleLogger } from '@adapters/logging/ConsoleLogger';
import {
PAYMENT_REPOSITORY_TOKEN,
MEMBERSHIP_FEE_REPOSITORY_TOKEN,
MEMBER_PAYMENT_REPOSITORY_TOKEN,
PRIZE_REPOSITORY_TOKEN,
WALLET_REPOSITORY_TOKEN,
TRANSACTION_REPOSITORY_TOKEN,
LOGGER_TOKEN,
GET_PAYMENTS_USE_CASE_TOKEN,
CREATE_PAYMENT_USE_CASE_TOKEN,
UPDATE_PAYMENT_STATUS_USE_CASE_TOKEN,
GET_MEMBERSHIP_FEES_USE_CASE_TOKEN,
UPSERT_MEMBERSHIP_FEE_USE_CASE_TOKEN,
UPDATE_MEMBER_PAYMENT_USE_CASE_TOKEN,
GET_PRIZES_USE_CASE_TOKEN,
CREATE_PRIZE_USE_CASE_TOKEN,
AWARD_PRIZE_USE_CASE_TOKEN,
DELETE_PRIZE_USE_CASE_TOKEN,
GET_WALLET_USE_CASE_TOKEN,
PROCESS_WALLET_TRANSACTION_USE_CASE_TOKEN,
AWARD_PRIZE_USE_CASE_TOKEN,
CREATE_PAYMENT_USE_CASE_TOKEN,
CREATE_PRIZE_USE_CASE_TOKEN,
DELETE_PRIZE_USE_CASE_TOKEN,
GET_MEMBERSHIP_FEES_USE_CASE_TOKEN,
GET_PAYMENTS_USE_CASE_TOKEN,
GET_PRIZES_USE_CASE_TOKEN,
GET_WALLET_USE_CASE_TOKEN,
LOGGER_TOKEN,
MEMBERSHIP_FEE_REPOSITORY_TOKEN,
MEMBER_PAYMENT_REPOSITORY_TOKEN,
PAYMENT_REPOSITORY_TOKEN,
PRIZE_REPOSITORY_TOKEN,
PROCESS_WALLET_TRANSACTION_USE_CASE_TOKEN,
TRANSACTION_REPOSITORY_TOKEN,
UPDATE_MEMBER_PAYMENT_USE_CASE_TOKEN,
UPDATE_PAYMENT_STATUS_USE_CASE_TOKEN,
UPSERT_MEMBERSHIP_FEE_USE_CASE_TOKEN,
WALLET_REPOSITORY_TOKEN,
} from './PaymentsTokens';
export * from './PaymentsTokens';

View File

@@ -1,5 +1,5 @@
import { describe, expect, it, vi } from 'vitest';
import { Result } from '@core/shared/domain/Result';
import { describe, expect, it, vi } from 'vitest';
import { PaymentsService } from './PaymentsService';
describe('PaymentsService', () => {

View File

@@ -17,47 +17,47 @@ import type { UpsertMembershipFeeUseCase } from '@core/payments/application/use-
// DTOs
import type {
AwardPrizeInput,
AwardPrizeOutput,
CreatePaymentInput,
CreatePaymentOutput,
CreatePrizeInput,
CreatePrizeOutput,
DeletePrizeInput,
DeletePrizeOutput,
GetMembershipFeesOutput,
GetMembershipFeesQuery,
GetPaymentsOutput,
GetPaymentsQuery,
GetPrizesOutput,
GetPrizesQuery,
GetWalletOutput,
GetWalletQuery,
ProcessWalletTransactionInput,
ProcessWalletTransactionOutput,
UpdateMemberPaymentInput,
UpdateMemberPaymentOutput,
UpdatePaymentStatusInput,
UpdatePaymentStatusOutput,
UpsertMembershipFeeInput,
UpsertMembershipFeeOutput,
AwardPrizeInput,
AwardPrizeOutput,
CreatePaymentInput,
CreatePaymentOutput,
CreatePrizeInput,
CreatePrizeOutput,
DeletePrizeInput,
DeletePrizeOutput,
GetMembershipFeesOutput,
GetMembershipFeesQuery,
GetPaymentsOutput,
GetPaymentsQuery,
GetPrizesOutput,
GetPrizesQuery,
GetWalletOutput,
GetWalletQuery,
ProcessWalletTransactionInput,
ProcessWalletTransactionOutput,
UpdateMemberPaymentInput,
UpdateMemberPaymentOutput,
UpdatePaymentStatusInput,
UpdatePaymentStatusOutput,
UpsertMembershipFeeInput,
UpsertMembershipFeeOutput,
} from './dtos/PaymentsDto';
// Injection tokens
import {
AWARD_PRIZE_USE_CASE_TOKEN,
CREATE_PAYMENT_USE_CASE_TOKEN,
CREATE_PRIZE_USE_CASE_TOKEN,
DELETE_PRIZE_USE_CASE_TOKEN,
GET_MEMBERSHIP_FEES_USE_CASE_TOKEN,
GET_PAYMENTS_USE_CASE_TOKEN,
GET_PRIZES_USE_CASE_TOKEN,
GET_WALLET_USE_CASE_TOKEN,
LOGGER_TOKEN,
PROCESS_WALLET_TRANSACTION_USE_CASE_TOKEN,
UPDATE_MEMBER_PAYMENT_USE_CASE_TOKEN,
UPDATE_PAYMENT_STATUS_USE_CASE_TOKEN,
UPSERT_MEMBERSHIP_FEE_USE_CASE_TOKEN,
AWARD_PRIZE_USE_CASE_TOKEN,
CREATE_PAYMENT_USE_CASE_TOKEN,
CREATE_PRIZE_USE_CASE_TOKEN,
DELETE_PRIZE_USE_CASE_TOKEN,
GET_MEMBERSHIP_FEES_USE_CASE_TOKEN,
GET_PAYMENTS_USE_CASE_TOKEN,
GET_PRIZES_USE_CASE_TOKEN,
GET_WALLET_USE_CASE_TOKEN,
LOGGER_TOKEN,
PROCESS_WALLET_TRANSACTION_USE_CASE_TOKEN,
UPDATE_MEMBER_PAYMENT_USE_CASE_TOKEN,
UPDATE_PAYMENT_STATUS_USE_CASE_TOKEN,
UPSERT_MEMBERSHIP_FEE_USE_CASE_TOKEN,
} from './PaymentsTokens';
@Injectable()

View File

@@ -1,10 +1,10 @@
import {
PAYMENTS_MEMBER_PAYMENT_REPOSITORY_TOKEN,
PAYMENTS_MEMBERSHIP_FEE_REPOSITORY_TOKEN,
PAYMENTS_PAYMENT_REPOSITORY_TOKEN,
PAYMENTS_PRIZE_REPOSITORY_TOKEN,
PAYMENTS_TRANSACTION_REPOSITORY_TOKEN,
PAYMENTS_WALLET_REPOSITORY_TOKEN,
PAYMENTS_MEMBER_PAYMENT_REPOSITORY_TOKEN,
PAYMENTS_MEMBERSHIP_FEE_REPOSITORY_TOKEN,
PAYMENTS_PAYMENT_REPOSITORY_TOKEN,
PAYMENTS_PRIZE_REPOSITORY_TOKEN,
PAYMENTS_TRANSACTION_REPOSITORY_TOKEN,
PAYMENTS_WALLET_REPOSITORY_TOKEN,
} from '../../persistence/payments/PaymentsPersistenceTokens';
export const PAYMENT_REPOSITORY_TOKEN = PAYMENTS_PAYMENT_REPOSITORY_TOKEN;

View File

@@ -1,7 +1,7 @@
import { ApiProperty } from '@nestjs/swagger';
import { IsEnum, IsNumber, IsString, IsOptional } from 'class-validator';
import { PaymentType } from './PaymentType';
import { IsEnum, IsNumber, IsOptional, IsString } from 'class-validator';
import { PayerType } from './PayerType';
import { PaymentType } from './PaymentType';
export class CreatePaymentInputDTO {
@ApiProperty({ enum: PaymentType })

View File

@@ -1,6 +1,6 @@
import { ApiProperty } from '@nestjs/swagger';
import { IsString, IsNumber, IsEnum, IsOptional, IsDate } from 'class-validator';
import { TransactionType, ReferenceType } from './PaymentsDto';
import { IsDate, IsEnum, IsNumber, IsOptional, IsString } from 'class-validator';
import { ReferenceType, TransactionType } from './PaymentsDto';
export class FullTransactionDto {
@ApiProperty()

View File

@@ -1,6 +1,6 @@
import { ApiProperty } from '@nestjs/swagger';
import { IsObject, IsArray } from 'class-validator';
import { MembershipFeeDto, MemberPaymentDto } from './PaymentsDto';
import { IsArray, IsObject } from 'class-validator';
import { MemberPaymentDto, MembershipFeeDto } from './PaymentsDto';
export class GetMembershipFeesResultDTO {
@ApiProperty({ type: MembershipFeeDto, nullable: true })

View File

@@ -1,6 +1,6 @@
import { ApiProperty } from '@nestjs/swagger';
import { IsObject, IsArray } from 'class-validator';
import { WalletDto, TransactionDto } from './PaymentsDto';
import { IsArray, IsObject } from 'class-validator';
import { TransactionDto, WalletDto } from './PaymentsDto';
export class GetWalletResultDTO {
@ApiProperty({ type: WalletDto })

View File

@@ -1,8 +1,8 @@
import { ApiProperty } from '@nestjs/swagger';
import { IsString, IsNumber, IsEnum, IsOptional, IsDate } from 'class-validator';
import { PaymentType } from './PaymentType';
import { IsDate, IsEnum, IsNumber, IsOptional, IsString } from 'class-validator';
import { PayerType } from './PayerType';
import { PaymentStatus } from './PaymentStatus';
import { PaymentType } from './PaymentType';
export class PaymentDTO {
@ApiProperty()

View File

@@ -1,5 +1,5 @@
import { ApiProperty } from '@nestjs/swagger';
import { IsString, IsNotEmpty, IsNumber, IsEnum, IsOptional, IsDate, IsBoolean } from 'class-validator';
import { IsBoolean, IsDate, IsEnum, IsNotEmpty, IsNumber, IsOptional, IsString } from 'class-validator';
export enum PaymentType {
SPONSORSHIP = 'sponsorship',

View File

@@ -1,6 +1,6 @@
import { ApiProperty } from '@nestjs/swagger';
import { IsObject } from 'class-validator';
import { WalletDto, TransactionDto } from './PaymentsDto';
import { TransactionDto, WalletDto } from './PaymentsDto';
export class ProcessWalletTransactionResultDTO {
@ApiProperty({ type: WalletDto })

View File

@@ -1,5 +1,5 @@
import { ApiProperty } from '@nestjs/swagger';
import { IsString, IsEnum } from 'class-validator';
import { IsEnum, IsString } from 'class-validator';
import { PaymentStatus } from './PaymentStatus';
export class UpdatePaymentStatusInputDTO {

View File

@@ -1,5 +1,5 @@
import type { UseCaseOutputPort } from '@core/shared/application';
import type { CreatePaymentResult } from '@core/payments/application/use-cases/CreatePaymentUseCase';
import type { UseCaseOutputPort } from '@core/shared/application';
import type { CreatePaymentOutput } from '../dtos/PaymentsDto';
export class CreatePaymentPresenter implements UseCaseOutputPort<CreatePaymentResult> {

View File

@@ -1,5 +1,5 @@
import type { UseCaseOutputPort } from '@core/shared/application';
import type { GetPaymentsResult } from '@core/payments/application/use-cases/GetPaymentsUseCase';
import type { UseCaseOutputPort } from '@core/shared/application';
import type { GetPaymentsOutput } from '../dtos/PaymentsDto';
export class GetPaymentsPresenter implements UseCaseOutputPort<GetPaymentsResult> {

View File

@@ -1,5 +1,5 @@
import type { UseCaseOutputPort } from '@core/shared/application';
import type { UpdatePaymentStatusResult } from '@core/payments/application/use-cases/UpdatePaymentStatusUseCase';
import type { UseCaseOutputPort } from '@core/shared/application';
import type { UpdatePaymentStatusOutput } from '../dtos/PaymentsDto';
export class UpdatePaymentStatusPresenter implements UseCaseOutputPort<UpdatePaymentStatusResult> {