Skip to content

fix: Use correct API parameter names for thread and inbox timestamp filtering#117

Open
pauloslund wants to merge 4 commits intomainfrom
pauloslund/fix-timestamp-params
Open

fix: Use correct API parameter names for thread and inbox timestamp filtering#117
pauloslund wants to merge 4 commits intomainfrom
pauloslund/fix-timestamp-params

Conversation

@pauloslund
Copy link
Copy Markdown
Contributor

Summary

  • Add newerThan and olderThan Date parameters to ThreadsClient.getThreads() and InboxClient.getInbox()/archiveAll(), properly converting them to Unix timestamps for the API
  • Map camelCase SDK params to the correct snake_case API query/body parameters (newer_than_ts, older_than_ts, since_ts_or_obj_idx, until_ts_or_obj_idx)
  • Deprecate the old since/until params on inbox client with backward-compatible ?? fallback
  • Add limit param support to getThreads
  • Add tests for both new and deprecated parameter paths, including a new inbox-client.test.ts file

Test plan

  • Verify newerThan/olderThan correctly map to API params in threads and inbox clients
  • Verify deprecated since/until still work via fallback
  • Run existing and new unit tests

…iltering

Add newerThan/olderThan Date params to threads and inbox clients, mapping
them to the correct snake_case API parameters. Deprecate the old since/until
params on inbox client with backward-compatible fallback. Add tests for both
new and deprecated parameter paths.
Copy link
Copy Markdown
Member

@doistbot doistbot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This PR updates the threads and inbox clients to properly support timestamp filtering by introducing newerThan and olderThan parameters and mapping them to the correct API formats. These updates effectively align the SDK with the API's expected parameters and improve the clarity of the public contract. A few minor adjustments are noted to preserve backward compatibility for existing snake_case inputs in the threads client and to ensure a limit value of zero is not silently ignored.

Share FeedbackReview Logs

const method = 'GET'
const url = `${ENDPOINT_THREADS}/get`
const params = args
const params: Record<string, unknown> = {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[P1] Rebuilding params from scratch here drops the previously documented newer_than_ts / older_than_ts inputs for getThreads(). Before this change, those snake_case keys were forwarded through request() and worked for JS consumers; after this refactor they are silently ignored, so existing calls can start returning unfiltered threads. Please add a deprecated fallback for the old keys, similar to the inbox/comments migrations, before removing that runtime path.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in 639ff5a. Switched back to the passthrough pattern — we now destructure only the timestamp fields and spread ...rest through. Added deprecated newerThanTs/olderThanTs number fields on GetThreadsArgs (which auto-convert to newer_than_ts/older_than_ts via snakeCaseKeys), with newerThan Date taking precedence when both are provided.

if (args.archived != null) params.archived = args.archived
if (args.newerThan) params.newer_than_ts = Math.floor(args.newerThan.getTime() / 1000)
if (args.olderThan) params.older_than_ts = Math.floor(args.olderThan.getTime() / 1000)
if (args.limit) params.limit = args.limit
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[P2] This truthy check means the new limit support silently ignores an explicit 0. GetThreadsArgsSchema now accepts any number, so callers can pass 0 and get a full result set instead of either limit=0 or a validation error. Using args.limit != null here, or tightening the schema to positive integers, would keep the implementation aligned with the public contract.

…werThanTs/olderThanTs

Instead of rebuilding params from scratch, use the spread/passthrough
pattern consistent with other methods. Add deprecated newerThanTs and
olderThanTs number fields so existing JS consumers passing the old
snake_case keys continue to work.
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.

3 participants