Skip to content
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

Upgrade node bindings #709

Merged
merged 7 commits into from
Nov 6, 2024
Merged

Upgrade node bindings #709

merged 7 commits into from
Nov 6, 2024

Conversation

rygine
Copy link
Collaborator

@rygine rygine commented Nov 6, 2024

Summary

  • Upgraded @xmtp/node-bindings
  • Refactored code with updated type exports
  • Fixed streaming issues when a stream error occurs

Summary by CodeRabbit

Release Notes

  • New Features

    • Enhanced flexibility in handling values within the AsyncStream class, now accommodating undefined values.
  • Improvements

    • Updated type names and structures across the SDK for better clarity and consistency, including changes in the Client, Conversation, and Conversations classes.
    • Improved error handling in streaming methods to prevent instantiation of objects with invalid data.
    • Upgraded the node bindings for better integration and performance.
  • Bug Fixes

    • Adjusted test cases to reflect new type names while maintaining existing functionality.

These updates improve overall robustness and maintainability of the SDK, ensuring a smoother user experience.

@rygine rygine requested a review from a team as a code owner November 6, 2024 22:44
Copy link

changeset-bot bot commented Nov 6, 2024

🦋 Changeset detected

Latest commit: 5a41542

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@xmtp/node-sdk Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

Copy link

coderabbitai bot commented Nov 6, 2024

Walkthrough

The pull request introduces several updates across multiple files in the @xmtp/node-sdk package. Key changes include a version bump of the @xmtp/node-bindings dependency and significant type renaming throughout the codebase, particularly in the Client, Conversation, and related classes. The modifications enhance type clarity and consistency, allowing for better handling of undefined values in the AsyncStream class and other components. Test files have been updated to reflect these type changes while maintaining their original logic.

Changes

File Change Summary
sdks/node-sdk/package.json Updated @xmtp/node-bindings dependency from ^0.0.16 to ^0.0.17.
sdks/node-sdk/src/AsyncStream.ts Updated StreamCallback type to allow undefined, modified internal queue and return method types.
sdks/node-sdk/src/Client.ts Renamed types (NapiClient to NodeClient, etc.), updated constructor and method signatures.
sdks/node-sdk/src/Conversation.ts Renamed types (NapiConsentState to ConsentState, etc.), updated constructor and method signatures.
sdks/node-sdk/src/Conversations.ts Renamed types (NapiConversations to NodeConversations, etc.), refined error handling in methods.
sdks/node-sdk/src/DecodedMessage.ts Updated imports and constructor to use new message types, adjusted switch statements accordingly.
sdks/node-sdk/test/Client.test.ts Updated type references in tests to new naming conventions for consent and signature request types.
sdks/node-sdk/test/Conversation.test.ts Updated import for ConsentState, enhanced message streaming test functionality.
sdks/node-sdk/test/Conversations.test.ts Updated import statements for consent state and permissions options in tests.
sdks/node-sdk/test/helpers.ts Updated import for SignatureRequestType in the helper function.

Possibly related PRs

  • Update Node SDK #694: Enhances message handling by allowing undefined as a valid content type, aligning with updates in the AsyncStream class.
  • Refactor AsyncStream #704: Refactors the AsyncStream class, related to changes in the main PR regarding the handling of values and errors.

Suggested reviewers

  • fabriguespe
  • nplasterer

Poem

🐰 In the garden of code, we hop with glee,
New types and changes, as bright as can be.
With undefined welcomed, our streams flow free,
A leap into clarity, come join the spree!
Let's celebrate updates, both big and small,
For in this code burrow, there's joy for us all! 🌼


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between 03ee42e and 5a41542.

📒 Files selected for processing (1)
  • .changeset/metal-boxes-marry.md (1 hunks)
✅ Files skipped from review due to trivial changes (1)
  • .changeset/metal-boxes-marry.md

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

cloudflare-workers-and-pages bot commented Nov 6, 2024

Deploying xmtp-js-docs with  Cloudflare Pages  Cloudflare Pages

Latest commit: 5a41542
Status: ✅  Deploy successful!
Preview URL: https://5cbdd962.xmtp-js.pages.dev
Branch Preview URL: https://rygine-node-sdk-updates.xmtp-js.pages.dev

View logs

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Outside diff range and nitpick comments (5)
sdks/node-sdk/src/AsyncStream.ts (1)

Line range hint 68-75: Consider adding error handling for stream termination.

While the type changes look good, consider adding error handling for cases where the stream is terminated abnormally. This could help with the streaming issues mentioned in the PR objectives.

  return = (value: T | undefined) => {
    this.#done = true;
+   // Clean up any pending operations
+   this.#queue = [];
+   this.#resolveNext = null;
    this.onReturn?.();
    return Promise.resolve({
      done: true,
      value,
    });
  };
sdks/node-sdk/src/Conversation.ts (4)

4-6: Consider renaming the Group type alias for clarity.

The alias Conversation as Group could be confusing since this file defines its own Conversation class. Consider using a more distinctive name like ConversationGroup or NativeConversation to avoid potential confusion.


116-121: LGTM: Improved stream error handling.

The changes enhance error handling by:

  • Using more conventional parameter names (error, value)
  • Explicitly handling undefined values
  • Properly propagating errors through both the AsyncStream and callback

Consider adding a JSDoc comment to document the possible undefined case for better developer experience.

+ /**
+  * Streams messages from the conversation.
+  * @param callback Optional callback that receives either a DecodedMessage or undefined
+  * when the stream value is null, along with any potential errors.
+  */
  stream(callback?: StreamCallback<DecodedMessage>) {

Line range hint 197-204: Document the message filtering behavior.

The method filters out messages with undefined content, which is an important implementation detail that should be documented. This behavior could affect consumers of the API.

+ /**
+  * Retrieves messages from the conversation.
+  * @param options Optional parameters for listing messages
+  * @returns An array of DecodedMessage, excluding any messages with undefined content
+  */
  messages(options?: ListMessagesOptions): DecodedMessage[] {

211-213: Add return type annotation for consistency.

The updateConsentState method should have an explicit return type annotation for consistency with other methods.

- updateConsentState(consentState: ConsentState) {
+ updateConsentState(consentState: ConsentState): void {
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between 8d6e5a6 and 03ee42e.

⛔ Files ignored due to path filters (1)
  • yarn.lock is excluded by !**/yarn.lock, !**/*.lock
📒 Files selected for processing (10)
  • sdks/node-sdk/package.json (1 hunks)
  • sdks/node-sdk/src/AsyncStream.ts (2 hunks)
  • sdks/node-sdk/src/Client.ts (7 hunks)
  • sdks/node-sdk/src/Conversation.ts (5 hunks)
  • sdks/node-sdk/src/Conversations.ts (12 hunks)
  • sdks/node-sdk/src/DecodedMessage.ts (3 hunks)
  • sdks/node-sdk/test/Client.test.ts (6 hunks)
  • sdks/node-sdk/test/Conversation.test.ts (4 hunks)
  • sdks/node-sdk/test/Conversations.test.ts (5 hunks)
  • sdks/node-sdk/test/helpers.ts (2 hunks)
🔇 Additional comments (32)
sdks/node-sdk/src/AsyncStream.ts (2)

16-16: LGTM! Queue type properly aligned with callback changes.

The queue type modification to (T | undefined)[] maintains type safety and correctly supports the new undefined value handling.


8-11: Verify handling of undefined values in consuming code.

The type change to allow undefined values in StreamCallback is a good improvement for flexibility. However, we should ensure all consumers properly handle the undefined case.

✅ Verification successful

Based on the search results, I can now generate the final response:

StreamCallback's undefined value handling is properly implemented

The codebase shows consistent and safe handling of undefined values in all StreamCallback implementations:

  • All stream methods use ternary operators with null checks: value ? new Something(value) : undefined
  • The AsyncStream base implementation has proper error and completion state handling
  • No direct property access on value without prior existence checks
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for StreamCallback usage to verify undefined handling
rg -l "StreamCallback" | xargs rg -A 5 "StreamCallback"

# Look for potential value access without undefined checks
ast-grep --pattern 'value.$$$' 

Length of output: 4946

sdks/node-sdk/src/DecodedMessage.ts (4)

3-5: LGTM! Clean import updates.

The updated imports align with the node-bindings upgrade, properly using type imports where appropriate.


28-28: Verify constructor usage after type change.

The constructor parameter type change from NapiMessage to Message looks good, but we should verify all instantiations of DecodedMessage have been updated.

#!/bin/bash
# Search for DecodedMessage instantiations to verify they use the updated type
rg -l "new DecodedMessage" | xargs rg -A 2 "new DecodedMessage"

46-56: Verify delivery status enum coverage.

The switch statement handles Unpublished, Published, and Failed statuses. Let's verify these cover all possible DeliveryStatus values.

✅ Verification successful

Switch statement correctly handles all delivery statuses

The verification confirms the switch statement is complete and correct:

  • The MessageDeliveryStatus type is explicitly defined as "unpublished" | "published" | "failed"
  • The switch statement handles all three possible values from DeliveryStatus enum
  • The same pattern is consistently used in both node-sdk and browser-sdk
  • The mapping aligns perfectly with the defined type
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for DeliveryStatus definition to verify all cases are covered
ast-grep --pattern 'enum DeliveryStatus {
  $$$
}'

Length of output: 52


Script:

#!/bin/bash
# Let's try searching for DeliveryStatus using ripgrep to find its definition
rg "enum.*DeliveryStatus" -A 5

Length of output: 32


Script:

#!/bin/bash
# Let's try a broader search for DeliveryStatus to find its definition and usage
rg "DeliveryStatus" -A 3 -B 3

Length of output: 5668


36-43: Verify message kind enum coverage.

The switch statement handles Application and MembershipChange kinds. Let's verify these cover all possible GroupMessageKind values.

sdks/node-sdk/package.json (2)

55-55: LGTM! Dependency update aligns with PR objectives.

The upgrade of @xmtp/node-bindings to version ^0.0.17 corresponds with the PR's focus on updating type exports and fixing streaming issues.


Line range hint 2-2: Verify version compatibility and consider version bump.

Since this PR introduces type changes and streaming fixes through the node-bindings upgrade, consider:

  1. Verifying that all type changes are backward compatible
  2. Potentially bumping the node-sdk version (currently 0.0.21) if the changes warrant it

Also applies to: 55-55

✅ Verification successful

Based on the gathered information, I can now provide the final response:

Version bump recommended for streaming changes and type refactoring

The changelog shows that version 0.0.21 already includes significant changes:

  • Refactored streams for better error handling
  • Added 1:1 messages and stream error handling
  • Added consent state methods and signature functionality
  • Added new client capabilities

These changes are already properly versioned and documented, and there's no evidence of breaking type changes that would require additional version bumps.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check for breaking changes in type usage across the codebase

# Test: Look for any TODO/FIXME comments related to types that might indicate compatibility issues
rg -i "TODO|FIXME|XXX" --type ts

# Test: Look for type-related changes in test files that might indicate breaking changes
rg -i "type|interface" --type test

Length of output: 1362


Script:

#!/bin/bash
# Let's gather more specific information about type changes and version impacts

# Check the current version in package.json
echo "Current version in package.json:"
grep '"version"' sdks/node-sdk/package.json

# Look for type definitions and interfaces in node-sdk
echo -e "\nType definitions in node-sdk:"
rg -g '*.ts' -g '*.d.ts' 'type|interface' sdks/node-sdk/

# Check for recent changes in type definitions
echo -e "\nRecent changes in type-related files:"
git log -p --since="1 month ago" sdks/node-sdk/ | grep -A 5 -B 5 'type|interface'

# Check for breaking changes markers in commit messages
echo -e "\nBreaking change indicators in recent commits:"
git log --since="1 month ago" --grep="BREAKING" sdks/node-sdk/

# Look for dependencies that might affect types
echo -e "\nDependencies that might affect types:"
grep -A 10 '"dependencies"' sdks/node-sdk/package.json

Length of output: 5800


Script:

#!/bin/bash
# Let's check for any changes in the node-bindings dependency and its impact

# Check the git history for changes related to node-bindings
echo "Recent changes related to node-bindings:"
git log -p --since="1 month ago" sdks/node-sdk/ | grep -B 5 -A 5 "@xmtp/node-bindings"

# Look for any changes in streaming-related types
echo -e "\nStreaming-related type changes:"
rg -g '*.ts' 'stream|Stream' sdks/node-sdk/

# Check test files for any streaming or type-related changes
echo -e "\nTest file changes for streaming and types:"
git log -p --since="1 month ago" sdks/node-sdk/test/ | grep -B 5 -A 5 'stream\|Stream\|type\|interface'

# Look for any migration guides or breaking change documentation
echo -e "\nChecking for migration or breaking change documentation:"
fd -e md . sdks/node-sdk/ -x grep -l "migration\|breaking\|upgrade"

Length of output: 30787


Script:

#!/bin/bash
# Let's check the changelog and recent commits for breaking changes

# Check CHANGELOG.md for recent version changes
echo "Recent changelog entries:"
head -n 20 sdks/node-sdk/CHANGELOG.md

# Check recent commits for node-bindings upgrade details
echo -e "\nRecent commits mentioning node-bindings upgrade:"
git log --grep="node-bindings" --since="1 month ago" -p sdks/node-sdk/

# Check for any type-related changes in the diff
echo -e "\nType-related changes in recent commits:"
git log -p --since="1 month ago" sdks/node-sdk/ | grep -A 5 -B 5 "type|interface|NapiType"

Length of output: 911

sdks/node-sdk/test/helpers.ts (2)

8-8: LGTM! Import statement updated for new type name.

The change from NapiSignatureRequestType to SignatureRequestType aligns with the node bindings upgrade and improves type naming clarity.


64-64: LGTM! Verify type usage consistency.

The usage of SignatureRequestType.CreateInbox is correctly updated. Let's verify that all other occurrences have been similarly updated.

✅ Verification successful

Type usage is consistent across the codebase

The verification shows that:

  • Node SDK consistently uses SignatureRequestType from @xmtp/node-bindings
  • Browser SDK consistently uses WasmSignatureRequestType from @xmtp/wasm-bindings
  • No occurrences of the old NapiSignatureRequestType were found
  • Each SDK maintains its own appropriate type variant throughout its codebase
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify that all occurrences of NapiSignatureRequestType have been replaced
# with SignatureRequestType across the codebase

echo "Checking for any remaining occurrences of NapiSignatureRequestType..."
rg "NapiSignatureRequestType"

echo "Verifying all current uses of SignatureRequestType..."
rg "SignatureRequestType" -A 2

Length of output: 6133

sdks/node-sdk/src/Conversation.ts (1)

15-15: LGTM: Type updates are consistent.

The changes to the private field and constructor parameter types align with the new type system while maintaining the same functionality.

Also applies to: 17-17

sdks/node-sdk/src/Conversations.ts (5)

2-4: LGTM! Type updates improve clarity

The renaming of types from Napi* prefix to more semantic names (CreateGroupOptions, ListConversationsOptions, NodeConversations) improves code clarity and maintainability.

Also applies to: 13-13


15-18: LGTM! Constructor signature updated correctly

The constructor signature has been properly updated to use the new NodeConversations type while maintaining the same initialization logic.


52-52: LGTM! Method signatures consistently updated

Method signatures have been properly updated to use the new type names while preserving the existing type constraints and method behaviors.

Also applies to: 68-68, 77-77, 86-86


101-104: LGTM! Improved stream error handling

The changes introduce robust error handling across all streaming methods by:

  • Safely handling undefined values in stream callbacks
  • Consistently applying the pattern across all streaming methods
  • Preventing potential null pointer exceptions during stream errors

This improvement aligns with the PR objective of fixing streaming issues.

Also applies to: 117-120, 133-136, 152-155, 171-177, 190-193


101-104: Verify consistent stream error handling across the codebase

Let's verify that similar stream error handling improvements have been applied to all streaming methods in the codebase.

✅ Verification successful

Based on the search results, I can now generate a final response:

Stream error handling is consistently implemented across the codebase

The error handling pattern is consistently implemented in all streaming methods:

  • Conversations.ts: stream((err, value) => {...})
  • Conversation.ts: stream((error, value) => {...})
  • Both implementations properly handle the error parameter and pass it through to callbacks
  • JS SDK uses a different streaming pattern (async iterators) which handles errors through Promise rejection
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for other streaming methods that might need similar error handling updates
ast-grep --pattern 'stream($$$) {
  $$$
  .stream((err, value) => {
    $$$
  });
  $$$
}'

Length of output: 92


Script:

#!/bin/bash
# Let's try a broader search for stream-related patterns
rg -A 5 "\.stream\(" --type ts

# Also search for method definitions containing 'stream'
ast-grep --pattern 'stream($$$) {
  $$$
}'

Length of output: 4395

sdks/node-sdk/src/Client.ts (6)

17-22: LGTM! Clean type imports.

The removal of the Napi prefix from types makes the code cleaner while maintaining functionality.


87-87: LGTM! Consistent type updates.

The NodeClient type updates in both the property and constructor are consistent with the node bindings upgrade.

Also applies to: 91-91


189-191: LGTM! Type signature updated correctly.

The SignatureRequestType parameter type update aligns with the node bindings upgrade.


224-224: LGTM! Message type and enum updates.

The Message type and GroupMessageKind enum updates maintain the same validation logic while aligning with the new type system.

Also applies to: 233-233


268-273: LGTM! Consent type updates.

The Consent and ConsentEntityType updates maintain the same functionality while aligning with the new type system.


242-244: Verify the method rename impact.

The method call has been renamed from requestHistorySync to sendHistorySyncRequest. While the change is straightforward, let's verify there are no other callers that need updating.

✅ Verification successful

Let me gather more context about the usage of both method names.


Let me check if there are any other files that might be using this client method.


Let me check for test files specifically with common test file extensions.


Method rename is self-contained and safe

The method rename from requestHistorySync to sendHistorySyncRequest is localized to the Client.ts file. The only occurrences found are:

  • The method definition itself
  • A configuration option property named requestHistorySync which is unrelated to the method rename
  • The internal call to the new method name sendHistorySyncRequest

No other usages were found in the codebase, including tests and examples, indicating this is a safe change.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for any remaining usage of the old method name
rg "requestHistorySync" --type ts

Length of output: 216


Script:

#!/bin/bash
# Get more context around the occurrences
rg "requestHistorySync|sendHistorySyncRequest" --type ts -A 3 -B 3

Length of output: 1297


Script:

#!/bin/bash
# Search for Client class usage and instantiation
rg "new Client\(" --type ts -A 3 -B 3

# Also search for any test files that might be using these methods
rg "requestHistorySync|sendHistorySyncRequest" --type test

Length of output: 904


Script:

#!/bin/bash
# Search in test files with common extensions
rg "requestHistorySync|sendHistorySyncRequest" -g "*.test.ts" -g "*.spec.ts" -g "*.test.js" -g "*.spec.js" -A 3 -B 3

# Also check if the method is used in any examples
fd -e ts -e js -p examples/ | xargs rg "requestHistorySync|sendHistorySyncRequest"

Length of output: 203

sdks/node-sdk/test/Client.test.ts (4)

2-4: LGTM! Clean type imports from node-bindings.

The removal of the "Napi" prefix from types indicates a cleaner API design in the upgraded package.


119-120: LGTM! Consistent usage of SignatureRequestType.

The type has been correctly updated across all signature-related operations while maintaining the original test functionality for wallet associations and installation management.

Also applies to: 150-151, 164-164, 198-198


223-224: LGTM! Comprehensive consent state management test.

The test thoroughly covers the consent state lifecycle with the updated types while maintaining complete test coverage of all state transitions (Unknown → Allowed → Denied).

Also applies to: 228-230, 235-236, 238-238, 240-240, 243-244


2-4: Verify consistent type usage across the codebase.

Let's ensure all usages of these types have been updated throughout the codebase:

✅ Verification successful

Type changes have been consistently updated across the codebase

The verification shows that:

  • No occurrences of old Napi-prefixed types were found
  • The new types are consistently used:
    • node-sdk uses ConsentEntityType, ConsentState, SignatureRequestType from @xmtp/node-bindings
    • browser-sdk uses WasmConsentEntityType, WasmConsentState, WasmSignatureRequestType from @xmtp/wasm-bindings
    • js-sdk uses its own string-based type definition for ConsentState
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for any remaining occurrences of the old type names
echo "Checking for any remaining Napi-prefixed types..."
rg "NapiConsentEntityType|NapiConsentState|NapiSignatureRequestType"

# Verify the new type usage is consistent
echo "Verifying new type usage..."
rg "ConsentEntityType|ConsentState|SignatureRequestType"

Length of output: 12435

sdks/node-sdk/test/Conversation.test.ts (2)

1-1: LGTM: Import change aligns with node-bindings upgrade

The change from NapiConsentState to ConsentState is consistent with the package upgrade objectives.


417-417: LGTM: Consent state checks properly updated

The consent state checks have been properly updated to use the new ConsentState enum from the upgraded node-bindings package. The tests correctly verify the state transitions from Unknown to Allowed.

Also applies to: 419-419, 424-424, 426-426

sdks/node-sdk/test/Conversations.test.ts (4)

1-1: LGTM! Clean type imports.

The removal of the "Napi" prefix from imported types aligns with the node bindings upgrade and improves type clarity.


33-33: LGTM! Consistent type usage in test assertions.

The test cases correctly use the updated type names while maintaining the same validation logic for permissions and consent states.

Also applies to: 87-87, 109-109


214-221: LGTM! Proper type usage in conversation options.

The conversation creation with admin-only permissions correctly uses the updated type name while maintaining the same permission validation logic.


Line range hint 266-447: Comprehensive streaming test coverage maintained.

The test suite thoroughly covers various streaming scenarios for both DM and group conversations. Since no changes were needed in the streaming test logic, please ensure that the streaming fixes mentioned in the PR objectives are implemented and tested in the relevant files.

✅ Verification successful

Streaming implementation and tests are properly aligned

The streaming functionality is well-implemented and thoroughly tested:

  • AsyncStream class provides robust async iteration support with proper error handling
  • Conversations class implements all streaming methods (stream, streamGroups, streamDms, streamAllMessages, etc.) consistently
  • The test coverage in the review matches the actual implementation, validating both success and error cases

The streaming test coverage is appropriate and no issues were found in the implementation.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Look for streaming-related changes in other files
# Test: Search for streaming-related code changes
rg -l "stream|Stream" --type ts

Length of output: 884


Script:

#!/bin/bash
# Let's check for recent changes in streaming-related files
git diff HEAD~10..HEAD -- sdks/node-sdk/src/AsyncStream.ts sdks/node-sdk/src/Conversations.ts sdks/node-sdk/src/Conversation.ts

# Also check the implementation of streaming methods
ast-grep --pattern 'stream($$$) {
  $$$
}'

Length of output: 210


Script:

#!/bin/bash
# Let's examine the streaming implementations in the node-sdk
cat sdks/node-sdk/src/AsyncStream.ts
cat sdks/node-sdk/src/Conversations.ts

# Also check the test file for any recent changes
cat sdks/node-sdk/test/AsyncStream.test.ts

Length of output: 9358

sdks/node-sdk/test/Conversation.test.ts Show resolved Hide resolved
@rygine rygine requested a review from a team as a code owner November 6, 2024 22:51
@rygine rygine merged commit 34b1e31 into main Nov 6, 2024
24 checks passed
@rygine rygine deleted the rygine/node-sdk-updates branch November 6, 2024 23:23
@coderabbitai coderabbitai bot mentioned this pull request Dec 2, 2024
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