feat!: persist T-Bank data and synchronize reads
Backend security / security (push) Successful in 8s
Backend verify / verify (push) Failing after 10m45s
Conventional commits / commits (pull_request) Successful in 29s
Backend security / security (pull_request) Successful in 8s
Backend verify / verify (pull_request) Failing after 10m37s

Store account membership, portfolio, operations, forecasts and market sources in SQLite.
Coalesce scoped refreshes, fence connection revisions, preserve complete financial
snapshots and stabilize operation period state.

BREAKING CHANGE: investment reads return data/meta resource envelopes and locally
persisted snapshots; consumers must use the matching OpenAPI contract and explicit
synchronization endpoints.
This commit is contained in:
2026-09-26 21:29:15 +03:00
parent 0862d56c4e
commit d6e6c4ace5
116 changed files with 18321 additions and 5409 deletions
@@ -0,0 +1,73 @@
import {
candleGaps,
candleWindows,
confirmedCandleCoverage,
} from './candle-coverage';
const date = (value: string) => new Date(value);
describe('source-confirmed daily candle coverage', () => {
it('retains closed empty coverage while yesterday incomplete and open empty ranges require rereading after midnight', () => {
const range = { from: date('2026-09-20Z'), to: date('2026-09-26Z') };
const now = date('2026-09-25T23:59:50Z');
const coverage = confirmedCandleCoverage(
range,
[
{
time: '2026-09-24T00:00:00Z',
close: '1.000000001',
isComplete: false,
},
],
now,
);
expect(
coverage.map((row) => [
row.from.toISOString().slice(0, 10),
row.to.toISOString().slice(0, 10),
row.isComplete,
]),
).toEqual([
['2026-09-20', '2026-09-24', true],
['2026-09-24', '2026-09-25', false],
['2026-09-25', '2026-09-26', false],
]);
expect(candleGaps(range, coverage, date('2026-09-25T23:59:59Z'))).toEqual(
[],
);
expect(candleGaps(range, coverage, date('2026-09-26T00:00:01Z'))).toEqual([
{ from: date('2026-09-24Z'), to: range.to },
]);
expect(
candleGaps(
range,
confirmedCandleCoverage(range, [], date('2026-09-27Z')),
date('2030-01-01Z'),
),
).toEqual([]);
});
it('expires the mutable empty current day at exactly one minute', () => {
const range = { from: date('2026-09-25Z'), to: date('2026-09-26Z') };
const covered = confirmedCandleCoverage(
range,
[],
date('2026-09-25T08:00:00Z'),
);
expect(candleGaps(range, covered, date('2026-09-25T08:00:59Z'))).toEqual(
[],
);
expect(candleGaps(range, covered, date('2026-09-25T08:01:00Z'))).toEqual([
range,
]);
});
it('splits leap-year history into contiguous windows of at most 365 days', () => {
const range = { from: date('2020-01-01Z'), to: date('2026-09-25Z') };
const windows = candleWindows(range);
expect(windows[0].from).toEqual(range.from);
expect(windows.at(-1)?.to).toEqual(range.to);
windows.forEach((window, index) => {
expect(window.to.valueOf() - window.from.valueOf()).toBeLessThanOrEqual(
365 * 86400000,
);
if (index) expect(window.from).toEqual(windows[index - 1].to);
});
});
});