-
Notifications
You must be signed in to change notification settings - Fork 63
Remove non-path-based API from LiveObjects #2108
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
base: PUB-2065/path-based-batch-api
Are you sure you want to change the base?
Remove non-path-based API from LiveObjects #2108
Conversation
|
Warning Rate limit exceeded@VeskeR has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 10 minutes and 49 seconds before requesting another review. ⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the 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. 📒 Files selected for processing (12)
WalkthroughThis PR performs a comprehensive type system and API refactoring for the Ably objects module, removing legacy lifecycle event types, introducing Subscription-based abstractions, generalizing LiveMap value typing to standardized Changes
Sequence Diagram(s)sequenceDiagram
participant Client
participant RealtimeObject
participant DefaultPathObject
participant LiveMap
participant Subscription
rect rgb(220, 240, 230)
Note over Client,Subscription: New object access pattern
Client->>RealtimeObject: get<T>()
RealtimeObject->>LiveMap: getRoot()
LiveMap-->>RealtimeObject: LiveMap instance
RealtimeObject->>DefaultPathObject: new DefaultPathObject(root)
DefaultPathObject-->>RealtimeObject: PathObject<LiveMap<T>>
RealtimeObject-->>Client: Promise<PathObject<LiveMap<T>>>
end
rect rgb(240, 220, 230)
Note over Client,Subscription: Legacy lifecycle removal
Note over Client,Subscription: on/off(LiveObjectLifecycleEvent) removed<br/>subscribe(listener) replaces lifecycle events
Client->>Subscription: subscribe(listener)
Subscription-->>Client: Subscription (with unsubscribe())
end
Estimated code review effort🎯 4 (Complex) | ⏱️ ~60 minutes
Possibly related PRs
Suggested reviewers
Poem
Pre-merge checks and finishing touches✅ Passed checks (3 passed)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this 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
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
Disabled knowledge base sources:
- Jira integration is disabled by default for public repositories
You can enable these sources in your CodeRabbit configuration.
📒 Files selected for processing (13)
ably.d.ts(7 hunks)objects.d.ts(1 hunks)src/plugins/objects/batchcontext.ts(1 hunks)src/plugins/objects/instance.ts(2 hunks)src/plugins/objects/livemap.ts(11 hunks)src/plugins/objects/livemapvaluetype.ts(2 hunks)src/plugins/objects/liveobject.ts(3 hunks)src/plugins/objects/objectmessage.ts(1 hunks)src/plugins/objects/objectspool.ts(1 hunks)src/plugins/objects/pathobject.ts(4 hunks)src/plugins/objects/pathobjectsubscriptionregister.ts(2 hunks)src/plugins/objects/realtimeobject.ts(1 hunks)test/common/modules/private_api_recorder.js(0 hunks)
💤 Files with no reviewable changes (1)
- test/common/modules/private_api_recorder.js
🧰 Additional context used
🧬 Code graph analysis (11)
src/plugins/objects/objectmessage.ts (1)
ably.d.ts (1)
Primitive(2373-2381)
src/plugins/objects/pathobject.ts (2)
ably.d.ts (3)
LiveMap(2415-2418)Subscription(1680-1689)Value(2438-2438)src/plugins/objects/livemap.ts (1)
LiveMap(48-983)
src/plugins/objects/pathobjectsubscriptionregister.ts (1)
ably.d.ts (1)
Subscription(1680-1689)
src/plugins/objects/batchcontext.ts (1)
src/plugins/objects/livemap.ts (1)
LiveMap(48-983)
src/plugins/objects/liveobject.ts (2)
ably.d.ts (2)
EventCallback(1653-1653)Subscription(1680-1689)src/plugins/objects/instance.ts (1)
InstanceEvent(22-25)
src/plugins/objects/objectspool.ts (3)
ably.d.ts (1)
LiveMap(2415-2418)objects.d.ts (1)
LiveMap(19-31)src/plugins/objects/livemap.ts (1)
LiveMap(48-983)
src/plugins/objects/realtimeobject.ts (1)
ably.d.ts (3)
Value(2438-2438)AblyDefaultObject(2487-3539)LiveMap(2415-2418)
src/plugins/objects/instance.ts (1)
ably.d.ts (4)
EventCallback(1653-1653)InstanceSubscriptionEvent(3688-3693)Subscription(1680-1689)LiveObject(2431-2431)
src/plugins/objects/livemapvaluetype.ts (2)
src/plugins/objects/livemap.ts (2)
LiveMap(48-983)ValueObjectData(24-27)ably.d.ts (2)
LiveMap(2415-2418)Primitive(2373-2381)
src/plugins/objects/livemap.ts (4)
ably.d.ts (6)
Primitive(2373-2381)Value(2438-2438)LiveMap(2415-2418)LiveObject(2431-2431)ObjectMessage(3754-3801)CompactedValue(2444-2469)src/plugins/objects/liveobject.ts (1)
LiveObjectUpdate(18-26)src/plugins/objects/realtimeobject.ts (1)
RealtimeObject(38-489)src/plugins/objects/objectmessage.ts (1)
ObjectMessage(358-462)
ably.d.ts (4)
objects.d.ts (1)
LiveMap(19-31)src/plugins/objects/livemap.ts (1)
LiveMap(48-983)src/plugins/objects/realtimeobject.ts (1)
ObjectsEventCallback(32-32)test/package/browser/template/src/index-objects.ts (1)
AblyObjectsTypes(27-29)
🪛 GitHub Actions: Test NPM package
objects.d.ts
[error] 14-14: Cannot redeclare exported variable 'LiveMap'.
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (6)
- GitHub Check: test-browser (firefox)
- GitHub Check: test-browser (webkit)
- GitHub Check: test-browser (chromium)
- GitHub Check: test-node (18.x)
- GitHub Check: test-node (20.x)
- GitHub Check: test-node (16.x)
🔇 Additional comments (11)
src/plugins/objects/batchcontext.ts (1)
84-84: LGTM! Correct alignment with function signature.The removal of the cast to
Primitiveis correct, asLiveMap.createMapSetMessageexpectsvalue: API.Value, which can be a primitive,LiveCounterValueType, orLiveMapValueType.src/plugins/objects/pathobjectsubscriptionregister.ts (1)
6-6: LGTM! Consistent with API refactoring.The change from
SubscribeResponsetoSubscriptionaligns with the PR-wide transition to Subscription-based abstractions. The implementation correctly returns an object with anunsubscribemethod matching theSubscriptioninterface.Also applies to: 63-63
src/plugins/objects/objectmessage.ts (1)
44-44: LGTM! Type standardization.The change from
PrimitiveObjectValuetoAPI.Primitivestandardizes primitive value typing across the codebase and aligns with the removal of thePrimitiveObjectValuealias.src/plugins/objects/livemapvaluetype.ts (1)
77-77: LGTM! Consistent type handling.Both changes correctly align with the removal of
PrimitiveObjectValueand the standardization onAPI.Primitive. Line 77 removes an unnecessary cast sinceLiveMap.validateKeyValueexpectsvalue: API.Value, and line 141 correctly types primitive values asAPI.PrimitiveforValueObjectData.Also applies to: 141-141
src/plugins/objects/objectspool.ts (1)
33-34: LGTM! API simplification.The removal of the generic type parameter simplifies the API and aligns with the broader refactoring to use non-generic
LiveMap. This change is consistent with the PathObject-based access pattern introduced in the PR.src/plugins/objects/pathobject.ts (1)
14-14: LGTM! Consistent API refactoring.All changes align with the PR objectives:
- Lines 14, 354: Migration from
SubscribeResponsetoSubscriptionaligns with the new subscription-based abstractions.- Line 34: Removing the generic type parameter from
LiveMapsimplifies the internal API.- Line 385: Direct assignment is cleaner since
this._rootis alreadyLiveMap, which extendsValue.These changes are consistent with the broader transition to PathObject-based access patterns.
Also applies to: 34-34, 354-354, 385-385
src/plugins/objects/instance.ts (1)
12-12: LGTM! Proper subscription delegation.The changes correctly implement the migration to
Subscription:
- Lines 12, 172: Import and return type updated to use
Subscription.- Line 176: Implementation properly delegates to the underlying
LiveObject'ssubscribemethod and transforms the internalInstanceEventto the publicInstanceSubscriptionEventformat, including convertingObjectMessageto its user-facing representation.Also applies to: 172-172, 176-176
src/plugins/objects/realtimeobject.ts (1)
82-91: Return type upgrade looks solid.Gating on the existing sync semaphore before handing back the
DefaultPathObjectkeeps the old lifecycle guarantees while exposing the new path-based surface. Nicely done.src/plugins/objects/liveobject.ts (1)
71-81: Subscription wrapper matches the new contract.Switching to the
{ unsubscribe }shape plugs straight into the newSubscriptioninterface without altering the underlying emitter behaviour. Looks good to me.src/plugins/objects/livemap.ts (1)
499-525: compact still normalizes nested structures correctly.Iterating via
entries()means we continue to skip tombstoned keys and base64 wrap buffers, so the observable JSON footprint stays intact after the generics refactor.ably.d.ts (1)
1670-1710: Typings line up with the runtime changes.The new
Subscription/StatusSubscriptioninterfaces give consumers a consistentunsubscribe/offcontract and match the objects returned in code. Looks good.
aea9de3 to
80fd55e
Compare
eb5afe1 to
81e9e97
Compare
This marks full transition to path-based API for LiveObjects. Included in this PR: - resolve TODOs related to path-based API - update all LiveObjects tests to use path-based API - remove publicly exposed LiveObject, LiveMap and LiveCounter types from ably.d.ts - remove lifecycle subscriptions API for liveobjects (API and implementation). OBJECT_DELETE events are handled by regular subscription events.
81e9e97 to
e7d734e
Compare
This marks full transition to path-based API for LiveObjects. Included in this PR:
Summary by CodeRabbit
Release Notes
New Features
API Changes