Skip to content

feat(events): add cursor-based API adapter (#1002) - #1055

Merged
greatest0fallt1me merged 2 commits into
Predictify-org:mainfrom
001somto:feat/1002-events-api-adapter
Nov 23, 2026
Merged

greatest0fallt1me merged 2 commits into
Predictify-org:mainfrom
001somto:feat/1002-events-api-adapter

Conversation

@001somto

Copy link
Copy Markdown
Contributor

Description

Adds an API-backed, filtered and cursor-paginated events adapter. Event fixtures are extracted from the store and retained for tests and explicitly enabled mock mode.

Type of Change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation update
  • Performance improvement
  • Refactoring (no functional changes)
  • Style/UI changes
  • Test updates
  • CI/CD changes
  • Security improvements

Related Issues

Closes #1002

Changes Made

Files Modified

  • lib/events-store.ts — load events through the adapter, start with empty state, support pagination and ignore stale responses.
  • lib/events-api.ts — add API fetching, Zod payload validation, error classification and adapter selection.
  • lib/events-mock.ts and lib/fixtures/events.ts — add the in-memory mock adapter and move event fixtures out of the store.
  • lib/env.ts and next.config.mjs — support and configure the NEXT_PUBLIC_USE_MOCKS build-time flag.
  • components/events/pagination.tsx — request additional adapter pages when needed.
  • README.md — document how to enable mock events in development.
  • lib/__tests__/events-store.test.ts, lib/__tests__/events-api.test.ts, and components/events/__tests__/virtualized-events-list.integration.test.tsx — cover adapter, store, pagination and error behavior.

Key Changes

  • API requests support status, category, search, cursor, limit and abort signal parameters.
  • API responses are validated and mapped to the Event type. HTTP permission errors, invalid responses and network errors are surfaced as distinct error kinds.
  • The mock adapter filters and paginates fixtures in memory. It is selected in tests or when NEXT_PUBLIC_USE_MOCKS=true; otherwise the API adapter is used.
  • Filter changes refresh results, and stale responses are ignored.
  • No dependencies were added.

Testing

  • Unit tests added/updated
  • Integration tests added/updated
  • Manual testing completed
  • Cross-browser testing (if applicable)
  • Mobile responsiveness tested (if applicable)
  • Accessibility testing completed
  • Performance testing (if applicable)

Test Coverage

  • New code is covered by tests
  • Existing tests still pass
  • Test coverage meets project standards

Related test commands:

  • corepack pnpm test -- lib/__tests__/events-store.test.ts lib/__tests__/events-api.test.ts — passed (22 tests).
  • corepack pnpm test -- components/events/__tests__/virtualized-events-list.integration.test.tsx — passed (14 tests).
  • corepack pnpm type-check — failed on existing unrelated issues in components/__tests__/error-boundary.test.tsx and lib/portfolio-analytics.ts / its tests.
  • corepack pnpm build — compilation succeeded, then failed on the existing FilteredClaimsEmptyState export type error in app/(dashboard)/claims/page.ts.

Code Quality

  • Code follows project style guidelines
  • Self-review completed
  • Code is self-documenting
  • No console errors or warnings
  • No linting errors
  • No TypeScript errors (if applicable)

Functionality

  • All tests pass
  • Feature works as expected in the related automated tests
  • No breaking changes introduced
  • Performance impact assessed

Documentation

  • README updated (if applicable)
  • Code comments added where necessary
  • API documentation updated (if applicable)
  • Changelog updated (if applicable)

Security & Accessibility

  • Security considerations addressed
  • Accessibility standards met
  • No sensitive data exposed
  • Input validation implemented

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@vercel

vercel Bot commented Nov 23, 2026

Copy link
Copy Markdown

@001somto is attempting to deploy a commit to the Jagadeesh B's projects Team on Vercel.

A member of the Team first needs to authorize it.

@drips-wave

drips-wave Bot commented Nov 23, 2026

Copy link
Copy Markdown

@001somto Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits.

You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀

Learn more about application limits

@greatest0fallt1me
greatest0fallt1me merged commit 6291967 into Predictify-org:main Nov 23, 2026
1 of 2 checks passed
@greatest0fallt1me

Copy link
Copy Markdown
Contributor

Thanks @001somto! We resolved the merge conflicts on our side and merged this. 🎉

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.

Extract events-store mock fixtures and add an API-backed adapter

2 participants