/** * DBIS Core Banking client — STUB. * * The `d-bis/dbis_core` system is fully specified (707-line README describing * Global Ledger, Accounts, Payments, FX Engine, CBDC, Compliance, Settlement) * but it is not currently deployed at any resolvable hostname. `api.dbis-core.d-bis.org` * fails DNS. * * Every method here returns the existing sample data from `src/data/portalData.ts` * with a one-time console.warn so it's obvious the portal is not yet wired to * the real ledger. Flip `endpoints.dbisCore.mocked = false` (and implement the * fetch bodies below) when the core banking API is stood up. */ import type { Account, FinancialSummary, TreasuryPosition, CashForecast, SettlementRecord, ReportConfig } from '../types/portal'; import { sampleAccounts, financialSummary, treasuryPositions, cashForecasts, settlementRecords, reportConfigs } from '../data/portalData'; import { endpoints } from '../config/endpoints'; let warned = false; function warnMock(method: string): void { if (warned) return; warned = true; // eslint-disable-next-line no-console console.warn( `[dbisCore] Using sample data for ${method}() — dbis_core API is not deployed. ` + `Set VITE_DBIS_CORE_API_BASE_URL and flip endpoints.dbisCore.mocked once available.`, ); } function delay(value: T, ms = 150): Promise { return new Promise(resolve => setTimeout(() => resolve(value), ms)); } export async function listAccounts(): Promise { if (endpoints.dbisCore.mocked) { warnMock('listAccounts'); return delay(sampleAccounts); } // TODO: fetch(`${endpoints.dbisCore.apiBaseUrl}/v1/accounts`) throw new Error('dbis_core live mode not implemented'); } export async function getFinancialSummary(): Promise { if (endpoints.dbisCore.mocked) { warnMock('getFinancialSummary'); return delay(financialSummary); } throw new Error('dbis_core live mode not implemented'); } export async function listTreasuryPositions(): Promise { if (endpoints.dbisCore.mocked) { warnMock('listTreasuryPositions'); return delay(treasuryPositions); } throw new Error('dbis_core live mode not implemented'); } export async function listCashForecasts(): Promise { if (endpoints.dbisCore.mocked) { warnMock('listCashForecasts'); return delay(cashForecasts); } throw new Error('dbis_core live mode not implemented'); } export async function listSettlements(): Promise { if (endpoints.dbisCore.mocked) { warnMock('listSettlements'); return delay(settlementRecords); } throw new Error('dbis_core live mode not implemented'); } export async function listReports(): Promise { if (endpoints.dbisCore.mocked) { warnMock('listReports'); return delay(reportConfigs); } throw new Error('dbis_core live mode not implemented'); }