3.1 KiB
3.1 KiB
Tasks: enterprise-api-plugin-banking
Change ID: enterprise-api-plugin-banking
Package: @suaveplan/api-plugin-banking
Target path: api/commerce/api-plugin-banking
Prerequisite packages on Verdaccio: @suaveplan/api, @suaveplan/api-shared, @suaveplan/api-plugin-auth, @suaveplan/api-plugin-database, @suaveplan/events, @suaveplan/idempotency, @suaveplan/audit-logging, @suaveplan/rate-limiter, @suaveplan/error
0. Pre-flight (non-negotiable)
- 0.1 Confirm clean working tree (
git statusreports nothing) and no in-flight worktrees with uncommitted work (git worktree listthengit statusin each) - 0.2 If any worktrees exist under
.claude/worktrees/, account for each one: still-active agent, work-pending-merge, or stale-and-prune. Stale worktrees MUST be removed (git worktree remove) before opening a new one — code that has been lost twice on main is the failure mode this guards against. - 0.3 Confirm the package set in
MANIFEST.mdmatchesfind packages -maxdepth 3 -name package.jsoncount. Drift here means a prior change archived without regenerating the manifest.
1. Scaffold
- Create
api/commerce/api-plugin-banking/;package.jsonv0.0.0; standard tooling.
2. Types, errors, events
- Types:
BankAdapterinterface,BankAccount,Balance,Transaction,TxQuery,PaymentRequest,PaymentInitResult,ConsentToken,BankingPluginConfig(Zod). - Errors: 6-code union, metadata, registration. Test + doc.
- Events:
BankingEventMap(banking:transaction:received, banking:payment:initiated, banking:consent:granted).
3. SurrealQL
surql/bank_account.surql,bank_transaction.surql,bank_consent.surql,bank_payment.surql.
4. BankAdapter port + BankingService
src/adapters/bank-adapter.port.ts—BankAdapterinterface (injectable for testing without mocks — pass a real stub implementation).BankingService:getAccounts,getBalance,listTransactions,initiatePayment,getConsentUrl,exchangeConsent,revokeConsent.- Cache account list + balance in SurrealDB; refresh on stale TTL.
.test.ts+.md.
5. Routes
GET /banking/accounts,GET /banking/accounts/:id/balance,GET /banking/accounts/:id/transactions—requireAuth.POST /banking/payments—requireAuth+ idempotency + rate-limit + audit + PSD2 SCA header check.POST /banking/consent,GET /banking/consent/callback— consent flow.- Route
.test.ts+.md.
6. Plugin factory + integration tests + publish
createBankingPlugin(adapter, config?):definePlugin,dependencies: ["database", "auth"],migrationsPath: "./surql".onTenantCreate/onTenantDelete: provision/teardown consent records.- Integration test with real
BankAdapterstub + real SurrealDB. bunx turbo lint typecheck test --filter=@suaveplan/api-plugin-banking— green; 100% coverage.bun scripts/publish.ts --package @suaveplan/api-plugin-banking.- Archive →
openspec/archive/2026-04-24-enterprise-api-plugin-banking/.