Skip to content

fix: MAU response shape handling (0.10.1) - #48

Merged
devinpearson merged 4 commits into
mainfrom
fix/mau-response-shapes
Aug 5, 2026
Merged

fix: MAU response shape handling (0.10.1)#48
devinpearson merged 4 commits into
mainfrom
fix/mau-response-shapes

Conversation

@devinpearson

@devinpearson devinpearson commented Aug 5, 2026

Copy link
Copy Markdown
Owner

Summary

  • Normalize live Mauritius API payloads (singleton lists, missing data wrapper, accounts.balance nesting) so mau accounts / balances / related commands render correctly
  • Bump CLI to 0.10.1 and investec-mau-api to ^0.1.1

Follow-up to #47 with fixes found during live MAU testing.

Test plan

  • npm run test:run passes
  • On a MAU-capable system: ipb mau accounts (no rows.map crash)
  • ipb mau accounts --json returns an array of account objects
  • ipb mau balances <id> --json returns flat balance fields (not { accounts: { balance: … } })
  • ipb mau transactions <id> --from … --to … works with live date range

Made with Cursor

Summary by CodeRabbit

  • Bug Fixes

    • Improved handling of account, balance, document, and transaction responses so more API response shapes display correctly.
    • Document listings now handle missing account numbers more safely.
    • Empty or non-list results are now treated consistently, reducing unexpected output.
  • Tests

    • Expanded coverage for response normalization across account, balance, document, and transaction flows.
  • Chores

    • Updated the app version and refreshed a dependency.

devinpearson and others added 4 commits August 5, 2026 14:14
Singleton account/transaction/document objects were treated as lists,
causing rows.map is not a function on mau accounts.

Co-authored-by: Cursor <cursoragent@cursor.com>
Live Mauritius payloads can put accounts/transactions at the top level
instead of under data; normalize both shapes.

Co-authored-by: Cursor <cursoragent@cursor.com>
Live balance responses nest the record under accounts.balance; expose
the inner balance object for table/JSON output.

Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
@coderabbitai

coderabbitai Bot commented Aug 5, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: ca5d6869-72da-49c9-afa7-9c6fde524a31

📥 Commits

Reviewing files that changed from the base of the PR and between 35ba392 and 367fdbc.

⛔ Files ignored due to path filters (1)
  • package-lock.json is excluded by !**/package-lock.json
📒 Files selected for processing (9)
  • package.json
  • src/cmds/mau/accounts.ts
  • src/cmds/mau/balances.ts
  • src/cmds/mau/documents.ts
  • src/cmds/mau/helpers.ts
  • src/cmds/mau/transactions.ts
  • src/utils/command-runners.ts
  • test/cmds/mau.test.ts
  • test/utils/mau-helpers.test.ts

📝 Walkthrough

Walkthrough

This change adds shared MAU response normalization helpers, updates MAU commands to use them for accounts, balances, transactions, and documents, tightens list handling for non-array items, adds test coverage for the new parsing paths, and bumps the package and investec-mau-api versions.

Changes

MAU response normalization

Layer / File(s) Summary
Shared MAU parsing helpers
src/cmds/mau/helpers.ts, test/utils/mau-helpers.test.ts
Added helpers to normalize arrays, extract account and named list payloads, and unwrap balance or record payloads from multiple MAU response shapes. Tests cover singleton objects, XML-style wrappers, nested fields, and wrapped balance records.
Command response handling
src/cmds/mau/accounts.ts, src/cmds/mau/balances.ts, src/cmds/mau/transactions.ts, src/cmds/mau/documents.ts
Accounts, balances, and transactions now use shared extraction helpers instead of direct result.data... access. Documents now support top-level or nested availableDocuments payloads, normalize document lists, and allow missing account numbers.
List handling and release update
src/utils/command-runners.ts, test/cmds/mau.test.ts, package.json
runListCommand now treats non-array items as empty results. A command test verifies singleton account normalization before list rendering. The package version and investec-mau-api dependency version are updated.

Estimated code review effort: 3 (Moderate) | ~25 minutes

Possibly related PRs

  • devinpearson/ipb#47: This PR updates the same MAU command area and extends the response handling added there.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/mau-response-shapes

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@devinpearson
devinpearson merged commit 5ce1d4f into main Aug 5, 2026
3 of 4 checks passed
@devinpearson
devinpearson deleted the fix/mau-response-shapes branch August 5, 2026 12:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant