style: align multiline ternary operators

This commit is contained in:
2026-09-28 16:37:01 +03:00
committed by ksv741
parent b78c215ff1
commit 183b7f1efd
54 changed files with 986 additions and 982 deletions
@@ -100,23 +100,23 @@ export function normalizeScreen(
...(accountId ? { accountId } : {}),
...(input.from ? { from: input.from } : {}),
...(input.to ? { to: input.to } : {}),
...(input.instrumentUid ?
{ instrumentUid: input.instrumentUid.toLowerCase() } :
{}),
...(input.instrumentUid
? { instrumentUid: input.instrumentUid.toLowerCase() }
: {}),
...(query ? { query } : {}),
...(input.candlePeriod ? { candlePeriod: input.candlePeriod } : {}),
...(input.candleRange ?
{
...(input.candleRange
? {
candleRange: {
from: new Date(input.candleRange.from).toISOString(),
to: new Date(input.candleRange.to).toISOString(),
},
} :
{}),
...(input.categories ?
// eslint-disable-next-line sonarjs/no-alphabetical-sort -- Code-unit ordering is intentional for canonical keys and ISO dates; locale collation would change persisted bindings.
{ categories: [...new Set(input.categories)].sort() } :
{}),
}
: {}),
...(input.categories
// eslint-disable-next-line sonarjs/no-alphabetical-sort -- Code-unit ordering is intentional for canonical keys and ISO dates; locale collation would change persisted bindings.
? { categories: [...new Set(input.categories)].sort() }
: {}),
...(input.limit !== undefined ? { limit: input.limit } : {}),
};
}
@@ -79,9 +79,9 @@ export class TbankSyncRepository {
work,
children: children.map((child) =>
progress.attempts?.[child.id] &&
progress.attempts[child.id] !== child.attemptId ?
{ ...child, state: 'cancelled', errorCode: null } :
child,
progress.attempts[child.id] !== child.attemptId
? { ...child, state: 'cancelled', errorCode: null }
: child,
),
progress,
};
@@ -120,9 +120,9 @@ export class TbankSyncService {
)
) {
for (const account of scope.screen === 'stock' ||
scope.screen === 'bond' ?
current.accounts :
selectedAccounts) {
scope.screen === 'bond'
? current.accounts
: selectedAccounts) {
const work = await this.portfolio.request(
userId,
revision,
@@ -135,9 +135,9 @@ export class TbankSyncService {
}
const saved = await this.portfolio.read(
userId,
scope.screen === 'stock' || scope.screen === 'bond' ?
'all' :
accountScope,
scope.screen === 'stock' || scope.screen === 'bond'
? 'all'
: accountScope,
true,
);
const positions = saved.data?.positions ?? [];
@@ -145,8 +145,8 @@ export class TbankSyncService {
...new Map(
positions.flatMap((position) =>
position.instrumentUid &&
(position.type === 'STOCK' || position.type === 'BOND') ?
[
(position.type === 'STOCK' || position.type === 'BOND')
? [
[
position.instrumentUid,
{
@@ -155,27 +155,27 @@ export class TbankSyncService {
historyFrom: null,
},
] as const,
] :
[],
]
: [],
),
).values(),
];
const plan = planInvestmentScreen(
{
...scope,
candleRange: scope.candleRange ?
{
candleRange: scope.candleRange
? {
from: new Date(scope.candleRange.from),
to: new Date(scope.candleRange.to),
} :
undefined,
}
: undefined,
},
{
accounts: selectedAccounts,
instruments:
scope.screen === 'stocks' || scope.screen === 'bonds' ?
[] :
instruments,
scope.screen === 'stocks' || scope.screen === 'bonds'
? []
: instruments,
membershipKnown: Boolean(current.membershipAt),
},
now,
@@ -185,18 +185,18 @@ export class TbankSyncService {
source.kind === 'operations' &&
source.accountId &&
source.from &&
source.to ?
[
source.to
? [
{
accountId: source.accountId,
from: source.from,
to: source.to,
...(source.instrumentUid ?
{ instrumentUid: source.instrumentUid } :
{}),
...(source.instrumentUid
? { instrumentUid: source.instrumentUid }
: {}),
},
] :
[],
]
: [],
);
if (intervals.length) {
await add([
@@ -278,11 +278,11 @@ export class TbankSyncService {
[uid],
true,
[
type === 'share' ?
'dividends' :
scope.screen === 'bond' ?
'coupons' :
'bond-events',
type === 'share'
? 'dividends'
: scope.screen === 'bond'
? 'coupons'
: 'bond-events',
],
{
from: source.from.toISOString().slice(ISO_DATE_START, ISO_DATE_LENGTH),
@@ -307,14 +307,14 @@ export class TbankSyncService {
uid: scope.instrumentUid,
instrumentType: scope.screen === 'bond' ? 'bond' : 'share',
period: scope.candlePeriod ?? 'month',
...(scope.candleRange ?
{
...(scope.candleRange
? {
range: {
from: new Date(scope.candleRange.from),
to: new Date(scope.candleRange.to),
},
} :
{}),
}
: {}),
},
now,
true,
@@ -346,9 +346,9 @@ export class TbankSyncService {
await this.access.local(userId, intent.scope.accountId);
const children = await Promise.all(
saved.children.map((child) =>
child.state === 'superseded' ?
this.operations.observe(userId, child.id) :
Promise.resolve(child),
child.state === 'superseded'
? this.operations.observe(userId, child.id)
: Promise.resolve(child),
),
);
const running = children.some((child) => child.state === 'running');
@@ -358,15 +358,15 @@ export class TbankSyncService {
null;
const state =
saved.work.processRunId !== this.runId &&
(!saved.progress.dispatched || running) ?
'cancelled' :
!saved.progress.dispatched || running ?
'running' :
failed ?
'failed' :
children.some((child) => child.state === 'cancelled') ?
'cancelled' :
'succeeded';
(!saved.progress.dispatched || running)
? 'cancelled'
: !saved.progress.dispatched || running
? 'running'
: failed
? 'failed'
: children.some((child) => child.state === 'cancelled')
? 'cancelled'
: 'succeeded';
const resources = await this.observe(userId, intent.scope);
if (
(await this.access.local(userId, intent.scope.accountId)).revision !==
@@ -423,9 +423,9 @@ export class TbankSyncService {
typeof input.kind === 'string'
) {
const range =
typeof input.rangeKey === 'string' && input.rangeKey.startsWith('[') ?
(JSON.parse(input.rangeKey) as string[]) :
null;
typeof input.rangeKey === 'string' && input.rangeKey.startsWith('[')
? (JSON.parse(input.rangeKey) as string[])
: null;
const sources = await this.sources.readMany(
userId,
type,
@@ -434,9 +434,9 @@ export class TbankSyncService {
[
input.kind as Parameters<
CatalogEnrichmentService['readMany']
>[4] extends (infer K)[] | undefined ?
K :
never,
>[4] extends (infer K)[] | undefined
? K
: never,
],
range ? { from: range[0], to: range[1] } : undefined,
);
@@ -492,19 +492,19 @@ export class TbankSyncService {
);
}
}
const observed = work.scopeKey.startsWith('operations:') ?
await this.operations.observe(userId, work.id) :
work;
const observed = work.scopeKey.startsWith('operations:')
? await this.operations.observe(userId, work.id)
: work;
const state =
observed.state === 'running' ?
observed.updatedAt < this.startedAt ?
'cancelled' :
'running' :
observed.state === 'failed' ?
'failed' :
observed.state === 'cancelled' ?
'cancelled' :
'succeeded';
observed.state === 'running'
? observed.updatedAt < this.startedAt
? 'cancelled'
: 'running'
: observed.state === 'failed'
? 'failed'
: observed.state === 'cancelled'
? 'cancelled'
: 'succeeded';
if ((await this.access.local(userId)).revision !== work.revision) {
throw new NotFoundException();
}
@@ -597,27 +597,27 @@ export class TbankSyncService {
uid,
instrumentType: type,
period: scope.candlePeriod ?? 'month',
...(scope.candleRange ?
{
...(scope.candleRange
? {
range: {
from: new Date(scope.candleRange.from),
to: new Date(scope.candleRange.to),
},
} :
{}),
}
: {}),
},
true,
),
);
await add(
type === 'share' ?
this.stockIncome.readPosition(userId, uid, true) :
this.bondIncome.readPosition(userId, uid, true),
type === 'share'
? this.stockIncome.readPosition(userId, uid, true)
: this.bondIncome.readPosition(userId, uid, true),
);
await add(
type === 'share' ?
this.stockIncome.dividends(userId, uid, true) :
this.bondIncome.coupons(userId, uid, true),
type === 'share'
? this.stockIncome.dividends(userId, uid, true)
: this.bondIncome.coupons(userId, uid, true),
);
}
return resources;