feat: render hourly investment states
This commit was merged in pull request #51.
This commit is contained in:
@@ -10,8 +10,6 @@ type BrokerageAccount = NonNullable<
|
|||||||
paths["/api/v1/brokerage-accounts"]["get"]["responses"][200]["content"]["application/json"]["data"]
|
paths["/api/v1/brokerage-accounts"]["get"]["responses"][200]["content"]["application/json"]["data"]
|
||||||
>[number];
|
>[number];
|
||||||
|
|
||||||
type BrokerageAccountsResponse = paths["/api/v1/brokerage-accounts"]["get"]["responses"][200]["content"]["application/json"];
|
|
||||||
|
|
||||||
function useBrokerageAccounts() {
|
function useBrokerageAccounts() {
|
||||||
const query = useResourceQuery({
|
const query = useResourceQuery({
|
||||||
meta: { accessGroup: "brokerage" },
|
meta: { accessGroup: "brokerage" },
|
||||||
@@ -21,7 +19,6 @@ function useBrokerageAccounts() {
|
|||||||
|
|
||||||
return {
|
return {
|
||||||
...query,
|
...query,
|
||||||
sync: query.sync as BrokerageAccountsResponse["sync"] | null,
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+16
-8
@@ -205,24 +205,32 @@ export const IndependentFreshness: Story
|
|||||||
],
|
],
|
||||||
[
|
[
|
||||||
{
|
{
|
||||||
availability: "complete",
|
availability: "available",
|
||||||
|
completeness: "complete",
|
||||||
dataRevision: "1",
|
dataRevision: "1",
|
||||||
freshness: "stale",
|
freshness: "stale",
|
||||||
lastSuccessfulAt: "2026-09-24T10:30:00Z",
|
lastAttempt: {
|
||||||
resourceKey: "portfolio/storybook-account",
|
finishedAt: "2026-09-24T10:31:00Z",
|
||||||
sync: {
|
problems: [],
|
||||||
errorCode: "TBANK_UNAVAILABLE",
|
startedAt: "2026-09-24T10:30:00Z",
|
||||||
id: "failed",
|
|
||||||
state: "failed",
|
state: "failed",
|
||||||
},
|
},
|
||||||
|
lastSuccessfulAt: "2026-09-24T10:30:00Z",
|
||||||
|
resourceKey: "portfolio/storybook-account",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
availability: "missing",
|
availability: "initial-loading",
|
||||||
|
completeness: "incomplete",
|
||||||
dataRevision: "0",
|
dataRevision: "0",
|
||||||
freshness: "unknown",
|
freshness: "unknown",
|
||||||
|
lastAttempt: {
|
||||||
|
finishedAt: null,
|
||||||
|
problems: [],
|
||||||
|
startedAt: "2026-09-24T10:30:00Z",
|
||||||
|
state: "running",
|
||||||
|
},
|
||||||
lastSuccessfulAt: null,
|
lastSuccessfulAt: null,
|
||||||
resourceKey: "portfolio/waiting",
|
resourceKey: "portfolio/waiting",
|
||||||
sync: { errorCode: null, id: "waiting", state: "running" },
|
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
|
|||||||
@@ -64,15 +64,16 @@ const BrokerageAccountSourceStatus: FC<BrokerageAccountSourceStatusProps> = (
|
|||||||
const { source } = props;
|
const { source } = props;
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
|
|
||||||
const isSyncing = source?.sync.state === "running";
|
const isSyncing = source?.lastAttempt.state === "running";
|
||||||
|
|
||||||
const errorText
|
const errorText
|
||||||
= source?.sync.state === "failed" ? t("accounts.refreshError") : null;
|
= source?.lastAttempt.state === "failed" ? t("accounts.refreshError") : null;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<SourceSyncStatus
|
<SourceSyncStatus
|
||||||
errorText={errorText}
|
errorText={errorText}
|
||||||
|
lastAttempt={source?.lastAttempt}
|
||||||
lastSuccessfulAt={source?.lastSuccessfulAt}
|
lastSuccessfulAt={source?.lastSuccessfulAt}
|
||||||
stale={source?.freshness === "stale"}
|
stale={source?.freshness === "stale"}
|
||||||
/>
|
/>
|
||||||
|
|||||||
@@ -5,20 +5,23 @@ import { resource } from "@/test/resource";
|
|||||||
import { section } from "./section";
|
import { section } from "./section";
|
||||||
|
|
||||||
describe("instrument source and transport presentation", () => {
|
describe("instrument source and transport presentation", () => {
|
||||||
it.each(["missing", "partial", "complete"] as const)(
|
it.each([
|
||||||
|
["initial-loading", "incomplete"],
|
||||||
|
["available", "complete"],
|
||||||
|
] as const)(
|
||||||
"keeps %s separate from successful transport",
|
"keeps %s separate from successful transport",
|
||||||
(availability) => {
|
(availability, completeness) => {
|
||||||
const data = availability === "missing" ? undefined : { rows: [] };
|
const data = availability === "initial-loading" ? undefined : { rows: [] };
|
||||||
|
|
||||||
const state = section({
|
const state = section({
|
||||||
data,
|
data,
|
||||||
isError: false,
|
isError: false,
|
||||||
meta: resource(data, { availability }).meta,
|
meta: resource(data, { availability, completeness }).meta,
|
||||||
});
|
});
|
||||||
|
|
||||||
expect(state.loading).toBe(availability === "missing");
|
expect(state.loading).toBe(availability === "initial-loading");
|
||||||
expect(state.partial).toBe(availability === "partial");
|
expect(state.partial).toBe(completeness === "incomplete");
|
||||||
expect(state.hasData).toBe(availability !== "missing");
|
expect(state.hasData).toBe(availability !== "initial-loading");
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
it("preserves empty successful data instead of treating it as missing", () => {
|
it("preserves empty successful data instead of treating it as missing", () => {
|
||||||
@@ -37,7 +40,12 @@ describe("instrument source and transport presentation", () => {
|
|||||||
|
|
||||||
it("preserves a full source when force fails", () => {
|
it("preserves a full source when force fails", () => {
|
||||||
const meta = resource([], {
|
const meta = resource([], {
|
||||||
sync: { errorCode: "TBANK_UNAVAILABLE", id: "work", state: "failed" },
|
lastAttempt: {
|
||||||
|
finishedAt: "2026-08-14T00:01:00Z",
|
||||||
|
problems: [],
|
||||||
|
startedAt: "2026-08-14T00:00:00Z",
|
||||||
|
state: "failed",
|
||||||
|
},
|
||||||
}).meta;
|
}).meta;
|
||||||
|
|
||||||
const state = section({ data: [], isError: false, meta });
|
const state = section({ data: [], isError: false, meta });
|
||||||
@@ -53,7 +61,12 @@ describe("instrument source and transport presentation", () => {
|
|||||||
data: undefined,
|
data: undefined,
|
||||||
isError: false,
|
isError: false,
|
||||||
meta: resource(null, {
|
meta: resource(null, {
|
||||||
sync: { errorCode: "TBANK_UNAVAILABLE", id: "work", state: "failed" },
|
lastAttempt: {
|
||||||
|
finishedAt: "2026-08-14T00:01:00Z",
|
||||||
|
problems: [],
|
||||||
|
startedAt: "2026-08-14T00:00:00Z",
|
||||||
|
state: "failed",
|
||||||
|
},
|
||||||
}).meta,
|
}).meta,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -16,14 +16,14 @@ function section(query: {
|
|||||||
isError: boolean;
|
isError: boolean;
|
||||||
meta?: InvestmentResourceMeta;
|
meta?: InvestmentResourceMeta;
|
||||||
}): SectionState {
|
}): SectionState {
|
||||||
const isError = query.isError || query.meta?.sync.state === "failed";
|
const isError = query.isError || query.meta?.lastAttempt.state === "failed";
|
||||||
const hasData = hasSectionData(query.data);
|
const hasData = hasSectionData(query.data);
|
||||||
|
|
||||||
return {
|
return {
|
||||||
error: isError,
|
error: isError,
|
||||||
hasData,
|
hasData,
|
||||||
loading: !hasData && !isError,
|
loading: !hasData && !isError,
|
||||||
partial: query.meta?.availability === "partial",
|
partial: query.meta?.completeness === "incomplete",
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -19,12 +19,14 @@ function auth() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
describe("read-only screen synchronization", () => {
|
describe("read-only screen synchronization", () => {
|
||||||
it("retries the resource with GET and never starts a sync POST", async () => {
|
it("retries the resource with GET without requesting source observation", async () => {
|
||||||
auth();
|
auth();
|
||||||
let gets = 0;
|
let gets = 0;
|
||||||
|
const syncModes: (null | string)[] = [];
|
||||||
server.use(
|
server.use(
|
||||||
http.get("*/api/v1/brokerage-accounts", () => {
|
http.get("*/api/v1/brokerage-accounts", ({ request }) => {
|
||||||
gets += 1;
|
gets += 1;
|
||||||
|
syncModes.push(new URL(request.url).searchParams.get("sync"));
|
||||||
|
|
||||||
return gets === 1
|
return gets === 1
|
||||||
? HttpResponse.json({ code: "TBANK_UNAVAILABLE" }, { status: 503 })
|
? HttpResponse.json({ code: "TBANK_UNAVAILABLE" }, { status: 503 })
|
||||||
@@ -49,6 +51,7 @@ describe("read-only screen synchronization", () => {
|
|||||||
await waitFor(() => expect(result.current.accounts.data).toEqual([]));
|
await waitFor(() => expect(result.current.accounts.data).toEqual([]));
|
||||||
|
|
||||||
expect(gets).toBe(2);
|
expect(gets).toBe(2);
|
||||||
|
expect(syncModes).toEqual([null, null]);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("refreshes the currently open resources together", async () => {
|
it("refreshes the currently open resources together", async () => {
|
||||||
|
|||||||
@@ -8,7 +8,6 @@ type ScreenResource = {
|
|||||||
isError: boolean;
|
isError: boolean;
|
||||||
isFetching: boolean;
|
isFetching: boolean;
|
||||||
meta?: InvestmentResourceMeta;
|
meta?: InvestmentResourceMeta;
|
||||||
observe: () => Promise<unknown>;
|
|
||||||
queryKey: QueryKey;
|
queryKey: QueryKey;
|
||||||
refetch: () => Promise<unknown>;
|
refetch: () => Promise<unknown>;
|
||||||
};
|
};
|
||||||
@@ -42,14 +41,12 @@ function useScreenSync(_scope: ScreenScope, resources: ScreenResource[]) {
|
|||||||
await Promise.allSettled(resources.map(resource => resource.refetch()));
|
await Promise.allSettled(resources.map(resource => resource.refetch()));
|
||||||
};
|
};
|
||||||
|
|
||||||
// Retry failed HTTP reads without asking the source to import again.
|
// Retry only the HTTP read; source attempts are reported in resource metadata.
|
||||||
const retry = async () => {
|
const retry = async () => {
|
||||||
const failed = resources.filter(
|
const failed = resources.filter(resource => resource.isError);
|
||||||
resource => resource.isError,
|
|
||||||
);
|
|
||||||
|
|
||||||
if (failed.length > 0)
|
if (failed.length > 0)
|
||||||
await Promise.allSettled(failed.map(resource => resource.observe()));
|
await Promise.allSettled(failed.map(resource => resource.refetch()));
|
||||||
else await refresh();
|
else await refresh();
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -57,7 +54,9 @@ function useScreenSync(_scope: ScreenScope, resources: ScreenResource[]) {
|
|||||||
refresh,
|
refresh,
|
||||||
refreshing: isRefreshing,
|
refreshing: isRefreshing,
|
||||||
retry,
|
retry,
|
||||||
sourceError: resources.some(({ meta }) => meta?.sync.state === "failed"),
|
sourceError: resources.some(
|
||||||
|
({ meta }) => meta?.lastAttempt.state === "failed",
|
||||||
|
),
|
||||||
transportError: resources.some(resource => resource.isError),
|
transportError: resources.some(resource => resource.isError),
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -123,9 +123,10 @@ describe("Upcoming event date filters", () => {
|
|||||||
resource(
|
resource(
|
||||||
null,
|
null,
|
||||||
{
|
{
|
||||||
sync: {
|
lastAttempt: {
|
||||||
errorCode: "TBANK_UNAVAILABLE",
|
finishedAt: "2026-08-14T00:01:00Z",
|
||||||
id: null,
|
problems: [],
|
||||||
|
startedAt: "2026-08-14T00:00:00Z",
|
||||||
state: "failed",
|
state: "failed",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@@ -309,7 +310,14 @@ it("retains the previous complete forecast when its source refresh fails", async
|
|||||||
|
|
||||||
const snapshot = resource(
|
const snapshot = resource(
|
||||||
{ events, incomeTotalsByCurrency: [{ currency: "RUB", value: "123.45" }] },
|
{ events, incomeTotalsByCurrency: [{ currency: "RUB", value: "123.45" }] },
|
||||||
{ sync: { errorCode: "TBANK_UNAVAILABLE", id: "failed", state: "failed" } },
|
{
|
||||||
|
lastAttempt: {
|
||||||
|
finishedAt: "2026-08-14T00:01:00Z",
|
||||||
|
problems: [],
|
||||||
|
startedAt: "2026-08-14T00:00:00Z",
|
||||||
|
state: "failed",
|
||||||
|
},
|
||||||
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
server.use(
|
server.use(
|
||||||
|
|||||||
@@ -51,8 +51,9 @@ describe("AccountEventsPage", () => {
|
|||||||
isError: false,
|
isError: false,
|
||||||
isLoading: false,
|
isLoading: false,
|
||||||
meta: {
|
meta: {
|
||||||
availability: "complete",
|
availability: "available",
|
||||||
sync: { errorCode: null, id: null, state: "idle" },
|
completeness: "complete",
|
||||||
|
lastAttempt: { finishedAt: null, problems: [], startedAt: null, state: "none" },
|
||||||
},
|
},
|
||||||
refetch: vi.fn(),
|
refetch: vi.fn(),
|
||||||
} as never,
|
} as never,
|
||||||
@@ -85,8 +86,9 @@ describe("AccountEventsPage", () => {
|
|||||||
isError: false,
|
isError: false,
|
||||||
isLoading: false,
|
isLoading: false,
|
||||||
meta: {
|
meta: {
|
||||||
availability: "complete",
|
availability: "available",
|
||||||
sync: { errorCode: null, id: null, state: "idle" },
|
completeness: "complete",
|
||||||
|
lastAttempt: { finishedAt: null, problems: [], startedAt: null, state: "none" },
|
||||||
},
|
},
|
||||||
refetch: vi.fn(),
|
refetch: vi.fn(),
|
||||||
} as never,
|
} as never,
|
||||||
@@ -138,8 +140,9 @@ describe("AccountEventsPage", () => {
|
|||||||
isError: false,
|
isError: false,
|
||||||
isLoading: false,
|
isLoading: false,
|
||||||
meta: {
|
meta: {
|
||||||
availability: "complete",
|
availability: "available",
|
||||||
sync: { errorCode: null, id: null, state: "idle" },
|
completeness: "complete",
|
||||||
|
lastAttempt: { finishedAt: null, problems: [], startedAt: null, state: "none" },
|
||||||
},
|
},
|
||||||
refetch: vi.fn(),
|
refetch: vi.fn(),
|
||||||
} as never,
|
} as never,
|
||||||
@@ -194,8 +197,9 @@ describe("AccountEventsPage", () => {
|
|||||||
isError: false,
|
isError: false,
|
||||||
isLoading: true,
|
isLoading: true,
|
||||||
meta: {
|
meta: {
|
||||||
availability: "complete",
|
availability: "available",
|
||||||
sync: { errorCode: null, id: null, state: "idle" },
|
completeness: "complete",
|
||||||
|
lastAttempt: { finishedAt: null, problems: [], startedAt: null, state: "none" },
|
||||||
},
|
},
|
||||||
refetch: vi.fn(),
|
refetch: vi.fn(),
|
||||||
} as never,
|
} as never,
|
||||||
|
|||||||
@@ -1,6 +1,8 @@
|
|||||||
import { useState } from "react";
|
import { useState } from "react";
|
||||||
import { useParams } from "react-router";
|
import { useParams } from "react-router";
|
||||||
|
|
||||||
|
import type { InvestmentResourceMeta } from "@/shared/api";
|
||||||
|
|
||||||
import {
|
import {
|
||||||
type BrokerageEvent,
|
type BrokerageEvent,
|
||||||
useBrokerageEvents,
|
useBrokerageEvents,
|
||||||
@@ -25,6 +27,7 @@ type AccountEventsPageViewModel
|
|||||||
onPeriodPopoverOpen: () => void;
|
onPeriodPopoverOpen: () => void;
|
||||||
onReset: () => void;
|
onReset: () => void;
|
||||||
partial?: boolean;
|
partial?: boolean;
|
||||||
|
source?: InvestmentResourceMeta;
|
||||||
state: "loaded";
|
state: "loaded";
|
||||||
}
|
}
|
||||||
| { onReset: () => void; state: "error" }
|
| { onReset: () => void; state: "error" }
|
||||||
@@ -74,7 +77,7 @@ function useAccountEventsPageViewModel(): AccountEventsPageViewModel {
|
|||||||
const availability = useInitialAvailability({
|
const availability = useInitialAvailability({
|
||||||
hasContent: !!events.data,
|
hasContent: !!events.data,
|
||||||
identity: scope,
|
identity: scope,
|
||||||
isError: events.isError || events.meta?.sync.state === "failed",
|
isError: events.isError || events.meta?.lastAttempt.state === "failed",
|
||||||
isFetching: events.isFetching,
|
isFetching: events.isFetching,
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -86,7 +89,7 @@ function useAccountEventsPageViewModel(): AccountEventsPageViewModel {
|
|||||||
setSearchParameters({});
|
setSearchParameters({});
|
||||||
};
|
};
|
||||||
|
|
||||||
if ((events.isError || events.meta?.sync.state === "failed") && !events.data)
|
if ((events.isError || events.meta?.lastAttempt.state === "failed") && !events.data)
|
||||||
return {
|
return {
|
||||||
onReset,
|
onReset,
|
||||||
state: "error",
|
state: "error",
|
||||||
@@ -115,7 +118,8 @@ function useAccountEventsPageViewModel(): AccountEventsPageViewModel {
|
|||||||
),
|
),
|
||||||
onPeriodPopoverOpen: () => setMaxDate(moscowDate(new Date())),
|
onPeriodPopoverOpen: () => setMaxDate(moscowDate(new Date())),
|
||||||
onReset,
|
onReset,
|
||||||
partial: events.meta?.availability !== "complete",
|
partial: events.meta?.completeness === "incomplete",
|
||||||
|
source: events.meta,
|
||||||
state: "loaded",
|
state: "loaded",
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
+7
@@ -15,6 +15,7 @@ import {
|
|||||||
BrokerageEventCard,
|
BrokerageEventCard,
|
||||||
brokerageEventKey,
|
brokerageEventKey,
|
||||||
} from "@/entities/brokerage-event";
|
} from "@/entities/brokerage-event";
|
||||||
|
import { SourceSyncStatus } from "@/shared/ui";
|
||||||
|
|
||||||
import type { AccountEventsPageViewModel } from "../AccountEventsPage.vm";
|
import type { AccountEventsPageViewModel } from "../AccountEventsPage.vm";
|
||||||
|
|
||||||
@@ -55,6 +56,12 @@ const AccountEventsPageLoaded: FC<AccountEventsPageLoadedProps> = (props) => {
|
|||||||
<Stack gap="lg">
|
<Stack gap="lg">
|
||||||
<Title order={1}>{t("events.title")}</Title>
|
<Title order={1}>{t("events.title")}</Title>
|
||||||
|
|
||||||
|
<SourceSyncStatus
|
||||||
|
lastAttempt={props.source?.lastAttempt}
|
||||||
|
lastSuccessfulAt={props.source?.lastSuccessfulAt}
|
||||||
|
stale={props.source?.freshness === "stale"}
|
||||||
|
/>
|
||||||
|
|
||||||
{!!props.partial && <Alert role="status">{t("investment.partial")}</Alert>}
|
{!!props.partial && <Alert role="status">{t("investment.partial")}</Alert>}
|
||||||
|
|
||||||
<Text c="dimmed">{t("events.hint")}</Text>
|
<Text c="dimmed">{t("events.hint")}</Text>
|
||||||
|
|||||||
@@ -136,13 +136,14 @@ it("maps comparison notices by role regardless of dependency order or resource k
|
|||||||
const previous
|
const previous
|
||||||
= {
|
= {
|
||||||
...resource(null).meta,
|
...resource(null).meta,
|
||||||
resourceKey: "opaque/year-looking-key",
|
lastAttempt: {
|
||||||
role: "previous" as const,
|
finishedAt: "2026-08-14T00:01:00Z",
|
||||||
sync: {
|
problems: [],
|
||||||
errorCode: "TBANK_UNAVAILABLE",
|
startedAt: "2026-08-14T00:00:00Z",
|
||||||
id: null,
|
|
||||||
state: "failed" as const,
|
state: "failed" as const,
|
||||||
},
|
},
|
||||||
|
resourceKey: "opaque/year-looking-key",
|
||||||
|
role: "previous" as const,
|
||||||
};
|
};
|
||||||
|
|
||||||
const year = {
|
const year = {
|
||||||
|
|||||||
@@ -66,7 +66,7 @@ function comparisonNotice(
|
|||||||
): ComparisonNotice {
|
): ComparisonNotice {
|
||||||
if (!dependency || dependency.unavailableReason) return unavailable;
|
if (!dependency || dependency.unavailableReason) return unavailable;
|
||||||
|
|
||||||
return dependency.sync.state === "failed"
|
return dependency.lastAttempt.state === "failed"
|
||||||
? "comparisonFailed"
|
? "comparisonFailed"
|
||||||
: "comparisonPending";
|
: "comparisonPending";
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -205,9 +205,10 @@ describe("AccountIncomePage", () => {
|
|||||||
resource(
|
resource(
|
||||||
null,
|
null,
|
||||||
{
|
{
|
||||||
sync: {
|
lastAttempt: {
|
||||||
errorCode: "TBANK_UNAVAILABLE",
|
finishedAt: "2026-08-14T00:01:00Z",
|
||||||
id: null,
|
problems: [],
|
||||||
|
startedAt: "2026-08-14T00:00:00Z",
|
||||||
state: "failed",
|
state: "failed",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@@ -832,12 +833,13 @@ it("keeps complete previous comparison while year source failed without inventin
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
...resource(null).meta,
|
...resource(null).meta,
|
||||||
role: "year" as const,
|
lastAttempt: {
|
||||||
sync: {
|
finishedAt: "2026-08-14T00:01:00Z",
|
||||||
errorCode: "TBANK_UNAVAILABLE",
|
problems: [],
|
||||||
id: null,
|
startedAt: "2026-08-14T00:00:00Z",
|
||||||
state: "failed" as const,
|
state: "failed" as const,
|
||||||
},
|
},
|
||||||
|
role: "year" as const,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
...resource(analytics).meta,
|
...resource(analytics).meta,
|
||||||
|
|||||||
@@ -79,7 +79,7 @@ const useAccountIncomePageViewModel = (): AccountIncomePageViewModel => {
|
|||||||
const availability = useInitialAvailability({
|
const availability = useInitialAvailability({
|
||||||
hasContent: !!analytics.data,
|
hasContent: !!analytics.data,
|
||||||
identity: `${accountId}:${period.from}:${period.to}`,
|
identity: `${accountId}:${period.from}:${period.to}`,
|
||||||
isError: analytics.isError || analytics.meta?.sync.state === "failed",
|
isError: analytics.isError || analytics.meta?.lastAttempt.state === "failed",
|
||||||
isFetching: analytics.isFetching,
|
isFetching: analytics.isFetching,
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -114,7 +114,7 @@ const useAccountIncomePageViewModel = (): AccountIncomePageViewModel => {
|
|||||||
formRevision: `${accountId}:${period.from}:${period.to}:${resetRevision}`,
|
formRevision: `${accountId}:${period.from}:${period.to}:${resetRevision}`,
|
||||||
onReset,
|
onReset,
|
||||||
onSubmit,
|
onSubmit,
|
||||||
partial: analytics.meta?.availability !== "complete",
|
partial: analytics.meta?.completeness === "incomplete",
|
||||||
state: "loaded",
|
state: "loaded",
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|||||||
+5
-4
@@ -507,9 +507,10 @@ it("keeps UTC operation boundaries in GET and source sync requests", async () =>
|
|||||||
resource(
|
resource(
|
||||||
null,
|
null,
|
||||||
{
|
{
|
||||||
sync: {
|
lastAttempt: {
|
||||||
errorCode: "TBANK_UNAVAILABLE",
|
finishedAt: "2026-08-14T00:01:00Z",
|
||||||
id: null,
|
problems: [],
|
||||||
|
startedAt: "2026-08-14T00:00:00Z",
|
||||||
state: "failed",
|
state: "failed",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@@ -543,7 +544,7 @@ it("does not label incomplete empty operations as a confirmed empty period", asy
|
|||||||
items: [],
|
items: [],
|
||||||
nextCursor: null,
|
nextCursor: null,
|
||||||
},
|
},
|
||||||
{ availability: "partial" },
|
{ completeness: "incomplete" },
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|||||||
@@ -2,6 +2,8 @@ import { useQueryClient } from "@tanstack/react-query";
|
|||||||
import { useState } from "react";
|
import { useState } from "react";
|
||||||
import { useParams } from "react-router";
|
import { useParams } from "react-router";
|
||||||
|
|
||||||
|
import type { InvestmentResourceMeta } from "@/shared/api";
|
||||||
|
|
||||||
import {
|
import {
|
||||||
type BrokerageOperation,
|
type BrokerageOperation,
|
||||||
brokerageOperationsQueryOptions,
|
brokerageOperationsQueryOptions,
|
||||||
@@ -39,6 +41,7 @@ type AccountOperationsPageViewModel
|
|||||||
onPrevious: () => void;
|
onPrevious: () => void;
|
||||||
onReset: () => void;
|
onReset: () => void;
|
||||||
partial?: boolean;
|
partial?: boolean;
|
||||||
|
source?: InvestmentResourceMeta;
|
||||||
state: "loaded";
|
state: "loaded";
|
||||||
}
|
}
|
||||||
| { onReset: () => void; state: "error" }
|
| { onReset: () => void; state: "error" }
|
||||||
@@ -98,7 +101,7 @@ const useAccountOperationsPageVm = (): AccountOperationsPageViewModel => {
|
|||||||
const availability = useInitialAvailability({
|
const availability = useInitialAvailability({
|
||||||
hasContent: !!operations.data,
|
hasContent: !!operations.data,
|
||||||
identity: scope,
|
identity: scope,
|
||||||
isError: operations.isError || operations.meta?.sync.state === "failed",
|
isError: operations.isError || operations.meta?.lastAttempt.state === "failed",
|
||||||
isFetching: operations.isFetching,
|
isFetching: operations.isFetching,
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -127,7 +130,7 @@ const useAccountOperationsPageVm = (): AccountOperationsPageViewModel => {
|
|||||||
|
|
||||||
if (
|
if (
|
||||||
(isInvalidCursor || !operations.data)
|
(isInvalidCursor || !operations.data)
|
||||||
&& (operations.isError || operations.meta?.sync.state === "failed")
|
&& (operations.isError || operations.meta?.lastAttempt.state === "failed")
|
||||||
)
|
)
|
||||||
return { onReset, state: "error" };
|
return { onReset, state: "error" };
|
||||||
|
|
||||||
@@ -177,7 +180,8 @@ const useAccountOperationsPageVm = (): AccountOperationsPageViewModel => {
|
|||||||
onPeriodPopoverOpen: () => setMaxDate(moscowDate(new Date())),
|
onPeriodPopoverOpen: () => setMaxDate(moscowDate(new Date())),
|
||||||
onPrevious: history.onPrevious,
|
onPrevious: history.onPrevious,
|
||||||
onReset,
|
onReset,
|
||||||
partial: operations.meta?.availability !== "complete",
|
partial: operations.meta?.completeness === "incomplete",
|
||||||
|
source: operations.meta,
|
||||||
state: "loaded",
|
state: "loaded",
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|||||||
+7
@@ -13,6 +13,7 @@ import { StateView } from "@wealthledger/ui";
|
|||||||
import { useTranslation } from "react-i18next";
|
import { useTranslation } from "react-i18next";
|
||||||
|
|
||||||
import { LedgerEntryRow, operationCategories } from "@/entities/broker-operation";
|
import { LedgerEntryRow, operationCategories } from "@/entities/broker-operation";
|
||||||
|
import { SourceSyncStatus } from "@/shared/ui";
|
||||||
|
|
||||||
import type { AccountOperationsPageViewModel } from "../AccountOperationsPage.vm";
|
import type { AccountOperationsPageViewModel } from "../AccountOperationsPage.vm";
|
||||||
|
|
||||||
@@ -62,6 +63,12 @@ const AccountOperationsPageLoaded: FC<AccountOperationsPageLoadedProps> = (
|
|||||||
<Stack gap="lg">
|
<Stack gap="lg">
|
||||||
<Title order={1}>{t("ledger.title")}</Title>
|
<Title order={1}>{t("ledger.title")}</Title>
|
||||||
|
|
||||||
|
<SourceSyncStatus
|
||||||
|
lastAttempt={props.source?.lastAttempt}
|
||||||
|
lastSuccessfulAt={props.source?.lastSuccessfulAt}
|
||||||
|
stale={props.source?.freshness === "stale"}
|
||||||
|
/>
|
||||||
|
|
||||||
{!!props.partial && <Alert role="status">{t("investment.partial")}</Alert>}
|
{!!props.partial && <Alert role="status">{t("investment.partial")}</Alert>}
|
||||||
|
|
||||||
{!!props.historyLoading && <Alert>{t("investment.history")}</Alert>}
|
{!!props.historyLoading && <Alert>{t("investment.history")}</Alert>}
|
||||||
|
|||||||
@@ -46,9 +46,10 @@ type PreviewResource<T> = {
|
|||||||
isError: boolean;
|
isError: boolean;
|
||||||
meta?: Pick<InvestmentResourceMeta,
|
meta?: Pick<InvestmentResourceMeta,
|
||||||
"availability"
|
"availability"
|
||||||
|
| "completeness"
|
||||||
| "freshness"
|
| "freshness"
|
||||||
|
| "lastAttempt"
|
||||||
| "lastSuccessfulAt"
|
| "lastSuccessfulAt"
|
||||||
| "sync"
|
|
||||||
>;
|
>;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -57,10 +58,10 @@ function toIncomeSummary(
|
|||||||
income: PreviewResource<IncomeSummary>,
|
income: PreviewResource<IncomeSummary>,
|
||||||
): AccountPageIncomeSummary {
|
): AccountPageIncomeSummary {
|
||||||
const to = `/accounts/${accountId}/income`;
|
const to = `/accounts/${accountId}/income`;
|
||||||
if (!income.data && !income.isError && income.meta?.sync.state !== "failed")
|
if (!income.data && !income.isError && income.meta?.lastAttempt.state !== "failed")
|
||||||
return { state: "loading", to };
|
return { state: "loading", to };
|
||||||
if (income.meta?.availability === "partial") return { state: "partial", to };
|
if (income.meta?.completeness === "incomplete") return { state: "partial", to };
|
||||||
if (!income.data && (income.isError || income.meta?.sync.state === "failed"))
|
if (!income.data && (income.isError || income.meta?.lastAttempt.state === "failed"))
|
||||||
return { state: "error", to };
|
return { state: "error", to };
|
||||||
if (!income.data?.totalsByCurrency.length) return { state: "empty", to };
|
if (!income.data?.totalsByCurrency.length) return { state: "empty", to };
|
||||||
|
|
||||||
@@ -76,15 +77,15 @@ function toRecentEvents(
|
|||||||
events: PreviewResource<{ events: BrokerageEvent[] }>,
|
events: PreviewResource<{ events: BrokerageEvent[] }>,
|
||||||
): AccountPageRecentEvents {
|
): AccountPageRecentEvents {
|
||||||
const to = `/accounts/${accountId}/events`;
|
const to = `/accounts/${accountId}/events`;
|
||||||
if (!events.data && !events.isError && events.meta?.sync.state !== "failed")
|
if (!events.data && !events.isError && events.meta?.lastAttempt.state !== "failed")
|
||||||
return { state: "loading", to };
|
return { state: "loading", to };
|
||||||
if (events.meta?.availability === "partial")
|
if (events.meta?.completeness === "incomplete")
|
||||||
return {
|
return {
|
||||||
items: events.data?.events.slice(0, RECENT_EVENTS_LIMIT) ?? [],
|
items: events.data?.events.slice(0, RECENT_EVENTS_LIMIT) ?? [],
|
||||||
state: "partial",
|
state: "partial",
|
||||||
to,
|
to,
|
||||||
};
|
};
|
||||||
if (!events.data && (events.isError || events.meta?.sync.state === "failed"))
|
if (!events.data && (events.isError || events.meta?.lastAttempt.state === "failed"))
|
||||||
return { state: "error", to };
|
return { state: "error", to };
|
||||||
const items = events.data?.events.slice(0, RECENT_EVENTS_LIMIT) ?? [];
|
const items = events.data?.events.slice(0, RECENT_EVENTS_LIMIT) ?? [];
|
||||||
if (items.length === 0) return { state: "empty", to };
|
if (items.length === 0) return { state: "empty", to };
|
||||||
@@ -104,14 +105,14 @@ function toRecentOperations(
|
|||||||
if (
|
if (
|
||||||
!operations.data
|
!operations.data
|
||||||
&& !operations.isError
|
&& !operations.isError
|
||||||
&& operations.meta?.sync.state !== "failed"
|
&& operations.meta?.lastAttempt.state !== "failed"
|
||||||
)
|
)
|
||||||
return { state: "loading", to };
|
return { state: "loading", to };
|
||||||
if (operations.meta?.availability === "partial")
|
if (operations.meta?.completeness === "incomplete")
|
||||||
return { items: operations.data?.items ?? [], state: "partial", to };
|
return { items: operations.data?.items ?? [], state: "partial", to };
|
||||||
if (
|
if (
|
||||||
!operations.data
|
!operations.data
|
||||||
&& (operations.isError || operations.meta?.sync.state === "failed")
|
&& (operations.isError || operations.meta?.lastAttempt.state === "failed")
|
||||||
)
|
)
|
||||||
return { state: "error", to };
|
return { state: "error", to };
|
||||||
if (!operations.data?.items.length) return { state: "empty", to };
|
if (!operations.data?.items.length) return { state: "empty", to };
|
||||||
@@ -120,7 +121,7 @@ function toRecentOperations(
|
|||||||
items: operations.data.items,
|
items: operations.data.items,
|
||||||
lastSuccessfulAt: operations.meta?.lastSuccessfulAt,
|
lastSuccessfulAt: operations.meta?.lastSuccessfulAt,
|
||||||
refreshError:
|
refreshError:
|
||||||
operations.isError || operations.meta?.sync.state === "failed",
|
operations.isError || operations.meta?.lastAttempt.state === "failed",
|
||||||
stale: operations.meta?.freshness === "stale",
|
stale: operations.meta?.freshness === "stale",
|
||||||
state: "loaded",
|
state: "loaded",
|
||||||
to,
|
to,
|
||||||
|
|||||||
@@ -173,14 +173,14 @@ it("keeps overview sections independent when their source data is incomplete", a
|
|||||||
mockLoadedAccountPage();
|
mockLoadedAccountPage();
|
||||||
server.use(
|
server.use(
|
||||||
http.get("*/api/v1/brokerage-accounts/:accountId/portfolio", () =>
|
http.get("*/api/v1/brokerage-accounts/:accountId/portfolio", () =>
|
||||||
HttpResponse.json(resource(portfolio, { availability: "partial" })),
|
HttpResponse.json(resource(portfolio, { completeness: "incomplete" })),
|
||||||
),
|
),
|
||||||
http.get("*/api/v1/brokerage-accounts/:accountId/operations", () =>
|
http.get("*/api/v1/brokerage-accounts/:accountId/operations", () =>
|
||||||
HttpResponse.json(
|
HttpResponse.json(
|
||||||
|
|
||||||
resource(
|
resource(
|
||||||
{ hasNext: false, items: [], nextCursor: null },
|
{ hasNext: false, items: [], nextCursor: null },
|
||||||
{ availability: "partial" },
|
{ completeness: "incomplete" },
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
@@ -188,7 +188,7 @@ it("keeps overview sections independent when their source data is incomplete", a
|
|||||||
HttpResponse.json(
|
HttpResponse.json(
|
||||||
resource(
|
resource(
|
||||||
{ events: [], incomeTotalsByCurrency: [] },
|
{ events: [], incomeTotalsByCurrency: [] },
|
||||||
{ availability: "partial" },
|
{ completeness: "incomplete" },
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
import { useParams } from "react-router";
|
import { useParams } from "react-router";
|
||||||
|
|
||||||
import type { Portfolio } from "@/entities/portfolio";
|
import type { Portfolio } from "@/entities/portfolio";
|
||||||
|
import type { InvestmentResourceMeta } from "@/shared/api";
|
||||||
|
|
||||||
import { useBrokerageOperations } from "@/entities/broker-operation";
|
import { useBrokerageOperations } from "@/entities/broker-operation";
|
||||||
import {
|
import {
|
||||||
@@ -45,6 +46,7 @@ type AccountPageEmptyViewModel = AccountPageContent & {
|
|||||||
type AccountPageLoadedViewModel = AccountPageContent & {
|
type AccountPageLoadedViewModel = AccountPageContent & {
|
||||||
portfolio: Portfolio;
|
portfolio: Portfolio;
|
||||||
positionSections: AccountPagePositionSection[];
|
positionSections: AccountPagePositionSection[];
|
||||||
|
source?: InvestmentResourceMeta;
|
||||||
state: "loaded";
|
state: "loaded";
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -87,7 +89,7 @@ function useAccountPageViewModel(): AccountPageViewModel {
|
|||||||
const availability = useInitialAvailability({
|
const availability = useInitialAvailability({
|
||||||
hasContent: !!portfolio.data,
|
hasContent: !!portfolio.data,
|
||||||
identity: accountId ?? "account",
|
identity: accountId ?? "account",
|
||||||
isError: portfolio.isError || portfolio.meta?.sync.state === "failed",
|
isError: portfolio.isError || portfolio.meta?.lastAttempt.state === "failed",
|
||||||
isFetching: portfolio.isFetching,
|
isFetching: portfolio.isFetching,
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -105,7 +107,7 @@ function useAccountPageViewModel(): AccountPageViewModel {
|
|||||||
const incomeSummary = toIncomeSummary(accountId, income);
|
const incomeSummary = toIncomeSummary(accountId, income);
|
||||||
|
|
||||||
if (
|
if (
|
||||||
portfolio.meta?.availability === "complete"
|
portfolio.meta?.availability === "available"
|
||||||
&& portfolio.data.positions.length === 0
|
&& portfolio.data.positions.length === 0
|
||||||
&& portfolio.data.cashBalances.length === 0
|
&& portfolio.data.cashBalances.length === 0
|
||||||
)
|
)
|
||||||
@@ -118,7 +120,7 @@ function useAccountPageViewModel(): AccountPageViewModel {
|
|||||||
state: "empty" as const,
|
state: "empty" as const,
|
||||||
};
|
};
|
||||||
|
|
||||||
const isPartial = portfolio.meta?.availability === "partial";
|
const isPartial = portfolio.meta?.completeness === "incomplete";
|
||||||
|
|
||||||
return {
|
return {
|
||||||
account,
|
account,
|
||||||
@@ -129,6 +131,7 @@ function useAccountPageViewModel(): AccountPageViewModel {
|
|||||||
positionSections: toAccountPagePositionSections(portfolio.data),
|
positionSections: toAccountPagePositionSections(portfolio.data),
|
||||||
recentEvents,
|
recentEvents,
|
||||||
recentOperations,
|
recentOperations,
|
||||||
|
source: portfolio.meta,
|
||||||
state: "loaded" as const,
|
state: "loaded" as const,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,8 +5,10 @@ import { useTranslation } from "react-i18next";
|
|||||||
|
|
||||||
import type { BrokerageAccount } from "@/entities/brokerage-account";
|
import type { BrokerageAccount } from "@/entities/brokerage-account";
|
||||||
import type { Portfolio } from "@/entities/portfolio";
|
import type { Portfolio } from "@/entities/portfolio";
|
||||||
|
import type { InvestmentResourceMeta } from "@/shared/api";
|
||||||
|
|
||||||
import { BrokerageEventsPreview } from "@/entities/brokerage-event";
|
import { BrokerageEventsPreview } from "@/entities/brokerage-event";
|
||||||
|
import { SourceSyncStatus } from "@/shared/ui";
|
||||||
import { PortfolioStructure } from "@/widgets/portfolio-structure";
|
import { PortfolioStructure } from "@/widgets/portfolio-structure";
|
||||||
|
|
||||||
import type { AccountPagePositionSection } from "../../../model/positions";
|
import type { AccountPagePositionSection } from "../../../model/positions";
|
||||||
@@ -32,6 +34,7 @@ type AccountPageLoadedProps = {
|
|||||||
positionSections: AccountPagePositionSection[];
|
positionSections: AccountPagePositionSection[];
|
||||||
recentEvents: AccountPageRecentEvents;
|
recentEvents: AccountPageRecentEvents;
|
||||||
recentOperations: AccountPageRecentOperations;
|
recentOperations: AccountPageRecentOperations;
|
||||||
|
source?: InvestmentResourceMeta;
|
||||||
};
|
};
|
||||||
|
|
||||||
const AccountPageLoaded: FC<AccountPageLoadedProps> = (props) => {
|
const AccountPageLoaded: FC<AccountPageLoadedProps> = (props) => {
|
||||||
@@ -49,6 +52,12 @@ const AccountPageLoaded: FC<AccountPageLoadedProps> = (props) => {
|
|||||||
<Stack gap="lg">
|
<Stack gap="lg">
|
||||||
<AccountHeading account={props.account} accountId={props.accountId} />
|
<AccountHeading account={props.account} accountId={props.accountId} />
|
||||||
|
|
||||||
|
<SourceSyncStatus
|
||||||
|
lastAttempt={props.source?.lastAttempt}
|
||||||
|
lastSuccessfulAt={props.source?.lastSuccessfulAt}
|
||||||
|
stale={props.source?.freshness === "stale"}
|
||||||
|
/>
|
||||||
|
|
||||||
{props.partial
|
{props.partial
|
||||||
? <Alert role="status">{t("investment.partial")}</Alert>
|
? <Alert role="status">{t("investment.partial")}</Alert>
|
||||||
: <CurrencyCards amounts={props.portfolio.totalsByCurrency} />}
|
: <CurrencyCards amounts={props.portfolio.totalsByCurrency} />}
|
||||||
|
|||||||
@@ -189,14 +189,19 @@ describe("AccountsPage", () => {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
it.each(["idle", "failed"] as const)(
|
it.each(["none", "failed"] as const)(
|
||||||
"keeps partial empty membership distinct from no accounts (sync=%s)",
|
"keeps incomplete empty membership distinct from no accounts (attempt=%s)",
|
||||||
async (state) => {
|
async (state) => {
|
||||||
server.use(
|
server.use(
|
||||||
http.get("*/api/v1/brokerage-accounts", () =>
|
http.get("*/api/v1/brokerage-accounts", () =>
|
||||||
HttpResponse.json(resource([], {
|
HttpResponse.json(resource([], {
|
||||||
availability: "partial",
|
completeness: "incomplete",
|
||||||
sync: { errorCode: null, id: null, state },
|
lastAttempt: {
|
||||||
|
finishedAt: state === "failed" ? "2026-08-14T00:01:00Z" : null,
|
||||||
|
problems: [],
|
||||||
|
startedAt: state === "none" ? null : "2026-08-14T00:00:00Z",
|
||||||
|
state,
|
||||||
|
},
|
||||||
})),
|
})),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
@@ -205,7 +210,7 @@ it.each(["idle", "failed"] as const)(
|
|||||||
await waitFor(() =>
|
await waitFor(() =>
|
||||||
expect(client.getQueryData(brokerageAccountsQueryKey)).toMatchObject({
|
expect(client.getQueryData(brokerageAccountsQueryKey)).toMatchObject({
|
||||||
data: [],
|
data: [],
|
||||||
meta: { availability: "partial" },
|
meta: { completeness: "incomplete" },
|
||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
expect(screen.queryByText("Нет инвестиционных счетов"))
|
expect(screen.queryByText("Нет инвестиционных счетов"))
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ const AccountsPage: FC = () => {
|
|||||||
return (
|
return (
|
||||||
<AccountsPageLoaded
|
<AccountsPageLoaded
|
||||||
accounts={viewModel.accounts}
|
accounts={viewModel.accounts}
|
||||||
sync={viewModel.sync}
|
meta={viewModel.meta}
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -4,17 +4,15 @@ import {
|
|||||||
useBrokerageAccounts,
|
useBrokerageAccounts,
|
||||||
} from "@/entities/brokerage-account";
|
} from "@/entities/brokerage-account";
|
||||||
import { useScreenSync } from "@/features/tbank-connection";
|
import { useScreenSync } from "@/features/tbank-connection";
|
||||||
import { ApiErrorCode, apiErrorCode, isApiErrorCode, type paths } from "@/shared/api";
|
import { ApiErrorCode, apiErrorCode, isApiErrorCode } from "@/shared/api";
|
||||||
import { useInitialAvailability } from "@/shared/lib";
|
import { useInitialAvailability } from "@/shared/lib";
|
||||||
|
|
||||||
type AccountsPageViewModel
|
type AccountsPageViewModel
|
||||||
= | { accounts: BrokerageAccountCard[]; state: "loaded"; sync: AccountsSync }
|
= | { accounts: BrokerageAccountCard[]; meta: NonNullable<ReturnType<typeof useBrokerageAccounts>["meta"]>; state: "loaded" }
|
||||||
| { code?: string; state: "error" }
|
| { code?: string; state: "error" }
|
||||||
| { state: "empty" }
|
| { state: "empty" }
|
||||||
| { state: "loading" };
|
| { state: "loading" };
|
||||||
|
|
||||||
type AccountsSync = paths["/api/v1/brokerage-accounts"]["get"]["responses"][200]["content"]["application/json"]["sync"];
|
|
||||||
|
|
||||||
function isAccountsAccessFailure(code?: string) {
|
function isAccountsAccessFailure(code?: string) {
|
||||||
return isApiErrorCode(code, ApiErrorCode.InvalidTbankToken)
|
return isApiErrorCode(code, ApiErrorCode.InvalidTbankToken)
|
||||||
|| isApiErrorCode(code, ApiErrorCode.TbankNotConnected);
|
|| isApiErrorCode(code, ApiErrorCode.TbankNotConnected);
|
||||||
@@ -28,12 +26,13 @@ function useAccountsPageViewModel(): AccountsPageViewModel {
|
|||||||
const isAccessFailure = isAccountsAccessFailure(code);
|
const isAccessFailure = isAccountsAccessFailure(code);
|
||||||
|
|
||||||
const hasResult = !!accounts.data
|
const hasResult = !!accounts.data
|
||||||
&& !(accounts.meta?.availability === "partial" && accounts.data.length === 0);
|
&& !!accounts.meta
|
||||||
|
&& !(accounts.meta.completeness === "incomplete" && accounts.data.length === 0);
|
||||||
|
|
||||||
const availability = useInitialAvailability({
|
const availability = useInitialAvailability({
|
||||||
hasContent: hasResult,
|
hasContent: hasResult,
|
||||||
identity: "accounts",
|
identity: "accounts",
|
||||||
isError: accounts.isError || accounts.meta?.sync.state === "failed",
|
isError: accounts.isError || accounts.meta?.lastAttempt.state === "failed",
|
||||||
isFetching: accounts.isFetching,
|
isFetching: accounts.isFetching,
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -49,10 +48,13 @@ function useAccountsPageViewModel(): AccountsPageViewModel {
|
|||||||
state: "empty" as const,
|
state: "empty" as const,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const meta = accounts.meta;
|
||||||
|
if (!meta) return { state: "loading" as const };
|
||||||
|
|
||||||
return {
|
return {
|
||||||
accounts: brokerageAccountCards(accounts.data, accounts.meta?.dependencies),
|
accounts: brokerageAccountCards(accounts.data, meta.dependencies),
|
||||||
|
meta,
|
||||||
state: "loaded" as const,
|
state: "loaded" as const,
|
||||||
sync: accounts.sync,
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,45 +1,24 @@
|
|||||||
import type { FC } from "react";
|
import type { FC } from "react";
|
||||||
|
|
||||||
import { Badge, Button, Stack, Text, Title } from "@mantine/core";
|
import { Button, Stack, Text, Title } from "@mantine/core";
|
||||||
import { useTranslation } from "react-i18next";
|
import { useTranslation } from "react-i18next";
|
||||||
import { Link } from "react-router";
|
import { Link } from "react-router";
|
||||||
|
|
||||||
|
import type { InvestmentResourceMeta } from "@/shared/api";
|
||||||
|
|
||||||
import {
|
import {
|
||||||
type BrokerageAccountCard,
|
type BrokerageAccountCard,
|
||||||
BrokerageAccountList,
|
BrokerageAccountList,
|
||||||
} from "@/entities/brokerage-account";
|
} from "@/entities/brokerage-account";
|
||||||
|
import { SourceSyncStatus } from "@/shared/ui";
|
||||||
|
|
||||||
type AccountsPageLoadedProps = {
|
type AccountsPageLoadedProps = {
|
||||||
accounts: BrokerageAccountCard[];
|
accounts: BrokerageAccountCard[];
|
||||||
sync:
|
meta: InvestmentResourceMeta;
|
||||||
| null
|
|
||||||
| undefined
|
|
||||||
| {
|
|
||||||
finishedAt: null | string;
|
|
||||||
sections: {
|
|
||||||
accountId?: string;
|
|
||||||
errorCode: null | string;
|
|
||||||
section: string;
|
|
||||||
}[];
|
|
||||||
startedAt: string;
|
|
||||||
state: string;
|
|
||||||
};
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const AccountsPageLoaded: FC<AccountsPageLoadedProps> = (props) => {
|
const AccountsPageLoaded: FC<AccountsPageLoadedProps> = (props) => {
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
const sync = props.sync;
|
|
||||||
|
|
||||||
const syncLabel = sync
|
|
||||||
? new Intl.DateTimeFormat("ru-RU", {
|
|
||||||
dateStyle: "short",
|
|
||||||
timeStyle: "short",
|
|
||||||
}).format(new Date(sync.finishedAt ?? sync.startedAt))
|
|
||||||
: null;
|
|
||||||
|
|
||||||
const syncColor = sync?.state === "failed" || sync?.state === "partial"
|
|
||||||
? "red"
|
|
||||||
: "gray";
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Stack gap="lg">
|
<Stack gap="lg">
|
||||||
@@ -50,20 +29,11 @@ const AccountsPageLoaded: FC<AccountsPageLoadedProps> = (props) => {
|
|||||||
{t("accounts.subtitle")}
|
{t("accounts.subtitle")}
|
||||||
</Text>
|
</Text>
|
||||||
|
|
||||||
{sync && (
|
<SourceSyncStatus
|
||||||
<Text c="dimmed" size="xs">
|
lastAttempt={props.meta.lastAttempt}
|
||||||
Последний обход:
|
lastSuccessfulAt={props.meta.lastSuccessfulAt}
|
||||||
{" "}
|
stale={props.meta.freshness === "stale"}
|
||||||
{syncLabel}
|
/>
|
||||||
{" "}
|
|
||||||
<Badge
|
|
||||||
color={syncColor}
|
|
||||||
size="xs"
|
|
||||||
>
|
|
||||||
{sync.state}
|
|
||||||
</Badge>
|
|
||||||
</Text>
|
|
||||||
)}
|
|
||||||
</Stack>
|
</Stack>
|
||||||
|
|
||||||
<Button
|
<Button
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ function useBondsPageVm() {
|
|||||||
code: apiErrorCode(result.error),
|
code: apiErrorCode(result.error),
|
||||||
error:
|
error:
|
||||||
!result.data
|
!result.data
|
||||||
&& (result.isError || result.meta?.sync.state === "failed"),
|
&& (result.isError || result.meta?.lastAttempt.state === "failed"),
|
||||||
items:
|
items:
|
||||||
result.data?.map(bond => ({
|
result.data?.map(bond => ({
|
||||||
...bond,
|
...bond,
|
||||||
@@ -29,9 +29,9 @@ function useBondsPageVm() {
|
|||||||
&& (isWaiting
|
&& (isWaiting
|
||||||
|| (!result.data
|
|| (!result.data
|
||||||
&& !result.isError
|
&& !result.isError
|
||||||
&& result.meta?.sync.state !== "failed")),
|
&& result.meta?.lastAttempt.state !== "failed")),
|
||||||
onQueryChange: search.onQueryChange,
|
onQueryChange: search.onQueryChange,
|
||||||
partial: result.meta?.availability === "partial",
|
partial: result.meta?.completeness === "incomplete",
|
||||||
query,
|
query,
|
||||||
ready:
|
ready:
|
||||||
debounced.length >= MIN_BOND_SEARCH_LENGTH
|
debounced.length >= MIN_BOND_SEARCH_LENGTH
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ function useStocksPageVm() {
|
|||||||
code: apiErrorCode(result.error),
|
code: apiErrorCode(result.error),
|
||||||
error:
|
error:
|
||||||
!result.data
|
!result.data
|
||||||
&& (result.isError || result.meta?.sync.state === "failed"),
|
&& (result.isError || result.meta?.lastAttempt.state === "failed"),
|
||||||
items:
|
items:
|
||||||
result.data?.map(stock => ({
|
result.data?.map(stock => ({
|
||||||
...stock,
|
...stock,
|
||||||
@@ -29,9 +29,9 @@ function useStocksPageVm() {
|
|||||||
&& (isWaiting
|
&& (isWaiting
|
||||||
|| (!result.data
|
|| (!result.data
|
||||||
&& !result.isError
|
&& !result.isError
|
||||||
&& result.meta?.sync.state !== "failed")),
|
&& result.meta?.lastAttempt.state !== "failed")),
|
||||||
onQueryChange: search.onQueryChange,
|
onQueryChange: search.onQueryChange,
|
||||||
partial: result.meta?.availability === "partial",
|
partial: result.meta?.completeness === "incomplete",
|
||||||
query,
|
query,
|
||||||
ready:
|
ready:
|
||||||
debounced.length >= MIN_STOCK_SEARCH_LENGTH
|
debounced.length >= MIN_STOCK_SEARCH_LENGTH
|
||||||
|
|||||||
Vendored
+390
-381
@@ -276,22 +276,6 @@ export interface paths {
|
|||||||
patch?: never;
|
patch?: never;
|
||||||
trace?: never;
|
trace?: never;
|
||||||
};
|
};
|
||||||
"/api/v1/tbank-sync/{id}": {
|
|
||||||
parameters: {
|
|
||||||
query?: never;
|
|
||||||
header?: never;
|
|
||||||
path?: never;
|
|
||||||
cookie?: never;
|
|
||||||
};
|
|
||||||
get: operations["TbankSyncController_status"];
|
|
||||||
put?: never;
|
|
||||||
post?: never;
|
|
||||||
delete?: never;
|
|
||||||
options?: never;
|
|
||||||
head?: never;
|
|
||||||
patch?: never;
|
|
||||||
trace?: never;
|
|
||||||
};
|
|
||||||
"/api/v1/brokerage-accounts/all/operations": {
|
"/api/v1/brokerage-accounts/all/operations": {
|
||||||
parameters: {
|
parameters: {
|
||||||
query?: never;
|
query?: never;
|
||||||
@@ -324,38 +308,6 @@ export interface paths {
|
|||||||
patch?: never;
|
patch?: never;
|
||||||
trace?: never;
|
trace?: never;
|
||||||
};
|
};
|
||||||
"/api/v1/brokerage-accounts/all/events": {
|
|
||||||
parameters: {
|
|
||||||
query?: never;
|
|
||||||
header?: never;
|
|
||||||
path?: never;
|
|
||||||
cookie?: never;
|
|
||||||
};
|
|
||||||
get: operations["UpcomingEventsController_all"];
|
|
||||||
put?: never;
|
|
||||||
post?: never;
|
|
||||||
delete?: never;
|
|
||||||
options?: never;
|
|
||||||
head?: never;
|
|
||||||
patch?: never;
|
|
||||||
trace?: never;
|
|
||||||
};
|
|
||||||
"/api/v1/brokerage-accounts/{accountId}/events": {
|
|
||||||
parameters: {
|
|
||||||
query?: never;
|
|
||||||
header?: never;
|
|
||||||
path?: never;
|
|
||||||
cookie?: never;
|
|
||||||
};
|
|
||||||
get: operations["UpcomingEventsController_get"];
|
|
||||||
put?: never;
|
|
||||||
post?: never;
|
|
||||||
delete?: never;
|
|
||||||
options?: never;
|
|
||||||
head?: never;
|
|
||||||
patch?: never;
|
|
||||||
trace?: never;
|
|
||||||
};
|
|
||||||
"/api/v1/brokerage-accounts/all/income-summary": {
|
"/api/v1/brokerage-accounts/all/income-summary": {
|
||||||
parameters: {
|
parameters: {
|
||||||
query?: never;
|
query?: never;
|
||||||
@@ -420,6 +372,38 @@ export interface paths {
|
|||||||
patch?: never;
|
patch?: never;
|
||||||
trace?: never;
|
trace?: never;
|
||||||
};
|
};
|
||||||
|
"/api/v1/brokerage-accounts/all/events": {
|
||||||
|
parameters: {
|
||||||
|
query?: never;
|
||||||
|
header?: never;
|
||||||
|
path?: never;
|
||||||
|
cookie?: never;
|
||||||
|
};
|
||||||
|
get: operations["UpcomingEventsController_all"];
|
||||||
|
put?: never;
|
||||||
|
post?: never;
|
||||||
|
delete?: never;
|
||||||
|
options?: never;
|
||||||
|
head?: never;
|
||||||
|
patch?: never;
|
||||||
|
trace?: never;
|
||||||
|
};
|
||||||
|
"/api/v1/brokerage-accounts/{accountId}/events": {
|
||||||
|
parameters: {
|
||||||
|
query?: never;
|
||||||
|
header?: never;
|
||||||
|
path?: never;
|
||||||
|
cookie?: never;
|
||||||
|
};
|
||||||
|
get: operations["UpcomingEventsController_get"];
|
||||||
|
put?: never;
|
||||||
|
post?: never;
|
||||||
|
delete?: never;
|
||||||
|
options?: never;
|
||||||
|
head?: never;
|
||||||
|
patch?: never;
|
||||||
|
trace?: never;
|
||||||
|
};
|
||||||
"/api/v1/stocks": {
|
"/api/v1/stocks": {
|
||||||
parameters: {
|
parameters: {
|
||||||
query?: never;
|
query?: never;
|
||||||
@@ -692,6 +676,22 @@ export interface paths {
|
|||||||
patch?: never;
|
patch?: never;
|
||||||
trace?: never;
|
trace?: never;
|
||||||
};
|
};
|
||||||
|
"/api/v1/tbank-sync/{id}": {
|
||||||
|
parameters: {
|
||||||
|
query?: never;
|
||||||
|
header?: never;
|
||||||
|
path?: never;
|
||||||
|
cookie?: never;
|
||||||
|
};
|
||||||
|
get: operations["TbankSyncController_status"];
|
||||||
|
put?: never;
|
||||||
|
post?: never;
|
||||||
|
delete?: never;
|
||||||
|
options?: never;
|
||||||
|
head?: never;
|
||||||
|
patch?: never;
|
||||||
|
trace?: never;
|
||||||
|
};
|
||||||
}
|
}
|
||||||
export type webhooks = Record<string, never>;
|
export type webhooks = Record<string, never>;
|
||||||
export interface components {
|
export interface components {
|
||||||
@@ -899,24 +899,35 @@ export interface components {
|
|||||||
/** @enum {string} */
|
/** @enum {string} */
|
||||||
historyState: "missing" | "loading" | "partial" | "complete" | "failed";
|
historyState: "missing" | "loading" | "partial" | "complete" | "failed";
|
||||||
};
|
};
|
||||||
InvestmentSyncDto: {
|
InvestmentAttemptProblemDto: {
|
||||||
id: string | null;
|
|
||||||
/** @enum {string} */
|
/** @enum {string} */
|
||||||
state: "idle" | "running" | "failed";
|
section: "membership" | "portfolio" | "operations" | "events";
|
||||||
|
accountId: string | null;
|
||||||
errorCode: string | null;
|
errorCode: string | null;
|
||||||
};
|
};
|
||||||
|
InvestmentAttemptDto: {
|
||||||
|
/** @enum {string} */
|
||||||
|
state: "none" | "running" | "succeeded" | "partial" | "failed";
|
||||||
|
/** Format: date-time */
|
||||||
|
startedAt: string | null;
|
||||||
|
/** Format: date-time */
|
||||||
|
finishedAt: string | null;
|
||||||
|
problems: components["schemas"]["InvestmentAttemptProblemDto"][];
|
||||||
|
};
|
||||||
InvestmentDependencyDto: {
|
InvestmentDependencyDto: {
|
||||||
dataRevision: string;
|
dataRevision: string;
|
||||||
unavailableReason?: string;
|
unavailableReason?: string;
|
||||||
coverage?: components["schemas"]["InvestmentCoverageDto"];
|
coverage?: components["schemas"]["InvestmentCoverageDto"];
|
||||||
resourceKey: string;
|
resourceKey: string;
|
||||||
/** @enum {string} */
|
/** @enum {string} */
|
||||||
availability: "missing" | "partial" | "complete";
|
availability: "available" | "initial-loading" | "temporarily-unavailable" | "connection-unavailable";
|
||||||
|
/** @enum {string} */
|
||||||
|
completeness: "complete" | "incomplete";
|
||||||
/** @enum {string} */
|
/** @enum {string} */
|
||||||
freshness: "unknown" | "fresh" | "stale";
|
freshness: "unknown" | "fresh" | "stale";
|
||||||
/** Format: date-time */
|
/** Format: date-time */
|
||||||
lastSuccessfulAt: string | null;
|
lastSuccessfulAt: string | null;
|
||||||
sync: components["schemas"]["InvestmentSyncDto"];
|
lastAttempt: components["schemas"]["InvestmentAttemptDto"];
|
||||||
};
|
};
|
||||||
InvestmentResourceMetaDto: {
|
InvestmentResourceMetaDto: {
|
||||||
dataRevision: string;
|
dataRevision: string;
|
||||||
@@ -924,22 +935,16 @@ export interface components {
|
|||||||
coverage?: components["schemas"]["InvestmentCoverageDto"];
|
coverage?: components["schemas"]["InvestmentCoverageDto"];
|
||||||
resourceKey: string;
|
resourceKey: string;
|
||||||
/** @enum {string} */
|
/** @enum {string} */
|
||||||
availability: "missing" | "partial" | "complete";
|
availability: "available" | "initial-loading" | "temporarily-unavailable" | "connection-unavailable";
|
||||||
|
/** @enum {string} */
|
||||||
|
completeness: "complete" | "incomplete";
|
||||||
/** @enum {string} */
|
/** @enum {string} */
|
||||||
freshness: "unknown" | "fresh" | "stale";
|
freshness: "unknown" | "fresh" | "stale";
|
||||||
/** Format: date-time */
|
/** Format: date-time */
|
||||||
lastSuccessfulAt: string | null;
|
lastSuccessfulAt: string | null;
|
||||||
sync: components["schemas"]["InvestmentSyncDto"];
|
lastAttempt: components["schemas"]["InvestmentAttemptDto"];
|
||||||
dependencies?: components["schemas"]["InvestmentDependencyDto"][];
|
dependencies?: components["schemas"]["InvestmentDependencyDto"][];
|
||||||
};
|
};
|
||||||
HourlySyncSectionDto: {
|
|
||||||
/** @enum {string} */
|
|
||||||
section: "membership" | "portfolio" | "operations" | "events";
|
|
||||||
/** @description Account identifier of the problematic section, when scoped. */
|
|
||||||
accountId?: string;
|
|
||||||
/** @description Safe error code of the failed section. No tokens or upstream payloads. */
|
|
||||||
errorCode: string | null;
|
|
||||||
};
|
|
||||||
HourlySyncStatusDto: {
|
HourlySyncStatusDto: {
|
||||||
/**
|
/**
|
||||||
* @description Last hourly walk state. Cancelled means an interrupted attempt; its start still delays the next term.
|
* @description Last hourly walk state. Cancelled means an interrupted attempt; its start still delays the next term.
|
||||||
@@ -950,7 +955,7 @@ export interface components {
|
|||||||
startedAt: string;
|
startedAt: string;
|
||||||
/** Format: date-time */
|
/** Format: date-time */
|
||||||
finishedAt: string | null;
|
finishedAt: string | null;
|
||||||
sections: components["schemas"]["HourlySyncSectionDto"][];
|
problems: components["schemas"]["InvestmentAttemptProblemDto"][];
|
||||||
};
|
};
|
||||||
BrokerageAccountsResourceDto: {
|
BrokerageAccountsResourceDto: {
|
||||||
data: components["schemas"]["BrokerageAccountDto"][] | null;
|
data: components["schemas"]["BrokerageAccountDto"][] | null;
|
||||||
@@ -1015,84 +1020,6 @@ export interface components {
|
|||||||
data: components["schemas"]["PortfolioDto"] | null;
|
data: components["schemas"]["PortfolioDto"] | null;
|
||||||
meta: components["schemas"]["InvestmentResourceMetaDto"];
|
meta: components["schemas"]["InvestmentResourceMetaDto"];
|
||||||
};
|
};
|
||||||
EventsInvestmentScreenDto: {
|
|
||||||
accountId: string;
|
|
||||||
/**
|
|
||||||
* @description discriminator enum property added by openapi-typescript
|
|
||||||
* @enum {string}
|
|
||||||
*/
|
|
||||||
screen: "events";
|
|
||||||
/**
|
|
||||||
* Format: date
|
|
||||||
* @description Inclusive UTC calendar start date (YYYY-MM-DD). May be supplied independently; defaults to today in UTC.
|
|
||||||
*/
|
|
||||||
from?: string;
|
|
||||||
/**
|
|
||||||
* Format: date
|
|
||||||
* @description Inclusive UTC calendar end date (YYYY-MM-DD). May be supplied independently; defaults to 30 days after from. Timestamp queries use the start of the following UTC day as the exclusive end.
|
|
||||||
*/
|
|
||||||
to?: string;
|
|
||||||
};
|
|
||||||
IncomeInvestmentScreenDto: {
|
|
||||||
accountId: string;
|
|
||||||
/**
|
|
||||||
* @description discriminator enum property added by openapi-typescript
|
|
||||||
* @enum {string}
|
|
||||||
*/
|
|
||||||
screen: "income";
|
|
||||||
/**
|
|
||||||
* Format: date
|
|
||||||
* @description Inclusive start calendar date in Europe/Moscow (YYYY-MM-DD). Supply both from and to, or neither for the current Moscow month.
|
|
||||||
*/
|
|
||||||
from?: string;
|
|
||||||
/**
|
|
||||||
* Format: date
|
|
||||||
* @description Inclusive end calendar date in Europe/Moscow (YYYY-MM-DD). Supply both from and to, or neither. Timestamp queries use the start of the following Moscow day as the exclusive end, capped at now.
|
|
||||||
*/
|
|
||||||
to?: string;
|
|
||||||
};
|
|
||||||
SyncCandleRangeDto: {
|
|
||||||
/** Format: date-time */
|
|
||||||
from: string;
|
|
||||||
/** Format: date-time */
|
|
||||||
to: string;
|
|
||||||
};
|
|
||||||
TimestampInvestmentScreenDto: {
|
|
||||||
accountId?: string;
|
|
||||||
/** Format: uuid */
|
|
||||||
instrumentUid?: string;
|
|
||||||
query?: string;
|
|
||||||
/** @enum {string} */
|
|
||||||
candlePeriod?: "month" | "halfYear" | "year" | "all";
|
|
||||||
candleRange?: components["schemas"]["SyncCandleRangeDto"];
|
|
||||||
categories?: ("trade" | "income" | "tax" | "fee" | "transfer" | "other")[];
|
|
||||||
limit?: number;
|
|
||||||
/**
|
|
||||||
* @description discriminator enum property added by openapi-typescript
|
|
||||||
* @enum {string}
|
|
||||||
*/
|
|
||||||
screen: "accounts" | "account" | "operations" | "stocks" | "bonds" | "stock" | "bond";
|
|
||||||
/**
|
|
||||||
* Format: date-time
|
|
||||||
* @description Start instant for operations.
|
|
||||||
*/
|
|
||||||
from?: string;
|
|
||||||
/**
|
|
||||||
* Format: date-time
|
|
||||||
* @description End instant for operations.
|
|
||||||
*/
|
|
||||||
to?: string;
|
|
||||||
};
|
|
||||||
TbankSyncStatusDto: {
|
|
||||||
/** Format: uuid */
|
|
||||||
id: string;
|
|
||||||
scope: (components["schemas"]["IncomeInvestmentScreenDto"] | components["schemas"]["EventsInvestmentScreenDto"] | components["schemas"]["TimestampInvestmentScreenDto"]) | null;
|
|
||||||
/** Format: date-time */
|
|
||||||
now: string;
|
|
||||||
/** @enum {string} */
|
|
||||||
state: "running" | "succeeded" | "failed" | "cancelled";
|
|
||||||
errorCode: string | null;
|
|
||||||
};
|
|
||||||
BrokerageOperationDto: {
|
BrokerageOperationDto: {
|
||||||
account?: components["schemas"]["AccountReferenceDto"];
|
account?: components["schemas"]["AccountReferenceDto"];
|
||||||
id: string;
|
id: string;
|
||||||
@@ -1125,33 +1052,6 @@ export interface components {
|
|||||||
data: components["schemas"]["BrokerageOperationsPageDto"] | null;
|
data: components["schemas"]["BrokerageOperationsPageDto"] | null;
|
||||||
meta: components["schemas"]["InvestmentResourceMetaDto"];
|
meta: components["schemas"]["InvestmentResourceMetaDto"];
|
||||||
};
|
};
|
||||||
UpcomingEventDto: {
|
|
||||||
account?: components["schemas"]["AccountReferenceDto"];
|
|
||||||
/** @enum {string} */
|
|
||||||
type: "coupon" | "dividend" | "maturity" | "offer";
|
|
||||||
/** Format: date */
|
|
||||||
date: string;
|
|
||||||
/** @enum {string} */
|
|
||||||
dateKind: "event" | "registry";
|
|
||||||
figi: string | null;
|
|
||||||
instrumentUid: string | null;
|
|
||||||
ticker: string;
|
|
||||||
displayName: string;
|
|
||||||
isin: string | null;
|
|
||||||
logoName: string | null;
|
|
||||||
projectedAmount: components["schemas"]["MoneyDto"] | null;
|
|
||||||
};
|
|
||||||
UpcomingEventsDto: {
|
|
||||||
accountId: string;
|
|
||||||
/** Format: date-time */
|
|
||||||
calculatedAt: string;
|
|
||||||
events: components["schemas"]["UpcomingEventDto"][];
|
|
||||||
incomeTotalsByCurrency: components["schemas"]["MoneyDto"][];
|
|
||||||
};
|
|
||||||
UpcomingEventsResourceDto: {
|
|
||||||
data: components["schemas"]["UpcomingEventsDto"] | null;
|
|
||||||
meta: components["schemas"]["InvestmentResourceMetaDto"];
|
|
||||||
};
|
|
||||||
IncomePeriodDto: {
|
IncomePeriodDto: {
|
||||||
/** Format: date */
|
/** Format: date */
|
||||||
from: string;
|
from: string;
|
||||||
@@ -1242,12 +1142,14 @@ export interface components {
|
|||||||
coverage?: components["schemas"]["InvestmentCoverageDto"];
|
coverage?: components["schemas"]["InvestmentCoverageDto"];
|
||||||
resourceKey: string;
|
resourceKey: string;
|
||||||
/** @enum {string} */
|
/** @enum {string} */
|
||||||
availability: "missing" | "partial" | "complete";
|
availability: "available" | "initial-loading" | "temporarily-unavailable" | "connection-unavailable";
|
||||||
|
/** @enum {string} */
|
||||||
|
completeness: "complete" | "incomplete";
|
||||||
/** @enum {string} */
|
/** @enum {string} */
|
||||||
freshness: "unknown" | "fresh" | "stale";
|
freshness: "unknown" | "fresh" | "stale";
|
||||||
/** Format: date-time */
|
/** Format: date-time */
|
||||||
lastSuccessfulAt: string | null;
|
lastSuccessfulAt: string | null;
|
||||||
sync: components["schemas"]["InvestmentSyncDto"];
|
lastAttempt: components["schemas"]["InvestmentAttemptDto"];
|
||||||
/** @enum {string} */
|
/** @enum {string} */
|
||||||
role: "selected" | "previous" | "year";
|
role: "selected" | "previous" | "year";
|
||||||
};
|
};
|
||||||
@@ -1257,12 +1159,14 @@ export interface components {
|
|||||||
coverage?: components["schemas"]["InvestmentCoverageDto"];
|
coverage?: components["schemas"]["InvestmentCoverageDto"];
|
||||||
resourceKey: string;
|
resourceKey: string;
|
||||||
/** @enum {string} */
|
/** @enum {string} */
|
||||||
availability: "missing" | "partial" | "complete";
|
availability: "available" | "initial-loading" | "temporarily-unavailable" | "connection-unavailable";
|
||||||
|
/** @enum {string} */
|
||||||
|
completeness: "complete" | "incomplete";
|
||||||
/** @enum {string} */
|
/** @enum {string} */
|
||||||
freshness: "unknown" | "fresh" | "stale";
|
freshness: "unknown" | "fresh" | "stale";
|
||||||
/** Format: date-time */
|
/** Format: date-time */
|
||||||
lastSuccessfulAt: string | null;
|
lastSuccessfulAt: string | null;
|
||||||
sync: components["schemas"]["InvestmentSyncDto"];
|
lastAttempt: components["schemas"]["InvestmentAttemptDto"];
|
||||||
/** @description Dependencies identified by role, not array order or resourceKey. A missing role is unavailable. */
|
/** @description Dependencies identified by role, not array order or resourceKey. A missing role is unavailable. */
|
||||||
dependencies: components["schemas"]["IncomeDependencyDto"][];
|
dependencies: components["schemas"]["IncomeDependencyDto"][];
|
||||||
};
|
};
|
||||||
@@ -1270,6 +1174,33 @@ export interface components {
|
|||||||
data: components["schemas"]["IncomeAnalyticsDto"] | null;
|
data: components["schemas"]["IncomeAnalyticsDto"] | null;
|
||||||
meta: components["schemas"]["IncomeAnalyticsMetaDto"];
|
meta: components["schemas"]["IncomeAnalyticsMetaDto"];
|
||||||
};
|
};
|
||||||
|
UpcomingEventDto: {
|
||||||
|
account?: components["schemas"]["AccountReferenceDto"];
|
||||||
|
/** @enum {string} */
|
||||||
|
type: "coupon" | "dividend" | "maturity" | "offer";
|
||||||
|
/** Format: date */
|
||||||
|
date: string;
|
||||||
|
/** @enum {string} */
|
||||||
|
dateKind: "event" | "registry";
|
||||||
|
figi: string | null;
|
||||||
|
instrumentUid: string | null;
|
||||||
|
ticker: string;
|
||||||
|
displayName: string;
|
||||||
|
isin: string | null;
|
||||||
|
logoName: string | null;
|
||||||
|
projectedAmount: components["schemas"]["MoneyDto"] | null;
|
||||||
|
};
|
||||||
|
UpcomingEventsDto: {
|
||||||
|
accountId: string;
|
||||||
|
/** Format: date-time */
|
||||||
|
calculatedAt: string;
|
||||||
|
events: components["schemas"]["UpcomingEventDto"][];
|
||||||
|
incomeTotalsByCurrency: components["schemas"]["MoneyDto"][];
|
||||||
|
};
|
||||||
|
UpcomingEventsResourceDto: {
|
||||||
|
data: components["schemas"]["UpcomingEventsDto"] | null;
|
||||||
|
meta: components["schemas"]["InvestmentResourceMetaDto"];
|
||||||
|
};
|
||||||
StockSearchResultDto: {
|
StockSearchResultDto: {
|
||||||
/** Format: uuid */
|
/** Format: uuid */
|
||||||
instrumentUid: string;
|
instrumentUid: string;
|
||||||
@@ -1630,6 +1561,84 @@ export interface components {
|
|||||||
PutTbankConnectionDto: {
|
PutTbankConnectionDto: {
|
||||||
token: string;
|
token: string;
|
||||||
};
|
};
|
||||||
|
EventsInvestmentScreenDto: {
|
||||||
|
accountId: string;
|
||||||
|
/**
|
||||||
|
* @description discriminator enum property added by openapi-typescript
|
||||||
|
* @enum {string}
|
||||||
|
*/
|
||||||
|
screen: "events";
|
||||||
|
/**
|
||||||
|
* Format: date
|
||||||
|
* @description Inclusive UTC calendar start date (YYYY-MM-DD). May be supplied independently; defaults to today in UTC.
|
||||||
|
*/
|
||||||
|
from?: string;
|
||||||
|
/**
|
||||||
|
* Format: date
|
||||||
|
* @description Inclusive UTC calendar end date (YYYY-MM-DD). May be supplied independently; defaults to 30 days after from. Timestamp queries use the start of the following UTC day as the exclusive end.
|
||||||
|
*/
|
||||||
|
to?: string;
|
||||||
|
};
|
||||||
|
IncomeInvestmentScreenDto: {
|
||||||
|
accountId: string;
|
||||||
|
/**
|
||||||
|
* @description discriminator enum property added by openapi-typescript
|
||||||
|
* @enum {string}
|
||||||
|
*/
|
||||||
|
screen: "income";
|
||||||
|
/**
|
||||||
|
* Format: date
|
||||||
|
* @description Inclusive start calendar date in Europe/Moscow (YYYY-MM-DD). Supply both from and to, or neither for the current Moscow month.
|
||||||
|
*/
|
||||||
|
from?: string;
|
||||||
|
/**
|
||||||
|
* Format: date
|
||||||
|
* @description Inclusive end calendar date in Europe/Moscow (YYYY-MM-DD). Supply both from and to, or neither. Timestamp queries use the start of the following Moscow day as the exclusive end, capped at now.
|
||||||
|
*/
|
||||||
|
to?: string;
|
||||||
|
};
|
||||||
|
SyncCandleRangeDto: {
|
||||||
|
/** Format: date-time */
|
||||||
|
from: string;
|
||||||
|
/** Format: date-time */
|
||||||
|
to: string;
|
||||||
|
};
|
||||||
|
TimestampInvestmentScreenDto: {
|
||||||
|
accountId?: string;
|
||||||
|
/** Format: uuid */
|
||||||
|
instrumentUid?: string;
|
||||||
|
query?: string;
|
||||||
|
/** @enum {string} */
|
||||||
|
candlePeriod?: "month" | "halfYear" | "year" | "all";
|
||||||
|
candleRange?: components["schemas"]["SyncCandleRangeDto"];
|
||||||
|
categories?: ("trade" | "income" | "tax" | "fee" | "transfer" | "other")[];
|
||||||
|
limit?: number;
|
||||||
|
/**
|
||||||
|
* @description discriminator enum property added by openapi-typescript
|
||||||
|
* @enum {string}
|
||||||
|
*/
|
||||||
|
screen: "accounts" | "account" | "operations" | "stocks" | "bonds" | "stock" | "bond";
|
||||||
|
/**
|
||||||
|
* Format: date-time
|
||||||
|
* @description Start instant for operations.
|
||||||
|
*/
|
||||||
|
from?: string;
|
||||||
|
/**
|
||||||
|
* Format: date-time
|
||||||
|
* @description End instant for operations.
|
||||||
|
*/
|
||||||
|
to?: string;
|
||||||
|
};
|
||||||
|
TbankSyncStatusDto: {
|
||||||
|
/** Format: uuid */
|
||||||
|
id: string;
|
||||||
|
scope: (components["schemas"]["IncomeInvestmentScreenDto"] | components["schemas"]["EventsInvestmentScreenDto"] | components["schemas"]["TimestampInvestmentScreenDto"]) | null;
|
||||||
|
/** Format: date-time */
|
||||||
|
now: string;
|
||||||
|
/** @enum {string} */
|
||||||
|
state: "running" | "succeeded" | "failed" | "cancelled";
|
||||||
|
errorCode: string | null;
|
||||||
|
};
|
||||||
};
|
};
|
||||||
responses: never;
|
responses: never;
|
||||||
parameters: never;
|
parameters: never;
|
||||||
@@ -3369,72 +3378,6 @@ export interface operations {
|
|||||||
};
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
TbankSyncController_status: {
|
|
||||||
parameters: {
|
|
||||||
query?: never;
|
|
||||||
header?: never;
|
|
||||||
path: {
|
|
||||||
id: string;
|
|
||||||
};
|
|
||||||
cookie?: never;
|
|
||||||
};
|
|
||||||
requestBody?: never;
|
|
||||||
responses: {
|
|
||||||
200: {
|
|
||||||
headers: {
|
|
||||||
[name: string]: unknown;
|
|
||||||
};
|
|
||||||
content: {
|
|
||||||
"application/json": components["schemas"]["TbankSyncStatusDto"];
|
|
||||||
};
|
|
||||||
};
|
|
||||||
/** @description Invalid request */
|
|
||||||
400: {
|
|
||||||
headers: {
|
|
||||||
[name: string]: unknown;
|
|
||||||
};
|
|
||||||
content: {
|
|
||||||
"application/problem+json": components["schemas"]["ProblemDetailsDto"];
|
|
||||||
};
|
|
||||||
};
|
|
||||||
/** @description Authentication required */
|
|
||||||
401: {
|
|
||||||
headers: {
|
|
||||||
[name: string]: unknown;
|
|
||||||
};
|
|
||||||
content: {
|
|
||||||
"application/problem+json": components["schemas"]["ProblemDetailsDto"];
|
|
||||||
};
|
|
||||||
};
|
|
||||||
/** @description Resource not found */
|
|
||||||
404: {
|
|
||||||
headers: {
|
|
||||||
[name: string]: unknown;
|
|
||||||
};
|
|
||||||
content: {
|
|
||||||
"application/problem+json": components["schemas"]["ProblemDetailsDto"];
|
|
||||||
};
|
|
||||||
};
|
|
||||||
/** @description Internal server error */
|
|
||||||
500: {
|
|
||||||
headers: {
|
|
||||||
[name: string]: unknown;
|
|
||||||
};
|
|
||||||
content: {
|
|
||||||
"application/problem+json": components["schemas"]["ProblemDetailsDto"];
|
|
||||||
};
|
|
||||||
};
|
|
||||||
/** @description Upstream service unavailable */
|
|
||||||
503: {
|
|
||||||
headers: {
|
|
||||||
[name: string]: unknown;
|
|
||||||
};
|
|
||||||
content: {
|
|
||||||
"application/problem+json": components["schemas"]["ProblemDetailsDto"];
|
|
||||||
};
|
|
||||||
};
|
|
||||||
};
|
|
||||||
};
|
|
||||||
BrokerageOperationsController_all: {
|
BrokerageOperationsController_all: {
|
||||||
parameters: {
|
parameters: {
|
||||||
query?: {
|
query?: {
|
||||||
@@ -3581,148 +3524,6 @@ export interface operations {
|
|||||||
};
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
UpcomingEventsController_all: {
|
|
||||||
parameters: {
|
|
||||||
query?: {
|
|
||||||
sync?: "observe";
|
|
||||||
/** @description Inclusive UTC calendar start date (YYYY-MM-DD). May be supplied independently; defaults to today in UTC. */
|
|
||||||
from?: string;
|
|
||||||
/** @description Inclusive UTC calendar end date (YYYY-MM-DD). May be supplied independently; defaults to 30 days after from. Timestamp queries use the start of the following UTC day as the exclusive end. */
|
|
||||||
to?: string;
|
|
||||||
};
|
|
||||||
header?: never;
|
|
||||||
path?: never;
|
|
||||||
cookie?: never;
|
|
||||||
};
|
|
||||||
requestBody?: never;
|
|
||||||
responses: {
|
|
||||||
200: {
|
|
||||||
headers: {
|
|
||||||
[name: string]: unknown;
|
|
||||||
};
|
|
||||||
content: {
|
|
||||||
"application/json": components["schemas"]["UpcomingEventsResourceDto"];
|
|
||||||
};
|
|
||||||
};
|
|
||||||
/** @description Invalid request */
|
|
||||||
400: {
|
|
||||||
headers: {
|
|
||||||
[name: string]: unknown;
|
|
||||||
};
|
|
||||||
content: {
|
|
||||||
"application/problem+json": components["schemas"]["ProblemDetailsDto"];
|
|
||||||
};
|
|
||||||
};
|
|
||||||
/** @description Authentication required */
|
|
||||||
401: {
|
|
||||||
headers: {
|
|
||||||
[name: string]: unknown;
|
|
||||||
};
|
|
||||||
content: {
|
|
||||||
"application/problem+json": components["schemas"]["ProblemDetailsDto"];
|
|
||||||
};
|
|
||||||
};
|
|
||||||
/** @description Resource not found */
|
|
||||||
404: {
|
|
||||||
headers: {
|
|
||||||
[name: string]: unknown;
|
|
||||||
};
|
|
||||||
content: {
|
|
||||||
"application/problem+json": components["schemas"]["ProblemDetailsDto"];
|
|
||||||
};
|
|
||||||
};
|
|
||||||
/** @description Internal server error */
|
|
||||||
500: {
|
|
||||||
headers: {
|
|
||||||
[name: string]: unknown;
|
|
||||||
};
|
|
||||||
content: {
|
|
||||||
"application/problem+json": components["schemas"]["ProblemDetailsDto"];
|
|
||||||
};
|
|
||||||
};
|
|
||||||
/** @description Upstream service unavailable */
|
|
||||||
503: {
|
|
||||||
headers: {
|
|
||||||
[name: string]: unknown;
|
|
||||||
};
|
|
||||||
content: {
|
|
||||||
"application/problem+json": components["schemas"]["ProblemDetailsDto"];
|
|
||||||
};
|
|
||||||
};
|
|
||||||
};
|
|
||||||
};
|
|
||||||
UpcomingEventsController_get: {
|
|
||||||
parameters: {
|
|
||||||
query?: {
|
|
||||||
sync?: "observe";
|
|
||||||
/** @description Inclusive UTC calendar start date (YYYY-MM-DD). May be supplied independently; defaults to today in UTC. */
|
|
||||||
from?: string;
|
|
||||||
/** @description Inclusive UTC calendar end date (YYYY-MM-DD). May be supplied independently; defaults to 30 days after from. Timestamp queries use the start of the following UTC day as the exclusive end. */
|
|
||||||
to?: string;
|
|
||||||
};
|
|
||||||
header?: never;
|
|
||||||
path: {
|
|
||||||
accountId: string;
|
|
||||||
};
|
|
||||||
cookie?: never;
|
|
||||||
};
|
|
||||||
requestBody?: never;
|
|
||||||
responses: {
|
|
||||||
200: {
|
|
||||||
headers: {
|
|
||||||
[name: string]: unknown;
|
|
||||||
};
|
|
||||||
content: {
|
|
||||||
"application/json": components["schemas"]["UpcomingEventsResourceDto"];
|
|
||||||
};
|
|
||||||
};
|
|
||||||
/** @description Invalid request */
|
|
||||||
400: {
|
|
||||||
headers: {
|
|
||||||
[name: string]: unknown;
|
|
||||||
};
|
|
||||||
content: {
|
|
||||||
"application/problem+json": components["schemas"]["ProblemDetailsDto"];
|
|
||||||
};
|
|
||||||
};
|
|
||||||
/** @description Authentication required */
|
|
||||||
401: {
|
|
||||||
headers: {
|
|
||||||
[name: string]: unknown;
|
|
||||||
};
|
|
||||||
content: {
|
|
||||||
"application/problem+json": components["schemas"]["ProblemDetailsDto"];
|
|
||||||
};
|
|
||||||
};
|
|
||||||
/** @description Resource not found */
|
|
||||||
404: {
|
|
||||||
headers: {
|
|
||||||
[name: string]: unknown;
|
|
||||||
};
|
|
||||||
content: {
|
|
||||||
"application/problem+json": components["schemas"]["ProblemDetailsDto"];
|
|
||||||
};
|
|
||||||
};
|
|
||||||
/** @description Internal server error */
|
|
||||||
500: {
|
|
||||||
headers: {
|
|
||||||
[name: string]: unknown;
|
|
||||||
};
|
|
||||||
content: {
|
|
||||||
"application/problem+json": components["schemas"]["ProblemDetailsDto"];
|
|
||||||
};
|
|
||||||
};
|
|
||||||
/** @description Upstream service unavailable */
|
|
||||||
503: {
|
|
||||||
headers: {
|
|
||||||
[name: string]: unknown;
|
|
||||||
};
|
|
||||||
content: {
|
|
||||||
"application/problem+json": components["schemas"]["ProblemDetailsDto"];
|
|
||||||
};
|
|
||||||
};
|
|
||||||
};
|
|
||||||
};
|
|
||||||
IncomeAnalyticsController_allSummary: {
|
IncomeAnalyticsController_allSummary: {
|
||||||
parameters: {
|
parameters: {
|
||||||
query?: {
|
query?: {
|
||||||
@@ -3999,6 +3800,148 @@ export interface operations {
|
|||||||
};
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
UpcomingEventsController_all: {
|
||||||
|
parameters: {
|
||||||
|
query?: {
|
||||||
|
sync?: "observe";
|
||||||
|
/** @description Inclusive UTC calendar start date (YYYY-MM-DD). May be supplied independently; defaults to today in UTC. */
|
||||||
|
from?: string;
|
||||||
|
/** @description Inclusive UTC calendar end date (YYYY-MM-DD). May be supplied independently; defaults to 30 days after from. Timestamp queries use the start of the following UTC day as the exclusive end. */
|
||||||
|
to?: string;
|
||||||
|
};
|
||||||
|
header?: never;
|
||||||
|
path?: never;
|
||||||
|
cookie?: never;
|
||||||
|
};
|
||||||
|
requestBody?: never;
|
||||||
|
responses: {
|
||||||
|
200: {
|
||||||
|
headers: {
|
||||||
|
[name: string]: unknown;
|
||||||
|
};
|
||||||
|
content: {
|
||||||
|
"application/json": components["schemas"]["UpcomingEventsResourceDto"];
|
||||||
|
};
|
||||||
|
};
|
||||||
|
/** @description Invalid request */
|
||||||
|
400: {
|
||||||
|
headers: {
|
||||||
|
[name: string]: unknown;
|
||||||
|
};
|
||||||
|
content: {
|
||||||
|
"application/problem+json": components["schemas"]["ProblemDetailsDto"];
|
||||||
|
};
|
||||||
|
};
|
||||||
|
/** @description Authentication required */
|
||||||
|
401: {
|
||||||
|
headers: {
|
||||||
|
[name: string]: unknown;
|
||||||
|
};
|
||||||
|
content: {
|
||||||
|
"application/problem+json": components["schemas"]["ProblemDetailsDto"];
|
||||||
|
};
|
||||||
|
};
|
||||||
|
/** @description Resource not found */
|
||||||
|
404: {
|
||||||
|
headers: {
|
||||||
|
[name: string]: unknown;
|
||||||
|
};
|
||||||
|
content: {
|
||||||
|
"application/problem+json": components["schemas"]["ProblemDetailsDto"];
|
||||||
|
};
|
||||||
|
};
|
||||||
|
/** @description Internal server error */
|
||||||
|
500: {
|
||||||
|
headers: {
|
||||||
|
[name: string]: unknown;
|
||||||
|
};
|
||||||
|
content: {
|
||||||
|
"application/problem+json": components["schemas"]["ProblemDetailsDto"];
|
||||||
|
};
|
||||||
|
};
|
||||||
|
/** @description Upstream service unavailable */
|
||||||
|
503: {
|
||||||
|
headers: {
|
||||||
|
[name: string]: unknown;
|
||||||
|
};
|
||||||
|
content: {
|
||||||
|
"application/problem+json": components["schemas"]["ProblemDetailsDto"];
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
UpcomingEventsController_get: {
|
||||||
|
parameters: {
|
||||||
|
query?: {
|
||||||
|
sync?: "observe";
|
||||||
|
/** @description Inclusive UTC calendar start date (YYYY-MM-DD). May be supplied independently; defaults to today in UTC. */
|
||||||
|
from?: string;
|
||||||
|
/** @description Inclusive UTC calendar end date (YYYY-MM-DD). May be supplied independently; defaults to 30 days after from. Timestamp queries use the start of the following UTC day as the exclusive end. */
|
||||||
|
to?: string;
|
||||||
|
};
|
||||||
|
header?: never;
|
||||||
|
path: {
|
||||||
|
accountId: string;
|
||||||
|
};
|
||||||
|
cookie?: never;
|
||||||
|
};
|
||||||
|
requestBody?: never;
|
||||||
|
responses: {
|
||||||
|
200: {
|
||||||
|
headers: {
|
||||||
|
[name: string]: unknown;
|
||||||
|
};
|
||||||
|
content: {
|
||||||
|
"application/json": components["schemas"]["UpcomingEventsResourceDto"];
|
||||||
|
};
|
||||||
|
};
|
||||||
|
/** @description Invalid request */
|
||||||
|
400: {
|
||||||
|
headers: {
|
||||||
|
[name: string]: unknown;
|
||||||
|
};
|
||||||
|
content: {
|
||||||
|
"application/problem+json": components["schemas"]["ProblemDetailsDto"];
|
||||||
|
};
|
||||||
|
};
|
||||||
|
/** @description Authentication required */
|
||||||
|
401: {
|
||||||
|
headers: {
|
||||||
|
[name: string]: unknown;
|
||||||
|
};
|
||||||
|
content: {
|
||||||
|
"application/problem+json": components["schemas"]["ProblemDetailsDto"];
|
||||||
|
};
|
||||||
|
};
|
||||||
|
/** @description Resource not found */
|
||||||
|
404: {
|
||||||
|
headers: {
|
||||||
|
[name: string]: unknown;
|
||||||
|
};
|
||||||
|
content: {
|
||||||
|
"application/problem+json": components["schemas"]["ProblemDetailsDto"];
|
||||||
|
};
|
||||||
|
};
|
||||||
|
/** @description Internal server error */
|
||||||
|
500: {
|
||||||
|
headers: {
|
||||||
|
[name: string]: unknown;
|
||||||
|
};
|
||||||
|
content: {
|
||||||
|
"application/problem+json": components["schemas"]["ProblemDetailsDto"];
|
||||||
|
};
|
||||||
|
};
|
||||||
|
/** @description Upstream service unavailable */
|
||||||
|
503: {
|
||||||
|
headers: {
|
||||||
|
[name: string]: unknown;
|
||||||
|
};
|
||||||
|
content: {
|
||||||
|
"application/problem+json": components["schemas"]["ProblemDetailsDto"];
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
StockController_search: {
|
StockController_search: {
|
||||||
parameters: {
|
parameters: {
|
||||||
query: {
|
query: {
|
||||||
@@ -5277,4 +5220,70 @@ export interface operations {
|
|||||||
};
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
TbankSyncController_status: {
|
||||||
|
parameters: {
|
||||||
|
query?: never;
|
||||||
|
header?: never;
|
||||||
|
path: {
|
||||||
|
id: string;
|
||||||
|
};
|
||||||
|
cookie?: never;
|
||||||
|
};
|
||||||
|
requestBody?: never;
|
||||||
|
responses: {
|
||||||
|
200: {
|
||||||
|
headers: {
|
||||||
|
[name: string]: unknown;
|
||||||
|
};
|
||||||
|
content: {
|
||||||
|
"application/json": components["schemas"]["TbankSyncStatusDto"];
|
||||||
|
};
|
||||||
|
};
|
||||||
|
/** @description Invalid request */
|
||||||
|
400: {
|
||||||
|
headers: {
|
||||||
|
[name: string]: unknown;
|
||||||
|
};
|
||||||
|
content: {
|
||||||
|
"application/problem+json": components["schemas"]["ProblemDetailsDto"];
|
||||||
|
};
|
||||||
|
};
|
||||||
|
/** @description Authentication required */
|
||||||
|
401: {
|
||||||
|
headers: {
|
||||||
|
[name: string]: unknown;
|
||||||
|
};
|
||||||
|
content: {
|
||||||
|
"application/problem+json": components["schemas"]["ProblemDetailsDto"];
|
||||||
|
};
|
||||||
|
};
|
||||||
|
/** @description Resource not found */
|
||||||
|
404: {
|
||||||
|
headers: {
|
||||||
|
[name: string]: unknown;
|
||||||
|
};
|
||||||
|
content: {
|
||||||
|
"application/problem+json": components["schemas"]["ProblemDetailsDto"];
|
||||||
|
};
|
||||||
|
};
|
||||||
|
/** @description Internal server error */
|
||||||
|
500: {
|
||||||
|
headers: {
|
||||||
|
[name: string]: unknown;
|
||||||
|
};
|
||||||
|
content: {
|
||||||
|
"application/problem+json": components["schemas"]["ProblemDetailsDto"];
|
||||||
|
};
|
||||||
|
};
|
||||||
|
/** @description Upstream service unavailable */
|
||||||
|
503: {
|
||||||
|
headers: {
|
||||||
|
[name: string]: unknown;
|
||||||
|
};
|
||||||
|
content: {
|
||||||
|
"application/problem+json": components["schemas"]["ProblemDetailsDto"];
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -75,9 +75,10 @@ describe("persistent resource query lifecycle", () => {
|
|||||||
http.get("*/api/v1/brokerage-accounts/:accountId/portfolio", () =>
|
http.get("*/api/v1/brokerage-accounts/:accountId/portfolio", () =>
|
||||||
HttpResponse.json(
|
HttpResponse.json(
|
||||||
resource(null, {
|
resource(null, {
|
||||||
sync: {
|
lastAttempt: {
|
||||||
errorCode: "TBANK_UNAVAILABLE",
|
finishedAt: "2026-08-14T00:01:00Z",
|
||||||
id: "work",
|
problems: [],
|
||||||
|
startedAt: "2026-08-14T00:00:00Z",
|
||||||
state: "failed",
|
state: "failed",
|
||||||
},
|
},
|
||||||
}),
|
}),
|
||||||
@@ -89,14 +90,16 @@ describe("persistent resource query lifecycle", () => {
|
|||||||
wrapper: createQueryWrapper().wrapper,
|
wrapper: createQueryWrapper().wrapper,
|
||||||
});
|
});
|
||||||
|
|
||||||
await waitFor(() => expect(result.current.meta?.sync.state).toBe("failed"));
|
await waitFor(() =>
|
||||||
|
expect(result.current.meta?.lastAttempt.state).toBe("failed"),
|
||||||
|
);
|
||||||
expect(result.current.data).toBeUndefined();
|
expect(result.current.data).toBeUndefined();
|
||||||
expect(result.current.isSuccess).toBe(true);
|
expect(result.current.isSuccess).toBe(true);
|
||||||
expect(result.current.status).toBe("success");
|
expect(result.current.status).toBe("success");
|
||||||
expect(result.current.isPending).toBe(false);
|
expect(result.current.isPending).toBe(false);
|
||||||
expect(result.current.isLoading).toBe(false);
|
expect(result.current.isLoading).toBe(false);
|
||||||
|
|
||||||
expect(result.current.meta?.availability).toBe("missing");
|
expect(result.current.meta?.availability).toBe("initial-loading");
|
||||||
});
|
});
|
||||||
it("keeps the refetch envelope while exposing the refreshed resource payload", async () => {
|
it("keeps the refetch envelope while exposing the refreshed resource payload", async () => {
|
||||||
auth();
|
auth();
|
||||||
|
|||||||
@@ -145,7 +145,7 @@ function useResourceQuery<
|
|||||||
queryKey: options.queryKey,
|
queryKey: options.queryKey,
|
||||||
refetch: query.refetch,
|
refetch: query.refetch,
|
||||||
status: query.status,
|
status: query.status,
|
||||||
sync: query.data?.sync,
|
sync: query.data && "sync" in query.data ? query.data.sync : undefined,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+748
-702
File diff suppressed because it is too large
Load Diff
@@ -382,6 +382,13 @@ const ru = {
|
|||||||
yearUnavailable: "Сравнение с годом ранее недоступно.",
|
yearUnavailable: "Сравнение с годом ранее недоступно.",
|
||||||
},
|
},
|
||||||
investment: {
|
investment: {
|
||||||
|
attempt: {
|
||||||
|
cancelled: "Обновление отменено",
|
||||||
|
failed: "Обновление не удалось",
|
||||||
|
partial: "Обновлено частично",
|
||||||
|
running: "Обновление выполняется",
|
||||||
|
succeeded: "Обновлено",
|
||||||
|
},
|
||||||
history: "История догружается",
|
history: "История догружается",
|
||||||
partial: "Период загружен не полностью",
|
partial: "Период загружен не полностью",
|
||||||
refresh: "Обновить",
|
refresh: "Обновить",
|
||||||
|
|||||||
@@ -32,6 +32,21 @@ describe("SourceSyncStatus", () => {
|
|||||||
expect(screen.getByRole("status")).toHaveTextContent("Обновление не удалось");
|
expect(screen.getByRole("status")).toHaveTextContent("Обновление не удалось");
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it("announces an active or failed source attempt with text", () => {
|
||||||
|
renderStatus({
|
||||||
|
lastAttempt: {
|
||||||
|
finishedAt: null,
|
||||||
|
problems: [],
|
||||||
|
startedAt: "2026-02-03T10:15:00.000Z",
|
||||||
|
state: "running",
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
expect(screen.getByRole("status")).toHaveTextContent(
|
||||||
|
"Обновление выполняется",
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
it("keeps the notices next to the timestamp they belong to", () => {
|
it("keeps the notices next to the timestamp they belong to", () => {
|
||||||
renderStatus({
|
renderStatus({
|
||||||
errorText: "Обновление не удалось",
|
errorText: "Обновление не удалось",
|
||||||
|
|||||||
@@ -3,6 +3,8 @@ import type { FC } from "react";
|
|||||||
import { Text } from "@mantine/core";
|
import { Text } from "@mantine/core";
|
||||||
import { useTranslation } from "react-i18next";
|
import { useTranslation } from "react-i18next";
|
||||||
|
|
||||||
|
import type { InvestmentResourceMeta } from "@/shared/api";
|
||||||
|
|
||||||
import { formatSnapshotTime } from "@/shared/lib";
|
import { formatSnapshotTime } from "@/shared/lib";
|
||||||
|
|
||||||
// Owns the "when did the source last answer" line and the two notices that
|
// Owns the "when did the source last answer" line and the two notices that
|
||||||
@@ -10,6 +12,7 @@ import { formatSnapshotTime } from "@/shared/lib";
|
|||||||
// shows a muted line, a page header a progress bar — that is a product call.
|
// shows a muted line, a page header a progress bar — that is a product call.
|
||||||
type SourceSyncStatusProps = {
|
type SourceSyncStatusProps = {
|
||||||
errorText?: null | string;
|
errorText?: null | string;
|
||||||
|
lastAttempt?: InvestmentResourceMeta["lastAttempt"];
|
||||||
lastSuccessfulAt?: null | string;
|
lastSuccessfulAt?: null | string;
|
||||||
stale?: boolean;
|
stale?: boolean;
|
||||||
};
|
};
|
||||||
@@ -17,6 +20,12 @@ type SourceSyncStatusProps = {
|
|||||||
const SourceSyncStatus: FC<SourceSyncStatusProps> = (props) => {
|
const SourceSyncStatus: FC<SourceSyncStatusProps> = (props) => {
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
|
|
||||||
|
const attempt = props.lastAttempt;
|
||||||
|
|
||||||
|
const attemptText = attempt && attempt.state !== "none"
|
||||||
|
? t(`investment.attempt.${attempt.state}`)
|
||||||
|
: null;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
{!!props.lastSuccessfulAt && (
|
{!!props.lastSuccessfulAt && (
|
||||||
@@ -29,6 +38,12 @@ const SourceSyncStatus: FC<SourceSyncStatusProps> = (props) => {
|
|||||||
|
|
||||||
{!!props.stale && <Text size="xs">{t("investment.stale")}</Text>}
|
{!!props.stale && <Text size="xs">{t("investment.stale")}</Text>}
|
||||||
|
|
||||||
|
{!!attemptText && (
|
||||||
|
<Text role="status" size="xs">
|
||||||
|
{attemptText}
|
||||||
|
</Text>
|
||||||
|
)}
|
||||||
|
|
||||||
{!!props.errorText && <Text role="status">{props.errorText}</Text>}
|
{!!props.errorText && <Text role="status">{props.errorText}</Text>}
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -7,12 +7,18 @@ function resource<T>(data: T, meta: Partial<Meta> = {}) {
|
|||||||
return {
|
return {
|
||||||
data,
|
data,
|
||||||
meta: {
|
meta: {
|
||||||
availability: data === null ? "missing" : "complete",
|
availability: data === null ? "initial-loading" : "available",
|
||||||
|
completeness: "complete",
|
||||||
dataRevision: "1",
|
dataRevision: "1",
|
||||||
freshness: "fresh",
|
freshness: "fresh",
|
||||||
|
lastAttempt: {
|
||||||
|
finishedAt: null,
|
||||||
|
problems: [],
|
||||||
|
startedAt: null,
|
||||||
|
state: "none",
|
||||||
|
},
|
||||||
lastSuccessfulAt: "2026-08-14T00:00:00Z",
|
lastSuccessfulAt: "2026-08-14T00:00:00Z",
|
||||||
resourceKey: "fixture",
|
resourceKey: "fixture",
|
||||||
sync: { errorCode: null, id: null, state: "idle" },
|
|
||||||
...meta,
|
...meta,
|
||||||
} satisfies Meta,
|
} satisfies Meta,
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user