Skip to content

Update js sdk for argument consistency #73

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

theishangoswami
Copy link
Contributor

The JavaScript SDK was refactored to remove all usages of the spread operator (...) and replace them with explicit argument passing. This change aligns the SDK with the Python SDK's recent updates, improving forward compatibility and type safety by preventing accidental property passing from API responses to requests.

Key changes include:

  • Main API Methods (src/index.ts):
    • search(), searchAndContents(), findSimilar(), findSimilarAndContents(), and getContents() methods now explicitly assign each option property (e.g., numResults, includeDomains, text) to the payload object instead of using the spread operator.
    • The extractContentsOptions() helper function was refactored to manually extract content-specific properties and build restOptions using a loop and Set-based filtering, avoiding destructuring with spread.
  • Websets API Methods:
    • listAll() in src/websets/client.ts and src/websets/items.ts now explicitly assigns cursor and limit pagination options.
    • listAll() and listAllAttempts() in src/websets/webhooks.ts explicitly assign cursor, limit, and eventType pagination options.

This refactoring ensures the SDK remains robust when new fields are introduced in API responses and enhances type checking. The changes maintain the existing public API interface.

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.

2 participants