Skip to content

feat: add searchByMemo for local invoice arrays - #1026

Open
aigon-x wants to merge 1 commit into
Stellar-split:mainfrom
aigon-x:feat/614-search-by-memo
Open

aigon-x wants to merge 1 commit into
Stellar-split:mainfrom
aigon-x:feat/614-search-by-memo

Conversation

@aigon-x

@aigon-x aigon-x commented Oct 13, 2026

Copy link
Copy Markdown

Summary

Adds searchByMemo(invoices, query, opts?) to src/search.ts and exports it from src/index.ts — a substring search over Invoice.memo for an in-memory invoice array.

Payment memo text is a common way users tag invoices (e.g. "split:INV-001"), and src/search.ts could only search Horizon by status/recipient with no way to filter a local array by memo. This is a self-contained, synchronous helper that complements searchInvoices (which stays async/Horizon-backed).

Changes

  • src/search.ts — new searchByMemo() + SearchByMemoOptions interface.
  • src/index.ts — re-exports searchByMemo and SearchByMemoOptions.
  • test/searchByMemo.test.ts — unit tests covering every acceptance criterion.

Acceptance criteria

  • searchByMemo(invoices: Invoice[], query: string, opts?: { caseSensitive?: boolean }): Invoice[] exported from src/search.ts
  • Returns invoices whose invoice.memo contains query as a substring; case-insensitive by default
  • Empty query returns all invoices unchanged
  • Invoices with memo of undefined / null are skipped without error
  • opts.caseSensitive = true enables exact-case matching
  • Exported from src/index.ts
  • Unit tests: substring match, case-insensitive default, case-sensitive override, empty query returns all, null memo skipped

Implementation notes

  • The input array is never mutated (returns a new filtered array; the empty-query path returns the input as-is per the criterion).
  • The helper is pure/synchronous — no Horizon dependency in the hot path.

How I tested

npx vitest run test/searchByMemo.test.ts
# ✓ test/searchByMemo.test.ts (7 tests) — all pass

Negative check (mandatory): with the fix reverted, all 7 tests fail; with the fix restored, all 7 pass.

Regression: npm test (client / retryPolicy / network-environment) — 110 tests pass.

tsc --noEmit introduces no new errors from the three files in this PR (the repo has unrelated pre-existing type errors elsewhere).

Fixes #614

Adds searchByMemo(invoices, query, opts) to src/search.ts for substring
matching on Invoice.memo across an in-memory array, exported from src/index.ts.

- case-insensitive by default; caseSensitive: true for exact-case matching
- empty query returns all invoices unchanged
- invoices with undefined/null memo are skipped without error
- unit tests cover all acceptance criteria

Fixes Stellar-split#614

This branch has not been deployed

No deployments
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.

Add searchByMemo full-text search to search.ts

1 participant