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

Update type declarations in ably.d.ts for LiveObjects #1967

Merged
merged 2 commits into from
Feb 13, 2025

Conversation

VeskeR
Copy link
Contributor

@VeskeR VeskeR commented Feb 12, 2025

This adds public write, batch and lifecycle events APIs type declarations. All liveobjects public API should be defined in ably.d.ts at this point.

Summary by CodeRabbit

  • New Features

    • Enhanced live data capabilities with additional event notifications for synchronization and lifecycle changes.
    • Introduced batching operations that group live updates, and refined real-time map and counter creation to return meaningful objects upon acknowledgment.
  • Documentation

    • Updated method descriptions for live counter operations to improve clarity for developers.

Copy link

coderabbitai bot commented Feb 12, 2025

Warning

Rate limit exceeded

@VeskeR has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 26 minutes and 3 seconds before requesting another review.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

📥 Commits

Reviewing files that changed from the base of the PR and between 2635a66 and f2dcf8a.

📒 Files selected for processing (3)
  • ably.d.ts (8 hunks)
  • src/plugins/liveobjects/livecounter.ts (1 hunks)
  • src/plugins/liveobjects/liveobjects.ts (2 hunks)

Walkthrough

This change introduces new types, interfaces, and namespaces to enhance the LiveObjects functionality in the Ably client library. New event callbacks and lifecycle event types are provided alongside methods for creating maps and counters, handling batch operations, and managing event listeners. Updates to documentation clarify the behavior of these methods, particularly regarding ACK messages and local object pooling. Additionally, minor comment adjustments improve clarity in the LiveCounter class.

Changes

File(s) Change Summary
ably.d.ts Added new types, interfaces, namespaces, and event callbacks for LiveObjects including LiveObjectsEventCallback, LiveObjectLifecycleEventCallback, and BatchCallback. Introduced new namespaces for event states, lifecycle events, and added methods in the LiveObjects interface for creating maps, counters, batching operations, and managing event listeners.
src/plugins/liveobjects/livecounter.ts, src/plugins/liveobjects/liveobjects.ts Updated documentation in the LiveCounter class (for decrement) for improved clarity. Modified the createMap and createCounter methods in the LiveObjects class to update the return behavior and documentation—emphasizing the use of ACK responses and the creation of meaningful local objects.

Sequence Diagram(s)

sequenceDiagram
    participant Client
    participant LiveObjects
    participant Server

    Client->>LiveObjects: createMap(entries) / createCounter(count)
    LiveObjects->>Server: Send creation request with provided data
    alt ACK Received
        Server-->>LiveObjects: ACK (confirmation)
        LiveObjects-->>Client: Return object from local pool
    else No ACK yet
        LiveObjects-->>Client: Return newly created local object using provided data
    end
Loading
sequenceDiagram
    participant Client
    participant LiveObjects
    participant Server

    Client->>LiveObjects: batch(callback)
    LiveObjects->>Client: Execute BatchCallback with BatchContext
    Client->>LiveObjects: Perform batched set/increment/decrement operations
    LiveObjects->>Server: Send batched operations message
    Server-->>LiveObjects: ACK for batched update
Loading

Possibly related PRs

Suggested reviewers

  • mschristensen
  • ttypic
  • lawrence-forooghian

Poem

I hopped through lines of code with glee,
Adding events and batches, oh so free.
New maps and counters now take flight,
In the garden of LiveObjects, all is bright.
My rabbit paws tap a happy beat—
CodeRabbit cheers the update neat!
🐇🌟


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 generate docstrings to generate docstrings for this PR. (Beta)
  • @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.

@VeskeR VeskeR requested review from zknill and kaschula February 12, 2025 08:25
@github-actions github-actions bot temporarily deployed to staging/pull/1967/bundle-report February 12, 2025 08:25 Inactive
@github-actions github-actions bot temporarily deployed to staging/pull/1967/features February 12, 2025 08:25 Inactive
@github-actions github-actions bot temporarily deployed to staging/pull/1967/typedoc February 12, 2025 08:25 Inactive
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

🧹 Nitpick comments (1)
src/plugins/liveobjects/liveobjects.ts (1)

287-287: TODO comments need to be addressed.

There are TODO comments indicating missing implementation for handling 'detached', 'failed', and 'suspended' channel states. These states should be properly handled to ensure robust error handling and state management.

Would you like me to help implement the missing channel state handlers or create an issue to track this task?

Also applies to: 291-291

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 2f5d208 and 2635a66.

📒 Files selected for processing (3)
  • ably.d.ts (8 hunks)
  • src/plugins/liveobjects/livecounter.ts (1 hunks)
  • src/plugins/liveobjects/liveobjects.ts (2 hunks)
✅ Files skipped from review due to trivial changes (1)
  • src/plugins/liveobjects/livecounter.ts
🧰 Additional context used
🪛 GitHub Actions: Test NPM package
ably.d.ts

[error] 2223-2223: Type 'BatchContextLiveMap' is not generic.

🪛 GitHub Actions: Lint
ably.d.ts

[error] 2223-2223: Type 'BatchContextLiveMap' is not generic.

⏰ Context from checks skipped due to timeout of 90000ms (6)
  • GitHub Check: test-browser (webkit)
  • GitHub Check: test-node (20.x)
  • GitHub Check: test-browser (firefox)
  • GitHub Check: test-node (18.x)
  • GitHub Check: test-node (16.x)
  • GitHub Check: test-browser (chromium)
🔇 Additional comments (15)
ably.d.ts (13)

1569-1587: Nice addition of callback types.

Everything looks good here. The doc is clear, and the approach is consistent with existing type definitions.


2054-2072: New LiveObjects events look good.

No issues spotted with the usage or naming for 'syncing' and 'synced'.


2073-2087: New LiveObject lifecycle events are consistent.

The 'deleted' state is well-defined to capture when an object is removed from the pool.


2119-2134: Method createMap is clearly documented.

No issues found. The type parameterization is correct, ensuring typed usage of the newly created LiveMap.


2135-2149: Method createCounter is straightforward.

No issues found. The doc block is clear on the initial count behavior.


2150-2171: batch method is well-defined.

Synchronous callback usage is clearly highlighted to avoid confusion about concurrency. Good job clarifying that it must not be async.


2205-2212: OnLiveObjectsEventResponse interface is fine.

No issues found. The usage of an off() method is consistent with other patterns in this file.


2220-2227: Documentation block for BatchContextLiveMap.

Minor note: The main declarations follow below. We'll watch for any type parameter consistency issues in the code body as well.

🧰 Tools
🪛 GitHub Actions: Test NPM package

[error] 2223-2223: Type 'BatchContextLiveMap' is not generic.

🪛 GitHub Actions: Lint

[error] 2223-2223: Type 'BatchContextLiveMap' is not generic.


2270-2293: BatchContextLiveCounter usage is consistent.

No issues found. The definition is straightforward, and no generics conflict arises here.


2317-2341: Setting/removing keys from LiveMap is well-documented.

No further concerns. The approach to applying operations when echoed back is clear.


2371-2390: Increment/Decrement methods are logically consistent.

No issues. The documentation is clear on how the final value is applied upon message echo.


2431-2452: Lifecycle event handling for LiveObject is consistent.

No issues or suggestions to add.


2475-2482: OnLiveObjectLifecycleEventResponse is properly structured.

No issues found. The approach is consistent with the rest of the file’s event handling.

src/plugins/liveobjects/liveobjects.ts (2)

104-107: LGTM! Documentation improvements enhance clarity.

The updated documentation now provides a clearer explanation of the method's behavior regarding ACK messages and object creation, which better aligns with the actual implementation.


136-139: LGTM! Documentation improvements enhance clarity.

The updated documentation now provides a clearer explanation of the method's behavior regarding ACK messages and object creation, which better aligns with the actual implementation.

ably.d.ts Outdated Show resolved Hide resolved
@VeskeR VeskeR force-pushed the liveobjects/update-types branch from 2635a66 to ba1c24a Compare February 12, 2025 08:56
@VeskeR VeskeR changed the base branch from integration/liveobjects to liveobjects/fix-tests February 12, 2025 08:56
@github-actions github-actions bot temporarily deployed to staging/pull/1967/bundle-report February 12, 2025 08:57 Inactive
@github-actions github-actions bot temporarily deployed to staging/pull/1967/features February 12, 2025 08:57 Inactive
@github-actions github-actions bot temporarily deployed to staging/pull/1967/typedoc February 12, 2025 08:57 Inactive
Base automatically changed from liveobjects/fix-tests to integration/liveobjects February 12, 2025 10:16
@VeskeR VeskeR merged commit 19ab536 into integration/liveobjects Feb 13, 2025
8 of 14 checks passed
@VeskeR VeskeR deleted the liveobjects/update-types branch February 13, 2025 00:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

3 participants