Skip to content

Typed events response#192

Open
gloskull wants to merge 4 commits into
Agentpay-Org:mainfrom
gloskull:typed-events-response
Open

Typed events response#192
gloskull wants to merge 4 commits into
Agentpay-Org:mainfrom
gloskull:typed-events-response

Conversation

@gloskull

Copy link
Copy Markdown

This PR tightens the AppEvent parsing types on the event log page.

Changes:

Documented the dual response shape ({ items } or { events }) in JSDoc for parseEventsResponse.
Replaced the as AppEvent["ts"] cast with a validated coercion that ensures ts is number | string | null. Unexpected types are coerced to null.
Improved handling of missing type field by coercing to an empty string.
Updated docs/api-integration.md with the documented response contract and updated AppEvent type.
Added comprehensive tests in src/app/events/page.test.tsx to verify:
Support for { events: [...] } shape.
Coercion of invalid ts values to null.
Error handling for non-array payloads.
Handling of missing type field.
Verified that npm run typecheck passes with the removed cast.
Verified that npm test src/app/events/page.test.tsx passes with 100% statement coverage for the page.
Closes #164

google-labs-jules Bot and others added 4 commits June 28, 2026 06:48
…nse shape

Tighten the AppEvent parsing types on the event log page.
- Add JSDoc to parseEventsResponse documenting the { items } or { events } response shapes.
- Validate ts against number | string | null union instead of casting; coerce unexpected types to null.
- Handle missing type field by coercing to empty string.
- Update docs/api-integration.md to reflect the response contract.
- Extend tests to cover the new validation and response shapes.

Co-authored-by: gloskull <189399494+gloskull@users.noreply.github.com>
…407952307921026351

Refactor events typed response and validate ts field
- Update `parseNonNegativeInt` in `src/lib/validateNumber.ts` to reject empty strings and `-0`.
- Refactor `UsagePage` in `src/app/usage/page.tsx` to separate field validation errors from general status errors, preventing duplicate `role="alert"` elements.
- Improve semantic structure and accessibility of `KeyValueGrid.tsx` by using `Fragment` and explicit `aria-label` for Testing Library compatibility.
- Fix `ConfirmDialog.test.tsx` to correctly target the dialog element for backdrop dismissal tests.
- All 52 test suites passing.

Co-authored-by: gloskull <189399494+gloskull@users.noreply.github.com>
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 a typed events response contract and remove unknown casts on the event log

1 participant