mirror of
https://github.com/Komediruzecki/token-circles.git
synced 2026-10-20 09:46:43 +02:00
Adds a remote MCP server at POST /mcp and a bearer-authed account API, so an agent can read the account, import statements and write back categorizations without a browser session. - 15 tools across read / write / import scopes; stateless streamable-HTTP JSON-RPC. Tokens are tc_pat_-prefixed and stored as a SHA-256 hash (migration 0027). - Auth is an allow-list, not a widening of authenticateRequest: a bearer token reaches /mcp and /api/v1/* and nothing else, with a regression test pinning 401 on the cookie-authed routes. - File bytes never travel through a tool argument. prepare_import returns a 15-minute HMAC-signed, purpose-bound capability URL and the bytes go over plain HTTP; export_snapshot does the same in reverse. - POST /api/v1/import runs the bank adapters before falling back to generic CSV, so the API accepts the files the Bank Imports tab accepts. The detection/parse core moved to shared/bankImport/ for this; its 42-name public surface is unchanged and 14 of the 20 moved files are byte-identical in logic. Verified against a real 94-row Erste statement locally: parsed by the erste adapter at 0.97 confidence, 100% date and amount parse rates, account created and linked, re-import deduped to 0. 624 worker tests / 73 files, 1680 frontend tests / 137 files, both typechecks and lint clean. Deploys to dev only; prod still requires a v* tag.
47 lines
1.7 KiB
TypeScript
47 lines
1.7 KiB
TypeScript
/**
|
|
* Bank statement import — portable core.
|
|
*
|
|
* Detection, parsing and transformation of a bank's raw CSV/XLS statement into
|
|
* the app's canonical import table. Pure TypeScript: no DOM, no localStorage, no
|
|
* filesystem — so both runtimes use it. The browser runs it to power the Bank
|
|
* Imports tab; the Worker runs it in `/api/v1/import` so an API caller uploading
|
|
* an ERSTE or Revolut export gets the same adapter treatment as the UI instead
|
|
* of falling back to generic-CSV header guessing.
|
|
*
|
|
* Browser-only persistence (remembered statements, user-edited rule sets) stays
|
|
* in `frontend/src/core/bankImport/` — it is storage, not parsing.
|
|
*/
|
|
export type {
|
|
BankId,
|
|
BankAdapter,
|
|
CanonicalTxn,
|
|
CanonicalType,
|
|
CategoryRule,
|
|
CategoryRuleSet,
|
|
TransferRuleSet,
|
|
StatementMeta,
|
|
ParsedStatement,
|
|
DetectInput,
|
|
TransformContext,
|
|
} from './types';
|
|
|
|
export { CANONICAL_HEADERS, txnsToTable, txnToRow } from './canonical';
|
|
export { listAdapters, getAdapter, detectBank } from './registry';
|
|
export type { DetectResult } from './registry';
|
|
export { processFiles, toDetectInput } from './process';
|
|
export type { BankFileInput, ProcessOptions, ProcessResult, FileResult } from './process';
|
|
export { resolveTargetAccount, statementSignature } from './accountResolver';
|
|
export type { AccountLike } from './accountResolver';
|
|
export {
|
|
DEFAULT_CATEGORY_RULES,
|
|
DEFAULT_CATEGORY_RULES_WORLDWIDE,
|
|
RULE_GROUPS,
|
|
DEFAULT_RULE_GROUP_ID,
|
|
rulesForGroup,
|
|
matchCategory,
|
|
categorize,
|
|
} from './categoryRules';
|
|
export type { RuleGroup } from './categoryRules';
|
|
export { DEFAULT_TRANSFER_RULES, isTransfer, resolveCounterpart } from './transferRules';
|
|
export type { XlsxModule, XlsxLoader, ParseDeps } from './xlsx';
|