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
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:
Vendored
+85
@@ -0,0 +1,85 @@
|
||||
// This process is deliberately killed by the SQLite suite at durable boundaries.
|
||||
require('../e2e-env.cjs');
|
||||
const { ConfigService } = require('@nestjs/config');
|
||||
const { PrismaService } = require('../../dist/src/prisma/prisma.service');
|
||||
const {
|
||||
TbankTokenService,
|
||||
} = require('../../dist/src/integrations/tbank/tbank-token.service');
|
||||
const {
|
||||
TbankAccessService,
|
||||
} = require('../../dist/src/integrations/tbank/tbank-access.service');
|
||||
const {
|
||||
BrokerageOperationsRepository,
|
||||
} = require('../../dist/src/modules/investments/operations/infrastructure/brokerage-operations.repository');
|
||||
const {
|
||||
BrokerageOperationsSyncService,
|
||||
} = require('../../dist/src/modules/investments/operations/application/brokerage-operations-sync.service');
|
||||
const mode = process.argv[2];
|
||||
const prisma = new PrismaService(new ConfigService(process.env));
|
||||
const repository = new BrokerageOperationsRepository(prisma);
|
||||
const tokens = new TbankTokenService(new ConfigService(process.env));
|
||||
const stopped = new Promise(() => {});
|
||||
let handle;
|
||||
let pages = 0;
|
||||
const checkpoint = () => process.send({ checkpoint: mode, handle });
|
||||
const upstream = {
|
||||
async getOperationsByCursor() {
|
||||
pages += 1;
|
||||
if (mode === 'between-pages' && pages === 2) {
|
||||
checkpoint();
|
||||
return stopped;
|
||||
}
|
||||
return {
|
||||
hasNext: mode === 'between-pages',
|
||||
nextCursor: mode === 'between-pages' ? 'discard-after-restart' : '',
|
||||
items: [
|
||||
{
|
||||
id: 'crash-row',
|
||||
date: { seconds: '1768000000' },
|
||||
payment: { units: '10', nano: 1, currency: 'rub' },
|
||||
},
|
||||
],
|
||||
};
|
||||
},
|
||||
};
|
||||
const publish = repository.publish.bind(repository);
|
||||
repository.publish = async (...args) => {
|
||||
if (mode === 'before-publish') {
|
||||
checkpoint();
|
||||
return stopped;
|
||||
}
|
||||
const result = await publish(...args);
|
||||
if (mode === 'after-publish') {
|
||||
checkpoint();
|
||||
return stopped;
|
||||
}
|
||||
return result;
|
||||
};
|
||||
const service = new BrokerageOperationsSyncService(
|
||||
repository,
|
||||
new TbankAccessService(prisma, tokens, upstream),
|
||||
upstream,
|
||||
{
|
||||
event() {
|
||||
process.send({ error: 'Unexpected worker persistence failure' });
|
||||
},
|
||||
},
|
||||
);
|
||||
process.on('message', () => {});
|
||||
(async () => {
|
||||
await prisma.$connect();
|
||||
handle = await service.request(
|
||||
'owner',
|
||||
[
|
||||
{
|
||||
accountId: 'account',
|
||||
from: new Date('2026-01-01Z'),
|
||||
to: new Date('2026-02-01Z'),
|
||||
},
|
||||
],
|
||||
true,
|
||||
);
|
||||
})().catch((error) => {
|
||||
process.send({ error: error.message });
|
||||
process.exitCode = 1;
|
||||
});
|
||||
Reference in New Issue
Block a user