chore: strengthen backend eslint profile
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
import { InvestmentResourceMetaDto } from '../investment-resource.dto';
|
||||
import { ApiProperty } from '@nestjs/swagger';
|
||||
|
||||
import { MoneyDto } from '../../../common/money.dto';
|
||||
import { InvestmentResourceMetaDto } from '../investment-resource.dto';
|
||||
|
||||
export class PortfolioSummaryDto {
|
||||
@ApiProperty({ type: MoneyDto, isArray: true })
|
||||
@@ -40,15 +41,18 @@ export class BrokerageAccountDto {
|
||||
'BROKERAGE' | 'INDIVIDUAL_INVESTMENT' | 'INVEST_BOX' | 'MONEY_MARKET_FUND';
|
||||
|
||||
@ApiProperty({ type: String, nullable: true, format: 'date' })
|
||||
declare openedOn: string | null;
|
||||
declare openedOn: null | string;
|
||||
|
||||
// eslint-disable-next-line @darraghor/nestjs-typed/api-property-matches-property-optionality -- Preserve the published required nullable schema; partial internal models may omit the field.
|
||||
@ApiProperty({ type: PortfolioSummaryDto, nullable: true })
|
||||
portfolioSummary?: PortfolioSummaryDto | null;
|
||||
portfolioSummary?: null | PortfolioSummaryDto;
|
||||
}
|
||||
|
||||
export class BrokerageAccountsResourceDto {
|
||||
// eslint-disable-next-line @darraghor/nestjs-typed/api-property-returning-array-should-set-array -- Nullable array union requires isArray in the explicit wire schema.
|
||||
@ApiProperty({ type: BrokerageAccountDto, isArray: true, nullable: true })
|
||||
declare data: BrokerageAccountDto[] | null;
|
||||
|
||||
@ApiProperty({ type: InvestmentResourceMetaDto })
|
||||
declare meta: InvestmentResourceMetaDto;
|
||||
}
|
||||
|
||||
@@ -1,9 +1,11 @@
|
||||
import { InvestmentReadQueryDto } from '../investment-resource.dto';
|
||||
import { Controller, Get, Req, Query, UseGuards } from '@nestjs/common';
|
||||
import { ApiBearerAuth, ApiOkResponse, ApiTags } from '@nestjs/swagger';
|
||||
import type { Request } from 'express';
|
||||
|
||||
import { Controller, Get, Query, Req, UseGuards } from '@nestjs/common';
|
||||
import { ApiBearerAuth, ApiOkResponse, ApiTags } from '@nestjs/swagger';
|
||||
|
||||
import { ApiProblemResponses } from '../../../common/decorators/api-safe-error-response.decorator';
|
||||
import { AccessPayload, JwtAuthGuard } from '../../auth/auth.api';
|
||||
import { InvestmentReadQueryDto } from '../investment-resource.dto';
|
||||
import { BrokerageAccountsResourceDto } from './brokerage-account.dto';
|
||||
import { BrokerageAccountsService } from './brokerage-accounts.service';
|
||||
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
import { PortfolioModule } from '../portfolio/portfolio.module';
|
||||
import { Module } from '@nestjs/common';
|
||||
|
||||
import { TbankModule } from '../../../integrations/tbank/tbank.module';
|
||||
import { AuthModule } from '../../auth/auth.module';
|
||||
import { PortfolioModule } from '../portfolio/portfolio.module';
|
||||
import { BrokerageAccountsController } from './brokerage-accounts.controller';
|
||||
import { BrokerageAccountsService } from './brokerage-accounts.service';
|
||||
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
jest.mock('../../../prisma/prisma.service', () => ({
|
||||
PrismaService: class {},
|
||||
}));
|
||||
import { BrokerageAccountsService } from './brokerage-accounts.service';
|
||||
import { investmentResourceMeta } from '../investment-resource.mapper';
|
||||
import { BrokerageAccountsService } from './brokerage-accounts.service';
|
||||
|
||||
jest.mock('../portfolio/application/portfolio.service', () => ({
|
||||
PortfolioService: class PortfolioService {},
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
import { Injectable } from '@nestjs/common';
|
||||
import { createHash } from 'node:crypto';
|
||||
import { PortfolioService } from '../portfolio/portfolio.api';
|
||||
|
||||
import { investmentResourceMeta } from '../investment-resource.mapper';
|
||||
import { PortfolioService } from '../portfolio/portfolio.api';
|
||||
import { BrokerageAccountDto } from './brokerage-account.dto';
|
||||
|
||||
@Injectable()
|
||||
@@ -11,15 +12,15 @@ export class BrokerageAccountsService {
|
||||
async list(userId: string, observe = false) {
|
||||
const saved = await this.portfolio.saved(userId, 'all', observe);
|
||||
const data: BrokerageAccountDto[] | null =
|
||||
saved.membership.availability === 'missing'
|
||||
? null
|
||||
: saved.accounts.map((account) => ({
|
||||
saved.membership.availability === 'missing' ?
|
||||
null :
|
||||
saved.accounts.map((account) => ({
|
||||
id: account.id,
|
||||
name: account.name,
|
||||
type: account.type as BrokerageAccountDto['type'],
|
||||
openedOn: account.openedOn,
|
||||
portfolioSummary: account.snapshot
|
||||
? {
|
||||
portfolioSummary: account.snapshot ?
|
||||
{
|
||||
totalsByCurrency: account.snapshot.totalsByCurrency,
|
||||
stockPositionCount: account.snapshot.positions.filter(
|
||||
(position) => position.type === 'STOCK',
|
||||
@@ -27,8 +28,8 @@ export class BrokerageAccountsService {
|
||||
bondPositionCount: account.snapshot.positions.filter(
|
||||
(position) => position.type === 'BOND',
|
||||
).length,
|
||||
}
|
||||
: null,
|
||||
} :
|
||||
null,
|
||||
}));
|
||||
return {
|
||||
data,
|
||||
@@ -46,18 +47,18 @@ export class BrokerageAccountsService {
|
||||
)
|
||||
.digest('base64url'),
|
||||
availability:
|
||||
data === null
|
||||
? 'missing'
|
||||
: saved.accounts.some((account) => !account.snapshot)
|
||||
? 'partial'
|
||||
: 'complete',
|
||||
fetchedAt: saved.membership.lastSuccessfulAt
|
||||
? new Date(saved.membership.lastSuccessfulAt)
|
||||
: null,
|
||||
data === null ?
|
||||
'missing' :
|
||||
saved.accounts.some((account) => !account.snapshot) ?
|
||||
'partial' :
|
||||
'complete',
|
||||
fetchedAt: saved.membership.lastSuccessfulAt ?
|
||||
new Date(saved.membership.lastSuccessfulAt) :
|
||||
null,
|
||||
freshForMs: 300_000,
|
||||
work: saved.membership.sync.id
|
||||
? { ...saved.membership.sync, id: saved.membership.sync.id }
|
||||
: null,
|
||||
work: saved.membership.sync.id ?
|
||||
{ ...saved.membership.sync, id: saved.membership.sync.id } :
|
||||
null,
|
||||
dependencies: saved.accounts.map((account) => account.meta),
|
||||
}),
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user