-
Notifications
You must be signed in to change notification settings - Fork 61
[PUB-1539] Replace internal usage of "state" term with "objects" for LiveObjects #1992
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
[PUB-1539] Replace internal usage of "state" term with "objects" for LiveObjects #1992
Conversation
WalkthroughThis pull request systematically refactors the codebase by renaming terminology from “state” to “object” across documentation, type definitions, methods, and tests. The changes update headers, comments, variable names, method signatures, and imported/exported entities to align with the new object-based model without altering functionality or control flow. Changes
Sequence Diagram(s)sequenceDiagram
participant C as Client
participant RTC as RealtimeChannel
participant P as Protocol
participant O as Objects Plugin
C->>RTC: send ObjectMessage[]
RTC->>P: process message (action: OBJECT)
P->>O: forward ObjectMessage[]
O-->>C: acknowledge and update state
Possibly related PRs
Suggested reviewers
Poem
Warning There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure. 🔧 ast-grep (0.31.1)test/realtime/objects.test.jsWarning Review ran into problems🔥 ProblemsErrors were encountered while retrieving linked issues. Errors (1)
🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
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)
Other keywords and placeholders
CodeRabbit Configuration File (
|
70b532e to
c6deab8
Compare
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: 0
🧹 Nitpick comments (8)
README.md (3)
648-649: Minor language improvement suggestion.Consider replacing "gives access to" with "provides access to" for stronger writing.
-The root object represents the top-level entry point for objects within a channel. It gives access to all other nested objects. +The root object represents the top-level entry point for objects within a channel. It provides access to all other nested objects.🧰 Tools
🪛 LanguageTool
[style] ~648-~648: Try using a synonym here to strengthen your writing.
Context: ... point for objects within a channel. It gives access to all other nested objects. ``...(GIVE_PROVIDE)
824-825: Consider adding an apostrophe for clearer possession.The phrase "local Objects state" would read better with an apostrophe to indicate possession.
-LiveObjects emit events that allow you to monitor objects' lifecycle changes, such as synchronization progress and object deletions. +LiveObjects emit events that allow you to monitor objects' lifecycle changes, such as synchronization progress and object deletions.🧰 Tools
🪛 LanguageTool
[uncategorized] ~824-~824: It seems likely that a singular genitive (’s) apostrophe is missing.
Context: ...dsyncedevents notify when the local Objects state on a client is being synchronized...(AI_HYDRA_LEO_APOSTROPHE_S_XS)
838-839: Consider adding a comma in compound sentence.Add a comma before "and" to improve readability in this compound sentence.
-**Object Deletion Events** - objects that have been orphaned for a long period (i.e., not connected to the object tree by being set as a key in a map accessible from the root map object) will eventually be deleted. Once an object is deleted, it can no longer be interacted with. You should avoid accessing its data or trying to update its value and you should remove all references to the deleted object in your application. +**Object Deletion Events** - objects that have been orphaned for a long period (i.e., not connected to the object tree by being set as a key in a map accessible from the root map object) will eventually be deleted. Once an object is deleted, it can no longer be interacted with. You should avoid accessing its data or trying to update its value, and you should remove all references to the deleted object in your application.🧰 Tools
🪛 LanguageTool
[uncategorized] ~838-~838: Use a comma before ‘and’ if it connects two independent clauses (unless they are closely connected and short).
Context: ...g its data or trying to update its value and you should remove all references to the...(COMMA_COMPOUND_SENTENCE)
src/plugins/objects/syncobjectsdatapool.ts (1)
21-21: Update TODO comment to reflect new terminologyThe TODO comment still references "stateObject" which should be updated to "objectState" for consistency with the recent terminology changes.
- // TODO: investigate if this class is still needed after changes with createOp. objects are now initialized from the stateObject and this class does minimal processing + // TODO: investigate if this class is still needed after changes with createOp. objects are now initialized from the objectState and this class does minimal processingsrc/plugins/objects/objects.ts (2)
76-79: Potential concurrency race while awaiting 'synced'
If the channel state transitions to a non-synced condition while awaiting thesyncedevent, consider adding additional checks or error handling to avoid hanging.
296-317: publish method
Emits object-based operations viathis._channel.sendState(...).Consider renaming
sendStateto better reflect the shift to object operations, e.g.sendObjects.src/plugins/objects/objectmessage.ts (1)
146-582: ObjectMessage class
Refactor fromStateMessagetoObjectMessageis thorough, covering encode/decode logic consistently.The
channelfield might be safe to remove entirely if no longer referenced, per the inline TODO comment.src/plugins/objects/livecounter.ts (1)
51-71: createCounterIncMessage
While logically correct, using!isFinite(amount)for validation is discouraged; preferNumber.isFinitefor safer numeric checks.Apply this diff:
- if (typeof amount !== 'number' || !isFinite(amount)) { + if (typeof amount !== 'number' || !Number.isFinite(amount)) {🧰 Tools
🪛 Biome (1.9.4)
[error] 54-54: isFinite is unsafe. It attempts a type coercion. Use Number.isFinite instead.
See the MDN documentation for more details.
Unsafe fix: Use Number.isFinite instead.(lint/suspicious/noGlobalIsFinite)
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (21)
README.md(7 hunks)ably.d.ts(10 hunks)scripts/moduleReport.ts(1 hunks)src/common/lib/client/realtimechannel.ts(9 hunks)src/common/lib/transport/protocol.ts(1 hunks)src/common/lib/types/protocolmessage.ts(6 hunks)src/plugins/objects/batchcontext.ts(3 hunks)src/plugins/objects/batchcontextlivecounter.ts(1 hunks)src/plugins/objects/batchcontextlivemap.ts(1 hunks)src/plugins/objects/index.ts(1 hunks)src/plugins/objects/livecounter.ts(10 hunks)src/plugins/objects/livemap.ts(27 hunks)src/plugins/objects/liveobject.ts(4 hunks)src/plugins/objects/objectmessage.ts(13 hunks)src/plugins/objects/objects.ts(17 hunks)src/plugins/objects/syncobjectsdatapool.ts(2 hunks)test/common/modules/objects_helper.js(3 hunks)test/common/modules/private_api_recorder.js(1 hunks)test/package/browser/template/src/index-objects.ts(1 hunks)test/realtime/channel.test.js(1 hunks)test/realtime/objects.test.js(98 hunks)
🧰 Additional context used
🧬 Code Definitions (10)
src/common/lib/transport/protocol.ts (1)
src/common/lib/types/protocolmessage.ts (1)
actions(17-39)
src/plugins/objects/batchcontext.ts (3)
src/plugins/objects/batchcontextlivecounter.ts (1)
BatchContextLiveCounter(6-41)src/plugins/objects/batchcontextlivemap.ts (1)
BatchContextLiveMap(7-62)src/plugins/objects/objectmessage.ts (1)
ObjectMessage(146-581)
src/plugins/objects/batchcontextlivecounter.ts (1)
src/plugins/objects/livecounter.ts (1)
LiveCounter(14-337)
src/common/lib/types/protocolmessage.ts (3)
src/plugins/objects/index.ts (1)
ObjectMessage(4-4)test/realtime/objects.test.js (2)
Utils(12-12)MessageEncoding(13-13)src/common/lib/types/message.ts (1)
MessageEncoding(445-450)
src/common/lib/client/realtimechannel.ts (2)
src/plugins/objects/index.ts (1)
ObjectMessage(4-4)src/common/lib/types/protocolmessage.ts (1)
actions(17-39)
src/plugins/objects/objects.ts (3)
src/plugins/objects/objectmessage.ts (1)
ObjectMessage(146-581)src/plugins/objects/livemap.ts (1)
LiveMap(54-832)src/plugins/objects/livecounter.ts (1)
LiveCounter(14-337)
src/plugins/objects/objectmessage.ts (1)
src/plugins/objects/livemap.ts (1)
ObjectData(34-34)
src/plugins/objects/livecounter.ts (1)
src/plugins/objects/objectmessage.ts (4)
ObjectState(118-141)ObjectOperation(82-115)ObjectMessage(146-581)CounterOp(47-50)
ably.d.ts (3)
src/plugins/objects/livemap.ts (1)
LiveMap(54-832)src/plugins/objects/livecounter.ts (1)
LiveCounter(14-337)src/plugins/objects/liveobject.ts (1)
SubscribeResponse(24-26)
src/plugins/objects/livemap.ts (3)
src/plugins/objects/objectmessage.ts (5)
ObjectValue(23-23)ObjectData(26-36)ObjectOperation(82-115)ObjectMessage(146-581)MapOp(39-44)src/plugins/objects/index.ts (2)
Objects(4-4)ObjectMessage(4-4)src/plugins/objects/objects.ts (1)
Objects(39-501)
🪛 LanguageTool
README.md
[style] ~648-~648: Try using a synonym here to strengthen your writing.
Context: ... point for objects within a channel. It gives access to all other nested objects. ``...
(GIVE_PROVIDE)
[uncategorized] ~824-~824: It seems likely that a singular genitive (’s) apostrophe is missing.
Context: ...d synced events notify when the local Objects state on a client is being synchronized...
(AI_HYDRA_LEO_APOSTROPHE_S_XS)
[uncategorized] ~838-~838: Use a comma before ‘and’ if it connects two independent clauses (unless they are closely connected and short).
Context: ...g its data or trying to update its value and you should remove all references to the...
(COMMA_COMPOUND_SENTENCE)
🪛 markdownlint-cli2 (0.17.2)
README.md
650-650: Code block style
Expected: indented; Actual: fenced
(MD046, code-block-style)
777-777: Code block style
Expected: indented; Actual: fenced
(MD046, code-block-style)
840-840: Code block style
Expected: indented; Actual: fenced
(MD046, code-block-style)
🪛 Biome (1.9.4)
src/plugins/objects/livecounter.ts
[error] 54-54: isFinite is unsafe. It attempts a type coercion. Use Number.isFinite instead.
See the MDN documentation for more details.
Unsafe fix: Use Number.isFinite instead.
(lint/suspicious/noGlobalIsFinite)
⏰ Context from checks skipped due to timeout of 90000ms (6)
- GitHub Check: test-node (20.x)
- GitHub Check: test-browser (webkit)
- GitHub Check: test-node (18.x)
- GitHub Check: test-browser (firefox)
- GitHub Check: test-node (16.x)
- GitHub Check: test-browser (chromium)
🔇 Additional comments (225)
test/package/browser/template/src/index-objects.ts (1)
34-34: Terminology updated correctly.This comment update correctly aligns with the PR objectives to replace 'state' terminology with 'objects' throughout the codebase.
src/common/lib/transport/protocol.ts (1)
24-24: Action constant updated correctly.The constant
actions.STATEhas been properly replaced withactions.OBJECTin the condition that determines when acknowledgment is required for messages. This change is consistent with the updates to action constants inprotocolmessage.ts.src/plugins/objects/batchcontextlivemap.ts (2)
52-53: Variable and method names updated correctly.The variable name has been changed from
stateMessagetomsg, and the method call fromqueueStateMessagetoqueueMessage, aligning with the PR objectives to replace state terminology with object terminology.
59-60: Variable and method names updated correctly.The variable name has been changed from
stateMessagetomsg, and the method call fromqueueStateMessagetoqueueMessage, consistent with the changes made in thesetmethod above and across the codebase.src/plugins/objects/index.ts (1)
1-1: Exports updated correctly for the renamed entity.The import, named export, and default export have been properly updated to use
ObjectMessageinstead ofStateMessage, which is consistent with the file renaming fromstatemessage.tstoobjectmessage.tsas mentioned in the PR objectives.Also applies to: 4-4, 8-8
scripts/moduleReport.ts (1)
334-334: Updated file path to align with object-based terminology.This change updates the allowed file path from
statemessage.tstoobjectmessage.tsin the Objects plugin files list, consistent with the broader terminology change from "state" to "object" throughout the codebase.src/plugins/objects/batchcontextlivecounter.ts (1)
26-27: Renamed variable and method to follow new object-based terminology.Changed from state-based to object-based terminology:
- Variable renamed from
stateMessagetomsg- Method call updated from
queueStateMessagetoqueueMessageThis aligns with the terminology standardization described in the PR objectives.
test/realtime/channel.test.js (1)
1937-1940: Updated protocol message action and channelSerial to reflect object-based terminology.Changed from state-based to object-based terminology:
- Action value changed from
19(STATE) to"OBJECT"- ChannelSerial value updated from
'STATE'to'OBJECT'This maintains consistency with the renaming of message actions as specified in the PR objectives.
test/common/modules/private_api_recorder.js (1)
25-27: Updated private API identifiers to reflect object-based terminology.Changed StateMessage-related identifiers to ObjectMessage-related identifiers:
'call.StateMessage.encode'→'call.ObjectMessage.encode''call.StateMessage.fromValues'→'call.ObjectMessage.fromValues''call.StateMessage.getMessageSize'→'call.ObjectMessage.getMessageSize'This ensures the private API recording system correctly tracks the renamed methods.
src/plugins/objects/batchcontext.ts (5)
7-7: Import updated to match renamed file.The import has been correctly updated from
StateMessagetoObjectMessageto align with the renaming of the file fromstatemessage.tstoobjectmessage.tsas specified in the PR objectives.
13-13: Comment terminology updated.The documentation comment has been updated to use "object ids" instead of "state ids", maintaining consistency with the PR's terminology change objectives.
15-15: Type declaration updated.The type of
_queuedMessageshas been properly changed fromStateMessage[]toObjectMessage[]to match the renamed type.
52-52: Error message terminology updated.The error message has been updated to use "LiveObject" instead of "Live Object", ensuring consistent terminology throughout the codebase.
88-89: Method name and parameter type updated.The method has been renamed from
queueStateMessagetoqueueMessageand its parameter type changed fromStateMessagetoObjectMessage, maintaining the intended functionality while using the new terminology.test/realtime/objects.test.js (122)
90-91: Function rename aligns with terminology updateThe function has been properly renamed from
stateMessageFromValuestoobjectMessageFromValuesand now correctly callsObjectsPlugin.ObjectMessage.fromValuesinstead ofStateMessage.fromValues.
114-114: Function rename for consistency with terminology changesFunction
waitForStateOperationhas been appropriately renamed towaitForObjectOperationto align with the object-based terminology.
139-140: Updated comment to reflect new terminologyComment has been updated to reference "fixture data" instead of potentially using "state" terminology.
182-197: Updated test and comments to use new OBJECT terminologyTest description and comments have been updated to reference "OBJECT" protocol message instead of "STATE".
207-208: Updated comment to reflect OBJECT_SYNC terminologyComment now correctly refers to "OBJECT_SYNC" instead of "STATE_SYNC" message.
214-229: Updated test and comments for OBJECT_SYNC terminologyTest description and code now properly use "OBJECT_SYNC" protocol message references.
243-244: Updated comments to use OBJECT_SYNC terminologyComment now correctly refers to "OBJECT_SYNC" instead of "STATE_SYNC" message.
276-298: Updated test description to use object terminologyTest description properly updated to reference "LiveObject" instead of likely "LiveState".
309-320: Updated test description to use objects terminologyTest description now properly uses "objects" instead of "states" terminology.
327-328: Updated expectation message to use OBJECT_SYNC terminologyThe expectation message now correctly refers to "OBJECT_SYNC" instead of "STATE_SYNC".
338-342: Updated test description to use OBJECT_SYNC terminologyTest description now properly refers to "OBJECT_SYNC" instead of "STATE_SYNC".
364-373: Updated test description and expectations to use OBJECT_SYNC terminologyTest description and expectations now correctly use "OBJECT_SYNC" instead of "STATE_SYNC".
395-395: Updated expectation message to use OBJECT_SYNC terminologyExpectation message now correctly refers to "OBJECT_SYNC" instead of "STATE_SYNC".
415-416: Updated expectation messages to use OBJECT_SYNC terminologyExpectation messages now correctly refer to "OBJECT_SYNC" instead of "STATE_SYNC".
423-424: Updated test description to use OBJECT_SYNC terminologyTest description now correctly refers to "OBJECT_SYNC" instead of "STATE_SYNC".
442-442: Updated expectation message to use OBJECT_SYNC terminologyExpectation message now correctly refers to "OBJECT_SYNC" instead of "STATE_SYNC".
486-487: Updated test description to use OBJECT_SYNC terminologyTest description now correctly refers to "OBJECT_SYNC" instead of "STATE_SYNC".
519-520: Updated test description to use OBJECT_SYNC terminologyTest description now correctly refers to "OBJECT_SYNC" instead of "STATE_SYNC".
672-673: Updated variable name to use objects terminologyVariable renamed from
stateSyncSequenceScenariostoobjectSyncSequenceScenarios.
674-675: Updated test description to use OBJECT_SYNC terminologyTest description now correctly refers to "OBJECT_SYNC" instead of "STATE_SYNC".
680-684: Updated comments and method call to use object terminologyUpdated to use
processObjectStateMessageOnChanneland OBJECT_SYNC terminology in comments.
715-716: Updated expectation message to use object terminologyExpectation message now correctly refers to OBJECT_SYNC with "tombstone=true" for a map object.
719-722: Updated expectation messages to use object terminologyExpectation messages now correctly refer to OBJECT_SYNC with "tombstone=true" for objects.
728-729: Updated test description to use OBJECT_SYNC terminologyTest description now correctly refers to "OBJECT_SYNC" instead of "STATE_SYNC".
740-743: Updated expectation message to use OBJECT_SYNC terminologyExpectation message now correctly refers to "OBJECT_SYNC" with "tombstone=true".
746-748: Updated comment to use OBJECT_SYNC terminologyComment now correctly refers to "OBJECT_SYNC" message where an object is tombstoned.
771-774: Updated expectation message to use OBJECT_SYNC terminologyExpectation message now correctly refers to "OBJECT_SYNC" with "tombstone=true".
781-782: Updated test description to use OBJECT_SYNC terminologyTest description now correctly refers to "OBJECT_SYNC" instead of "STATE_SYNC".
798-799: Updated expectation message to use OBJECT_SYNC terminologyExpectation message now correctly refers to "OBJECT_SYNC sequence with 'tombstone=true'".
807-808: Updated comment to use OBJECT_SYNC terminologyComment now correctly refers to "OBJECT_SYNC" message with tombstoned object.
838-839: Updated test description to use object terminologyTest description now correctly refers to "object operation messages" instead of "state operation messages".
902-903: Updated test description to use object terminologyTest description now correctly refers to "MAP_CREATE with object ids object operation messages".
978-979: Updated test description to use object terminologyTest description now correctly refers to "MAP_CREATE object operation messages".
993-1004: Updated method calls to use object terminologyMethod calls now correctly use
processObjectOperationMessageOnChannelinstead of likelyprocessStateOperationMessageOnChannel.
1016-1029: Updated method call to use object terminologyMethod call now correctly uses
processObjectOperationMessageOnChannel.
1060-1061: Updated test description to use object terminologyTest description now correctly refers to "MAP_SET with primitives object operation messages".
1109-1110: Updated test description to use object terminologyTest description now correctly refers to "MAP_SET with object ids object operation messages".
1167-1168: Updated test description to use object terminologyTest description now correctly refers to "MAP_SET object operation messages".
1173-1196: Updated method calls to use object terminologyMethod calls now correctly use
processObjectOperationMessageOnChannel.
1236-1237: Updated test description to use object terminologyTest description now correctly refers to "MAP_REMOVE object operation messages".
1299-1300: Updated test description to use object terminologyTest description now correctly refers to "MAP_REMOVE object operation messages".
1305-1344: Updated method calls to use object terminologyMethod calls now correctly use
processObjectOperationMessageOnChannel.
1371-1372: Updated test description to use object terminologyTest description now correctly refers to "COUNTER_CREATE object operation messages".
1424-1425: Updated test description to use object terminologyTest description now correctly refers to "COUNTER_CREATE object operation messages".
1439-1468: Updated method calls to use object terminologyMethod calls now correctly use
processObjectOperationMessageOnChannel.
1492-1493: Updated test description to use object terminologyTest description now correctly refers to "COUNTER_INC object operation messages".
1556-1557: Updated test description to use object terminologyTest description now correctly refers to "COUNTER_INC object operation messages".
1562-1598: Updated method calls to use object terminologyMethod calls now correctly use
processObjectOperationMessageOnChannel.
1601-1602: Updated test description to use object terminologyTest description now correctly refers to "OBJECT_DELETE object operation messages".
1626-1637: Updated method calls to use object terminologyMethod calls now correctly use
processObjectOperationMessageOnChannel.
1651-1670: Updated method calls to use object terminologyMethod calls now correctly use
processObjectOperationMessageOnChannel.
1678-1679: Updated test description to use object terminologyTest description now correctly refers to "OBJECT_DELETE object operation messages".
1693-1722: Updated method calls to use object terminologyMethod calls now correctly use
processObjectOperationMessageOnChannel.
1806-1817: Updated method calls to use object terminologyMethod calls now correctly use
processObjectOperationMessageOnChannel.
1840-1853: Updated method calls to use object terminologyMethod calls now correctly use
processObjectOperationMessageOnChannel.
1861-1862: Updated test description to use object terminologyTest description now correctly refers to "object operation message" instead of "state operation message".
1893-1940: Updated method calls and comments to use object terminologyMethod calls now correctly use
processObjectOperationMessageOnChanneland comments have been updated to reflect object terminology.
1947-1948: Updated test description to use object terminologyTest description now correctly refers to "object operation messages" instead of "state operation messages".
1951-1955: Updated comments and method call to use object terminologyComments and method call now correctly use OBJECT_SYNC terminology.
1960-1973: Updated method call and comments to use object terminologyMethod call now correctly uses
processObjectOperationMessageOnChanneland comments have been updated.
1979-1980: Updated test description to use object terminologyTest description now correctly refers to "object operation messages" instead of "state operation messages".
1983-1987: Updated comment and method call to use object terminologyComment and method call now correctly use OBJECT_SYNC terminology.
1992-2006: Updated method call to use object terminologyMethod call now correctly uses
processObjectOperationMessageOnChannel.
2015-2016: Updated expectation message to use object terminologyExpectation message now correctly refers to operations after OBJECT_SYNC has ended.
2019-2021: Updated expectation message to use object terminologyExpectation message now correctly refers to operations after OBJECT_SYNC has ended.
2028-2029: Updated test description to use object terminologyTest description now correctly refers to "object operation messages" instead of "state operation messages".
2032-2036: Updated comment and method call to use object terminologyComment and method call now correctly use OBJECT_SYNC terminology.
2041-2063: Updated method call to use object terminologyMethod call now correctly uses
processObjectOperationMessageOnChannel.
2066-2069: Updated method call to use object terminologyMethod call now correctly uses
processObjectStateMessageOnChannel.
2075-2076: Updated expectation message to use object terminologyExpectation message now correctly refers to operations when OBJECT_SYNC has ended.
2082-2083: Updated expectation message to use object terminologyExpectation message now correctly refers to operations received during OBJECT_SYNC sequence.
2089-2090: Updated test description to use object terminologyTest description now correctly refers to "object operation messages" instead of "state operation messages".
2094-2101: Updated comments and method call to use object terminologyComments and method call now correctly use OBJECT_SYNC terminology.
2178-2181: Updated method call to use object terminologyMethod call now correctly uses
processObjectStateMessageOnChannel.
2198-2199: Updated expectation message to use object terminologyExpectation message now correctly refers to operations after OBJECT_SYNC has ended.
2204-2205: Updated expectation message to use object terminologyExpectation message now correctly refers to counter value after OBJECT_SYNC has ended.
2211-2212: Updated test description to use object terminologyTest description now correctly refers to "object operation messages" instead of "state operation messages".
2215-2219: Updated comment and method call to use object terminologyComment and method call now correctly use OBJECT_SYNC terminology.
2224-2230: Updated method call to use object terminologyMethod call now correctly uses
processObjectOperationMessageOnChannel.
2235-2238: Updated method call to use object terminologyMethod call now correctly uses
processObjectStateMessageOnChannel.
2252-2253: Updated comment to use object terminologyComment now correctly refers to operations after OBJECT_SYNC has ended.
2259-2260: Updated expectation message to use object terminologyExpectation message now correctly refers to operations after OBJECT_SYNC has ended.
2264-2265: Updated expectation message to use object terminologyExpectation message now correctly refers to operations after OBJECT_SYNC has ended.
2270-2271: Updated expectation message to use object terminologyExpectation message now correctly refers to operations received outside of OBJECT_SYNC.
2697-2698: Updated test description to use object terminologyTest description now correctly refers to "LiveCounter created with Objects.createCounter".
2718-2719: Updated expectation message to use object terminologyExpectation message now correctly refers to "counter assigned to the object tree".
2747-2749: Updated method name to use object terminologyMethod name now correctly uses
objectMessagesparameter name.
2750-2751: Updated method call to use object terminologyMethod call now correctly uses
processObjectOperationMessageOnChannel.
2932-2933: Updated test description to use object terminologyTest description now correctly refers to "LiveMap created with Objects.createMap".
2947-2948: Updated expectation message to use object terminologyExpectation message now correctly refers to "map assigned to the object tree".
2951-2952: Updated expectation message to use object terminologyExpectation message now correctly refers to "map assigned to the object tree".
2955-2956: Updated expectation message to use object terminologyExpectation message now correctly refers to "map assigned to the object tree".
2983-2987: Updated method parameters to use object terminologyMethod parameters now correctly use
objectMessagesinstead of likelystateMessages.
3026-3039: Updated method call to use object terminologyMethod call now correctly uses
processObjectOperationMessageOnChannel.
3103-3104: Updated test description to use object terminologyTest description now correctly refers to "batch API .get method on a map returns BatchContext* wrappers for objects".
3146-3147: Updated test description to use object terminologyTest description now correctly refers to "batch API access API methods on objects".
3188-3189: Updated test description to use object terminologyTest description now correctly refers to objects rather than states.
4476-4477: Updated test description to use object terminologyTest description now correctly refers to "object message publish" instead of "state message publish".
4513-4514: Updated error message to use object terminologyError message now correctly refers to "object messages" instead of "state messages".
4520-4521: Updated section header to use object terminologySection header now correctly refers to "ObjectMessage message size".
4524-4525: Updated method call to use object terminologyMethod call now correctly uses
objectMessageFromValuesinstead ofstateMessageFromValues.
4531-4532: Updated method call to use object terminologyMethod call now correctly uses
objectMessageFromValuesinstead ofstateMessageFromValues.
4538-4539: Updated method call to use object terminologyMethod call now correctly uses
objectMessageFromValuesinstead ofstateMessageFromValues.
4545-4546: Updated method call to use object terminologyMethod call now correctly uses
objectMessageFromValuesinstead ofstateMessageFromValues.
4552-4564: Updated method call to use object terminologyMethod call now correctly uses
objectMessageFromValuesinstead ofstateMessageFromValues.
4569-4578: Updated method call to use object terminologyMethod call now correctly uses
objectMessageFromValuesinstead ofstateMessageFromValues.
4583-4595: Updated method call to use object terminologyMethod call now correctly uses
objectMessageFromValuesinstead ofstateMessageFromValues.
4600-4609: Updated method call to use object terminologyMethod call now correctly uses
objectMessageFromValuesinstead ofstateMessageFromValues.
4614-4615: Updated method call to use object terminologyMethod call now correctly uses
objectMessageFromValuesinstead ofstateMessageFromValues.
4621-4627: Updated method call to use object terminologyMethod call now correctly uses
objectMessageFromValuesinstead ofstateMessageFromValues.
4632-4634: Updated method call to use object terminologyMethod call now correctly uses
objectMessageFromValuesinstead ofstateMessageFromValues.
4639-4645: Updated method call to use object terminologyMethod call now correctly uses
objectMessageFromValuesinstead ofstateMessageFromValues.
4650-4652: Updated method call to use object terminologyMethod call now correctly uses
objectMessageFromValuesinstead ofstateMessageFromValues.
4657-4659: Updated method call to use object terminologyMethod call now correctly uses
objectMessageFromValuesinstead ofstateMessageFromValues.
4664-4682: Updated method call to use object terminologyMethod call now correctly uses
objectMessageFromValuesinstead ofstateMessageFromValues.
4693-4695: Updated method call to use object terminologyMethod call now correctly uses
objectMessageFromValuesinstead ofstateMessageFromValues.
4700-4702: Updated method call to use object terminologyMethod call now correctly uses
objectMessageFromValuesinstead ofstateMessageFromValues.
4707-4709: Updated method call to use object terminologyMethod call now correctly uses
objectMessageFromValuesinstead ofstateMessageFromValues.
4714-4726: Updated method call to use object terminologyMethod call now correctly uses
objectMessageFromValuesinstead ofstateMessageFromValues.
4732-4738: Updated private API recording and method calls to use object terminologyPrivate API recordings and method calls now correctly use
ObjectMessageinstead ofStateMessage.
4745-4746: Updated test description to use object terminologyTest description now correctly refers to "Objects modes" instead of "States modes".
5552-5557: Updated variable name to use object terminologyVariable references now correctly use
objectSyncSequenceScenariosinstead ofstateSyncSequenceScenarios.README.md (5)
656-656: Terminology update looks good.The heading change from "Live Object Types" to "Object Types" aligns with the specification updates.
660-661: Terminology update looks good.Updated description of LiveMap to reference "other objects" instead of "other Live Objects", maintaining consistency with the new terminology.
717-718: Terminology update looks good.Updated subscription description to reference "objects" instead of "Live Objects", maintaining consistency.
775-776: Terminology update looks good.Clear description about creating new LiveMap and LiveCounter objects, consistent with the updated terminology.
845-845: Simplified message looks good.Simplified notification message from "Live Object has been deleted" to "Object has been deleted", consistent with terminology changes.
src/common/lib/types/protocolmessage.ts (6)
37-38: Action constant names updated correctly.Changed action names from
STATEtoOBJECTandSTATE_SYNCtoOBJECT_SYNCwhile preserving the same action codes.
53-53: Flag name updated correctly.Changed flag name from
HAS_STATEtoHAS_OBJECTwhile preserving the bit position (1 << 7).
129-135: Type and method calls updated correctly.Updated the variable type from
StateMessage[]toObjectMessage[]and corresponding method calls to use the newObjectMessage.fromValuesmethod.
146-147: Comment updated correctly.Updated the comment to refer to "object messages" instead of "state messages".
181-182: String representation code updated correctly.Updated the object handling in the
stringifymethod to useObjectMessage.fromValuesArray.
222-222: Property type updated correctly.Updated the
stateproperty type in theProtocolMessageclass fromStateMessage[]toObjectMessage[]to match the renamed type.src/common/lib/client/realtimechannel.ts (9)
33-33: Import statement updated correctly.Changed the import to use
ObjectMessageinstead ofStateMessagewhile maintaining the same import structure.
510-519: Method signature and implementation updated correctly.Renamed the method parameter from state messages to object messages and updated the corresponding action constant from
STATEtoOBJECT.
527-527: Message action check updated correctly.Updated the action check in the
processMessagemethod to useactions.OBJECTinstead ofactions.STATE.
545-545: Flag check updated correctly.Changed the flag check from
HAS_STATEtoHAS_OBJECTin the attached handler.
555-556: Method call updated correctly.Updated the method call to
onAttachedto pass thehasObjectflag instead of thehasStateflag.
615-637: Message handling logic updated correctly.Updated the case conditions for object and object sync messages and their handling logic to use the new terminology. All references to state messages have been replaced with object messages.
743-743: Generic type constraint updated correctly.Updated the generic type constraint in the
_decodeAndPrepareMessagesmethod to useObjectMessageinstead ofStateMessage.
812-812: Method parameter updated correctly.Added
hasObjectparameter to thenotifyStatemethod to replace the previoushasStateparameter.
834-835: Method call updated correctly.Updated the method call to
actOnChannelStateto provide thehasObjectflag instead ofhasState.test/common/modules/objects_helper.js (5)
4-4: Comment updated correctly.Updated the class description to refer to "objects tree" and "object messages" instead of "state tree" and "state messages".
239-253: Method renamed and implementation updated correctly.Renamed the method from
stateOperationMessagetoobjectOperationMessageand updated internal variable naming while maintaining the same functionality. The action code (19) remains the same.
255-264: Method renamed and implementation updated correctly.Renamed the method from
stateObjectMessagetoobjectStateMessageand maintained the same functionality. The action code (20) remains the same.
266-279: Method renamed and call updated correctly.Renamed the method from
processStateOperationMessageOnChanneltoprocessObjectOperationMessageOnChanneland updated the method call inside to use the new name.
281-294: Method renamed and call updated correctly.Renamed the method from
processStateObjectMessageOnChanneltoprocessObjectStateMessageOnChanneland updated the method call inside to use the new name.src/plugins/objects/syncobjectsdatapool.ts (7)
3-3: Import updated for alignment with object-based terminologyThe import statement now correctly uses
ObjectMessageandObjectStateinstead of their state-based counterparts, in line with the PR objectives.
7-7: Interface property renamed for consistencyThe property has been updated from
stateObjecttoobjectState, keeping the same functionality while aligning with the new terminology.
52-62: Method name and parameters updated successfullyThe method has been properly renamed from
applyStateSyncMessagestoapplyObjectSyncMessages, with parameters updated accordingly. The logging message has also been updated to reflect the new terminology.
64-69: Variable names updated to match new terminologyVariable and property names have been consistently updated from state-related to object-related terminology while maintaining the same logic.
74-75: Error logging updated to use new terminologyThe error logging message correctly uses the updated method name and terminology, ensuring consistency in the codebase.
81-88: Method signature and implementation updated correctlyBoth the method signature and implementation details for
_createLiveCounterDataEntryhave been properly updated to use the newObjectStatetype instead ofStateObject.
90-97: Method signature and implementation updated correctlyBoth the method signature and implementation details for
_createLiveMapDataEntryhave been properly updated to use the newObjectStatetype instead ofStateObject.src/plugins/objects/liveobject.ts (7)
3-3: Imports updated to align with new terminologyThe imports have been updated from state-related types to object-related types, consistent with the PR objectives.
47-49: Documentation comment updated correctlyThe comment has been updated to reference "object operations" instead of "state operations", maintaining consistency with the new terminology.
157-159: Documentation comment updated to reflect new terminologyThe comment now correctly describes the action as clearing the "object's data" rather than the "object's state", maintaining consistency with the new terminology.
208-213: Method documentation and signature updatedBoth the JSDoc comment and method signature have been updated to use object-related terminology instead of state-related terminology.
214-226: Method documentation and signature updated correctlyThe method has been renamed from
overrideWithStateObjecttooverrideWithObjectState, and its documentation has been updated to use object-based terminology throughout.
233-236: Documentation comment updatedThe comment has been updated to use the new terminology while maintaining the same meaning.
237-247: Documentation and method parameter updatedBoth the JSDoc comment and method parameter have been updated to use object-related terminology instead of state-related terminology, while preserving the functional meaning.
ably.d.ts (7)
875-881: Terminology updated to align with new standardThe comment terminology has been appropriately updated from "Objects messages" to "object messages" for both
OBJECT_PUBLISHandOBJECT_SUBSCRIBEtype descriptions, ensuring consistency with the refactoring objectives.
2184-2186: Type definition migrated from StateValue to ObjectValueThe LiveMapType definition has been correctly updated to use
ObjectValueinstead ofStateValue, aligning with the PR's goal of replacing the internal usage of 'state' term with 'objects' for LiveObjects.
2296-2298: Documentation improvement for LiveMap classThe LiveMap class documentation has been enhanced to explicitly state that conflicts are resolved with last-write-wins (LWW) semantics. This is a helpful clarification for developers.
2314-2315: Minor wording improvement in size() method documentationUpdated terminology from "key/value pairs" to "key-value pairs" for consistency with general TypeScript/JavaScript conventions.
2428-2444: Documentation updated for LiveObject interface methodsThe comments for subscribe, unsubscribe, and unsubscribeAll methods have been updated to consistently refer to "LiveObject" instead of potentially using older terminology.
2471-2472: Updated comment for LiveObjectUpdate interfaceThe interface description has been updated to match the new object-based terminology.
2376-2376: Renamed StateValue type to ObjectValueThe type has been correctly renamed from StateValue to ObjectValue as per the PR requirements.
src/plugins/objects/objects.ts (10)
10-10: Rename from StateMessage to ObjectMessage looks correct
No issues identified in this import line.
52-66: Renaming and initializing_bufferedObjectOperations
Switching from_bufferedStateOperationsto_bufferedObjectOperationsof typeObjectMessage[]aligns well with the object-based approach.
112-131: Check for nullish operation or objectId
Ensuremsg.operationalways returns a validobjectIdin caseLiveMap.createMapCreateMessagefails or returns unexpected data.
144-162: createCounter method
Implementation closely mirrors the map creation flow and appears logically sound.
215-230: handleObjectSyncMessages
Refactored method properly parses sync state and applies object sync messages through_syncObjectsDataPool.
235-246: Buffering concurrent incoming messages
Forwarding object messages to a buffer until the channel completes sync is a valid approach to prevent race conditions.
251-274: onAttached method
Renaming fromhasStatetohasObjectaligns with the new object-based API, and the updated flow for resetting objects on attach looks consistent.
279-291: actOnChannelState
Logic for resetting object pools when detached or failed remains unchanged in essence and appears correct.
336-355: Sync logic
Discarding buffered messages on_startNewSyncand applying them after_applySyncensures consistency.
416-461: _applyObjectMessages method
Appropriately handles missing or unknown actions, creating zero-value objects as needed.src/plugins/objects/objectmessage.ts (4)
9-16: ObjectOperationAction enum
Transition away fromSTATE_*constants towardOBJECT_*constants is coherent and matches the rest of the refactor.
22-80: Object-based data structures
Renamed interfaces and types (e.g.,ObjectValue,ObjectData,MapOp,CounterOp) clearly reflect the new object model.
81-115: ObjectOperation interface
Replaces state operations with object operations, unifying map and counter operations under one type.
117-141: ObjectState interface
Captures an instantaneous object snapshot, including tombstone behavior, in a clear manner.src/plugins/objects/livecounter.ts (11)
3-3: Import references
Successfully transitioned from state-based imports to object-based imports.
25-34: fromObjectState
Correctly merges the passed-inObjectStateinto a newLiveCounterinstance.
37-46: fromObjectOperation
Gracefully handles initialization from aCOUNTER_CREATEoperation, reflecting the object-based model.
76-112: createCounterCreateMessage
Encodes the create operation for a counter including nonce and initial value.
117-123: createInitialValueObject
Returns a well-defined structure for a new counter's initial value, defaulting to zero.
141-143: increment method
Publishes aCOUNTER_INCoperation, deferring local state changes until the echoed response arrives.
162-220: applyOperation
Checks concurrency with site timeserials and routes counter operations (create/inc/tombstone) properly.
225-278: overrideWithObjectState
Performs validation on createOp, merges or tombstones appropriately, and updates local data.
297-306: _mergeInitialDataFromCreateOperation
Summation logic for merging the initial creation data ensures a correct starting count.
316-331: _applyCounterCreate
Prevents re-applying an already merged create operation, enforcing idempotency.
333-336: _applyCounterInc
Adds the increment amount to the local counter and constructs a straightforward update payload.src/plugins/objects/livemap.ts (18)
8-17: Consistent renaming from “state” to “object” in imports.
All imported entities here align well with the new LiveObjects naming scheme, and there appear to be no structural or functional issues introduced by these name changes.
19-32: Introduction of new “object”-based data interfaces.
ObjectIdObjectDataandValueObjectDataare clearly documented and correctly typed for referencing or storing leaf values, respectively. The JSDoc comments match their usage. No immediate pitfalls detected.
34-34: Refactoring of the data structures to “LiveMapEntry” and “LiveMapData.”
Changing the underlying type definitions from state-based to object-based is straightforward. TheObjectDatatype union anddata: Map<string, LiveMapEntry>property are coherent and consistent with the PR’s objectives.Also applies to: 36-36, 43-43, 47-47
73-80:fromObjectStatemethod refactor.
Renaming fromfromStateObjectis consistent with the new object-based model. The logic simply instantiates aLiveMapand applies the passed-in state. No issues spotted.
85-95:fromObjectOperationmethod refactor.
Renamed fromfromStateOperation. The method’s workflow for creating aLiveMapand applying the initial create operation is sensible. The non-null assertion onobjectOperation.map?.semantics!is acceptable if the calling code guarantees a valid map.Please ensure upstream logic consistently sets
objectOperation.mapbefore calling this method. If not, consider a graceful error check.
108-133:createMapSetMessagenow uses object-based payloads.
Switching from “state” to “object” references for the operation payload is seamless. The logic for determining whether the value is a reference to another LiveObject or a direct value remains clear and correct.
142-162:createMapRemoveMessagealigns with object-based approach.
The method constructs aMAP_REMOVEoperation in anObjectMessage. The type checks onkeystill stand. No concerns.
193-245:createMapCreateMessageandcreateInitialValueObjectreworked for object-based creation.
The changes properly handle map entries under the new naming convention, encoding the initial value, and generating an ID withObjectId.fromInitialValue. The function flow and error handling appear correct.
263-263: Doc references and usage of_getResolvedValueFromObjectData.
Changing “state” to “object” clarifies the meaning of these references. The usage ofelement.data!is guarded by tombstone checks, making it safe.Also applies to: 286-286, 315-315
343-344: Refinedsetandremovemethods to publish object-based messages.
The updated calls tocreateMapSetMessageandcreateMapRemoveMessagemaintain consistency with the object-based rewrite. No issues.Also applies to: 358-359
365-365:applyOperationupdated to handle object actions.
Renaming actions (e.g.,MAP_CREATE,MAP_SET,MAP_REMOVE) ensures clarity. The CRDT logic, site timeserial checks, and fallback branches remain unbroken.Also applies to: 366-366, 369-369, 396-396, 400-400, 410-410, 420-420
438-505:overrideWithObjectStatecorrectly applies the new object state.
Renamed fromoverrideWithStateObjectto align with the new model. Checks for semantics, tombstones, and createOp remain consistent. No red flags in the updated logic.
583-593:_mergeInitialDataFromCreateOperationfor MAP_CREATE merges object-based entries.
Appropriately merges each entry from the create operation to the existing map, skipping older timeserials. Implementation logically fits LWW semantics.
627-627:_applyMapCreatemethod re-labeled and integrated with object-based semantics.
It prevents applying duplicate create ops and ensures semantics match. Straightforward rename from any prior state-based logic.Also applies to: 641-641
663-663:_applyMapSetobject-based checks and timeserial validations.
Verifies whether data is a reference or a direct value. Properly sets or updates the map entry to non-tombstoned state, or logs if the timeserial is too old.Also applies to: 669-669, 675-675, 677-677, 684-684, 693-693, 694-694
763-765:_liveMapDataFromMapEntriesconstructs live map data aroundObjectData.
This is the direct counterpart to the old state-based approach. The logic to handleobjectIdvs.valueis clear.Also applies to: 770-770, 772-772, 774-774, 777-777, 785-785
794-794:_getResolvedValueFromObjectDatanow resolves object references vs. primitives.
Proper name change from_getResolvedValueFromStateDatato_getResolvedValueFromObjectData. The logic correctly checks if the reference object is tombstoned or not.Also applies to: 795-795, 796-796, 800-800
814-814:_isMapEntryTombstonedaccounts for tombstoned references.
The rename from state references to object references in the checks is straightforward. The method cleanly covers tombstone scenarios.Also applies to: 815-815, 822-822, 824-824
c6deab8 to
8f9bd30
Compare
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: 0
🧹 Nitpick comments (2)
src/plugins/objects/objects.ts (1)
296-316: publish(ObjectMessage[]): rename sendState?
The method is properly refactored to handleObjectMessage[]. However, consider renamingsendStateto something likesendObjectfor improved clarity.src/plugins/objects/livecounter.ts (1)
54-54: Use Number.isFinite instead of isFinite.Global
isFinite()attempts type coercion which can lead to unexpected behavior. UseNumber.isFinite()for stricter type checking.- if (typeof amount !== 'number' || !isFinite(amount)) { + if (typeof amount !== 'number' || !Number.isFinite(amount)) {🧰 Tools
🪛 Biome (1.9.4)
[error] 54-54: isFinite is unsafe. It attempts a type coercion. Use Number.isFinite instead.
See the MDN documentation for more details.
Unsafe fix: Use Number.isFinite instead.(lint/suspicious/noGlobalIsFinite)
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro (Legacy)
📒 Files selected for processing (9)
scripts/moduleReport.ts(1 hunks)src/plugins/objects/batchcontext.ts(3 hunks)src/plugins/objects/index.ts(1 hunks)src/plugins/objects/livecounter.ts(10 hunks)src/plugins/objects/livemap.ts(27 hunks)src/plugins/objects/liveobject.ts(4 hunks)src/plugins/objects/objectmessage.ts(13 hunks)src/plugins/objects/objects.ts(17 hunks)src/plugins/objects/syncobjectsdatapool.ts(2 hunks)
🚧 Files skipped from review as they are similar to previous changes (3)
- scripts/moduleReport.ts
- src/plugins/objects/index.ts
- src/plugins/objects/liveobject.ts
🧰 Additional context used
🧬 Code Definitions (4)
src/plugins/objects/objects.ts (3)
src/plugins/objects/objectmessage.ts (1)
ObjectMessage(146-575)src/plugins/objects/livemap.ts (1)
LiveMap(54-832)src/plugins/objects/livecounter.ts (1)
LiveCounter(14-337)
src/plugins/objects/livecounter.ts (3)
src/plugins/objects/index.ts (2)
Objects(4-4)ObjectMessage(4-4)src/plugins/objects/objects.ts (1)
Objects(39-501)src/plugins/objects/objectmessage.ts (4)
ObjectState(118-141)ObjectOperation(82-115)ObjectMessage(146-575)CounterOp(47-50)
src/plugins/objects/objectmessage.ts (1)
src/plugins/objects/livemap.ts (1)
ObjectData(34-34)
src/plugins/objects/livemap.ts (3)
src/plugins/objects/objectmessage.ts (5)
ObjectValue(23-23)ObjectData(26-36)ObjectOperation(82-115)ObjectMessage(146-575)MapOp(39-44)src/plugins/objects/index.ts (2)
Objects(4-4)ObjectMessage(4-4)src/plugins/objects/objects.ts (1)
Objects(39-501)
🪛 Biome (1.9.4)
src/plugins/objects/livecounter.ts
[error] 54-54: isFinite is unsafe. It attempts a type coercion. Use Number.isFinite instead.
See the MDN documentation for more details.
Unsafe fix: Use Number.isFinite instead.
(lint/suspicious/noGlobalIsFinite)
⏰ Context from checks skipped due to timeout of 90000ms (6)
- GitHub Check: test-browser (webkit)
- GitHub Check: test-node (20.x)
- GitHub Check: test-node (18.x)
- GitHub Check: test-browser (firefox)
- GitHub Check: test-browser (chromium)
- GitHub Check: test-node (16.x)
🔇 Additional comments (88)
src/plugins/objects/batchcontext.ts (5)
7-7: Consistent import renaming from StateMessage to ObjectMessage
This import aligns well with the refactor away from "state" terminology.
13-13: Doc comment updated to reflect new terminology
Renaming "live object ids" to "object ids" is consistent with the rest of the changes.
15-15: Correct transition to ObjectMessage[]
Switching the_queuedMessagesarray type fromStateMessage[]toObjectMessage[]is coherent with the rest of the refactor.
52-52: Minor error message update
Changing “Unknown LiveObject instance type” is consistent with the new naming scheme. No issues found.
88-89: Method rename from queueStateMessage to queueMessage
Updating the name and parameter type fromStateMessagetoObjectMessagematches the broader shift in terminology.src/plugins/objects/syncobjectsdatapool.ts (5)
3-3: Import refactor
AddingObjectMessageandObjectStatewhile dropping references to old state-based types is consistent with the rename.
7-7: Property rename to objectState
ChangingstateObjecttoobjectStateclarifies usage of the new object-based approach.
52-79: applyStateSyncMessages → applyObjectSyncMessages
Refactoring the logic to handleobjectMessage.objectinstead ofstateMessage.statekeeps the method aligned with the new terminology. The updated logging and skip conditions look correct.
81-84: _createLiveCounterDataEntry
ReplacingstateObjectwithobjectStateis consistent with the rest of this refactor.
90-93: _createLiveMapDataEntry
Similarly, changing toobjectStatefollows the same naming standard for map-related entries. Looks good.src/plugins/objects/objects.ts (15)
10-10: Refined import statement
Switching from state-based types toObjectMessageandObjectOperationActioncompletes the rename in this file.
52-65: Introduction of _bufferedObjectOperations
Renaming_bufferedStateOperationsto_bufferedObjectOperationsand changing its type toObjectMessage[]fits the new object-based workflow.
76-77: Sync waiting logic
Retaining the check forthis._state !== ObjectsState.syncedbefore returning the root keeps usage consistent and ensures the required sync is completed first.
112-131: Refactor createMap to use ObjectMessage
UsingLiveMap.createMapCreateMessageand then publishing a list ofObjectMessageis consistent with the new approach.
145-162: Refactor createCounter to use ObjectMessage
Transitioning from state-based creation to object-based creation ensures uniformity. The logic for publishing the create message and locally instantiating the object if needed is correct.
215-222: handleObjectSyncMessages
Renames fromhandleStateSyncMessagestohandleObjectSyncMessagesand usage of_syncObjectsDataPool.applyObjectSyncMessagesconfirm the shift to object sync.
237-246: handleObjectMessages buffering
Buffering object messages until the sync is complete is a sound approach. The updated references from “state” to “object” remain consistent.
251-274: onAttached with hasObject
The logic to start a new sync sequence or immediately end sync if!hasObjectis well-structured and aligns with the rename from “state” to “object.”
279-284: actOnChannelState
CallingonAttachedfor the 'attached' event with the newhasObjectparameter follows the revised naming.
335-350: _startNewSync and _endSync
Clearing_bufferedObjectOperationsbefore/after the sync then applying them once the sync completes is a sensible flow.
388-389: overrideWithObjectState usage
EnsuringexistingObjectupdates withentry.objectStatealigns with the new naming scheme and object-based logic.
400-404: LiveCounter & LiveMap fromObjectState
Refactoring the creation logic to rely onobjectStatematches the rest of the rename.
408-408: Updated error for unknown LiveObject
Replacing references to unknown “state” types is consistent, and the 500-code classification is appropriate.
414-414: deleteExtraObjectIds
Removing objects not present in the current sync helps keep the pool accurate and is consistent with object-based references.
421-461: _applyObjectMessages
Correctly checksobjectMessage.operationbefore deciding whether to create a zero-value object or skip unsupported actions. Perfectly follows the object-based approach.src/plugins/objects/objectmessage.ts (26)
9-16: LGTM! Consistent renaming of enum and action types.The renaming from
StateOperationActiontoObjectOperationActionis correctly implemented while maintaining the same enumeration values, preserving backward compatibility with the protocol.
22-23: LGTM! Type rename preserves underlying structure.The type rename from
StateValuetoObjectValuehas been properly implemented while maintaining the same underlying types.
25-36: LGTM! Interface renamed with documentation updates.The interface rename from
StateDatatoObjectDatais consistent, with documentation properly updated to reflect the terminology change from "state" to "object".
38-44: LGTM! Operation interface rename with documentation updates.The interface rename from
StateMapOptoMapOpis well-implemented with documentation properly updated.
46-50: LGTM! Counter operation interface rename.The interface rename from
StateCounterOptoCounterOpis correctly implemented.
53-65: LGTM! Map entry interface with updated references.The interface rename to use
ObjectDatain line 64 is correctly implemented.
67-73: LGTM! Map interface rename.The interface rename from
StateMaptoObjectMapis correctly implemented with proper documentation updates.
75-79: LGTM! Counter interface rename.The interface rename from
StateCountertoObjectCounteris correctly implemented with proper documentation updates.
81-116: LGTM! Operation interface rename with comprehensive updates.The interface rename from
StateOperationtoObjectOperationis thoroughly implemented, with all properties and documentation properly updated to use the new terminology.
117-141: LGTM! Object state interface implementation.The interface rename from
StateObjecttoObjectStateis well-implemented, with all properties and documentation properly updated. This change maintains the same underlying structure while updating the terminology.
143-169: LGTM! Class rename with property updates.The class rename from
StateMessagetoObjectMessageis consistently applied, with all class properties and documentation properly updated to use the new terminology.
175-197: LGTM! Method implementation with updated references.The
encodestatic method has been updated to use the new terminology (ObjectMessageandObjectOperation) throughout its implementation.
199-228: LGTM! Decode method with updated references.The
decodestatic method has been updated to properly handleObjectMessageand related types.
230-251: LGTM! Factory methods with updated references.The factory methods
fromValuesandfromValuesArrayhave been updated to properly handleObjectMessagetypes.
253-287: LGTM! Initial value encoding with updated references.The
encodeInitialValuemethod has been updated to work withObjectOperationandObjectMessagetypes.
289-315: LGTM! Map entries decoding method with updated references.The private
_decodeMapEntriesmethod has been updated to work with the newMapEntryandObjectDatatypes.
317-341: LGTM! Object operation encoding with thorough updates.The
_encodeObjectOperationmethod has been renamed from_encodeStateOperationand all references within have been properly updated to use the new terminology.
343-361: LGTM! Object state encoding with thorough updates.The
_encodeObjectStatemethod has been renamed from_encodeStateObjectand all references have been properly updated.
363-371: LGTM! Object data encoding method updated.The
_encodeObjectDatamethod has been renamed from_encodeStateDataand correctly handles the newObjectDatatype.
373-407: LGTM! Wire protocol encoding with updated references.The
_encodeForWireProtocolmethod has been updated to work withObjectMessage,ObjectOperation, andObjectStatetypes.
409-436: LGTM! JSON serialization with updated references.The
toJSONmethod has been updated to handleObjectOperationandObjectStateproperties correctly.
438-457: LGTM! String representation updated.The
toStringmethod has been updated to outputObjectMessagein its output along with property references.
459-474: LGTM! Message size calculation with updated references.The
getMessageSizemethod has been updated to use the renamed helper methods for calculating object operation and state sizes.
476-493: LGTM! Object operation size calculation method.The
_getObjectOperationSizemethod has been renamed from_getStateOperationSizeand correctly uses the renamed helper methods.
495-509: LGTM! Object state size calculation method.The
_getObjectStateSizemethod has been renamed from_getStateObjectSizeand correctly uses the renamed helper methods.
511-574: LGTM! Helper methods for size calculations updated.All helper methods for size calculations have been renamed consistently to use the "Object" terminology, maintaining their functionality:
_getObjectMapSize(from_getStateMapSize)_getObjectCounterSize(from_getStateCounterSize)_getMapEntrySize(no change)_getMapOpSize(no change)_getCounterOpSize(no change)_getObjectDataSize(from_getStateDataSize)_getObjectValueSize(from_getStateValueSize)src/plugins/objects/livecounter.ts (14)
1-4: LGTM! Import updates to use new types.The imports have been correctly updated to use
ObjectMessage,ObjectOperation,ObjectOperationAction, andObjectStatefrom the renamed file.
24-34: LGTM! Method rename with updated documentation.The method has been properly renamed from
fromStateObjecttofromObjectStatewith corresponding parameter type updates and documentation changes.
36-46: LGTM! Method rename with parameter updates.The method has been properly renamed from
fromStateOperationtofromObjectOperationwith corresponding parameter type updates and documentation changes.
48-71: LGTM! Counter increment message creation updated.The
createCounterIncMessagemethod has been updated to useObjectMessageandObjectOperationAction.COUNTER_INCcorrectly.🧰 Tools
🪛 Biome (1.9.4)
[error] 54-54: isFinite is unsafe. It attempts a type coercion. Use Number.isFinite instead.
See the MDN documentation for more details.
Unsafe fix: Use Number.isFinite instead.(lint/suspicious/noGlobalIsFinite)
73-112: LGTM! Counter creation message method updated.The
createCounterCreateMessagemethod has been updated to useObjectMessageandObjectOperationAction.COUNTER_CREATEcorrectly.
114-123: LGTM! Initial value object creation method updated.The
createInitialValueObjectmethod has been updated to useObjectOperationas the type parameter.
139-143: LGTM! Increment method implementation updated.The
incrementmethod has been updated to use the renamed message creation method correctly.
159-190: LGTM! Apply operation method updated.The
applyOperationmethod has been updated to useObjectOperationandObjectMessageparameter types with corresponding error message updates.
191-220: LGTM! Switch case structure updated.The action checking in the switch case has been updated to use
ObjectOperationActionenum values correctly.
222-278: LGTM! Object state override method updated.The
overrideWithObjectStatemethod has been renamed fromoverrideWithStateObjectand thoroughly updated to handle the newObjectStatetype with proper error messages.
297-306: LGTM! Initial data merging method updated.The
_mergeInitialDataFromCreateOperationmethod has been updated to useObjectOperationparameter type with correct property references.
308-314: LGTM! Error handling method updated.The
_throwNoPayloadErrormethod has been updated to useObjectOperationparameter type.
316-331: LGTM! Counter creation application method updated.The
_applyCounterCreatemethod has been updated to useObjectOperationparameter type.
333-336: LGTM! Counter increment application method updated.The
_applyCounterIncmethod has been updated to useCounterOpparameter type.src/plugins/objects/livemap.ts (23)
7-17: LGTM! Import updates to use new types.The imports have been correctly updated to use the renamed types from objectmessage.ts, ensuring consistency with the new terminology.
19-34: LGTM! Interface renames with proper documentation.The interfaces have been renamed from
ObjectIdStateDatatoObjectIdObjectDataandValueStateDatatoValueObjectDatawith corresponding documentation updates.
36-44: LGTM! Map entry interface updated.The
LiveMapEntryinterface now referencesObjectDatainstead ofStateData, maintaining consistency with the terminology change.
46-48: LGTM! Map data interface updated.The
LiveMapDatainterface has been updated to useLiveMapEntryconsistently.
72-82: LGTM! State object method rename.The method has been properly renamed from
fromStateObjecttofromObjectStatewith corresponding parameter updates and documentation changes.
84-97: LGTM! State operation method rename.The method has been properly renamed from
fromStateOperationtofromObjectOperationwith corresponding parameter updates and documentation changes.
99-133: LGTM! Map set message creation updated.The
createMapSetMessagemethod has been updated to useObjectMessage,ObjectOperationAction.MAP_SET, and properly handleObjectDatatypes.
135-162: LGTM! Map remove message creation updated.The
createMapRemoveMessagemethod has been updated to useObjectMessageandObjectOperationAction.MAP_REMOVEcorrectly.
192-230: LGTM! Map create message method updated.The
createMapCreateMessagemethod has been updated to useObjectMessage,ObjectOperationAction.MAP_CREATE, and properly handle the changed interfaces.
232-255: LGTM! Initial value object creation method updated.The
createInitialValueObjectmethod has been updated to useObjectOperationas the type parameter andMapEntryinterfaces properly.
257-287: LGTM! Documentation updates for map properties.The documentation for the
getmethod has been updated to reflect the new terminology around object references.
341-345: LGTM! Set method implementation updated.The
setmethod has been updated to use the renamed message creation methods correctly.
356-360: LGTM! Remove method implementation updated.The
removemethod has been updated to use the renamed message creation methods correctly.
362-433: LGTM! Apply operation method updated.The
applyOperationmethod has been updated to useObjectOperationandObjectMessageparameter types, and the switch cases useObjectOperationActionenum values correctly.
435-507: LGTM! Object state override method updated.The
overrideWithObjectStatemethod has been renamed fromoverrideWithStateObjectand thoroughly updated to handle the newObjectStatetype with proper error messages and logic.
583-617: LGTM! Initial data merging method updated.The
_mergeInitialDataFromCreateOperationmethod has been updated to useObjectOperationparameter type correctly.
619-625: LGTM! Error handling method updated.The
_throwNoPayloadErrormethod has been updated to useObjectOperationparameter type.
627-650: LGTM! Map creation application method updated.The
_applyMapCreatemethod has been updated to useObjectOperationparameter type.
652-702: LGTM! Map set application method updated.The
_applyMapSetmethod has been updated to useMapOpparameter type and handleObjectDatacorrectly.
704-733: LGTM! Map remove application method updated.The
_applyMapRemovemethod has been updated to useMapOpparameter type and handleLiveMapEntrycorrectly.
763-789: LGTM! Map entries conversion method updated.The
_liveMapDataFromMapEntriesmethod has been updated to properly convert fromMapEntrytoLiveMapEntrywhile handlingObjectDatacorrectly.
791-812: LGTM! Value resolution method updated.The
_getResolvedValueFromObjectDatamethod has been renamed and updated to handleObjectDataand returnObjectValuecorrectly.
814-831: LGTM! Map entry check method updated.The
_isMapEntryTombstonedmethod has been updated to useLiveMapEntryparameter type correctly.
mschristensen
left a 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.
Small comment: I think HAS_OBJECT should be HAS_OBJECTS
Otherwise lgtm, thanks :)
8f9bd30 to
6f8d1d0
Compare
Yeah, agree, updated in https://github.com/ably/ably-js/compare/8f9bd302574e359a424f045747ef7eef9d26c2f0..6f8d1d0d4b5f97b2e1fe7a46d4c711704ef40d5a. Will update the spec too |
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: 0
🧹 Nitpick comments (1)
src/plugins/objects/livecounter.ts (1)
54-54: Use Number.isFinite instead of isFinite.The global
isFinitefunction attempts a type coercion which could lead to unexpected behavior. UseNumber.isFiniteinstead for stricter type checking.- if (typeof amount !== 'number' || !isFinite(amount)) { + if (typeof amount !== 'number' || !Number.isFinite(amount)) {🧰 Tools
🪛 Biome (1.9.4)
[error] 54-54: isFinite is unsafe. It attempts a type coercion. Use Number.isFinite instead.
See the MDN documentation for more details.
Unsafe fix: Use Number.isFinite instead.(lint/suspicious/noGlobalIsFinite)
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro (Legacy)
📒 Files selected for processing (21)
README.md(7 hunks)ably.d.ts(10 hunks)scripts/moduleReport.ts(1 hunks)src/common/lib/client/realtimechannel.ts(9 hunks)src/common/lib/transport/protocol.ts(1 hunks)src/common/lib/types/protocolmessage.ts(6 hunks)src/plugins/objects/batchcontext.ts(3 hunks)src/plugins/objects/batchcontextlivecounter.ts(1 hunks)src/plugins/objects/batchcontextlivemap.ts(1 hunks)src/plugins/objects/index.ts(1 hunks)src/plugins/objects/livecounter.ts(10 hunks)src/plugins/objects/livemap.ts(27 hunks)src/plugins/objects/liveobject.ts(4 hunks)src/plugins/objects/objectmessage.ts(13 hunks)src/plugins/objects/objects.ts(17 hunks)src/plugins/objects/syncobjectsdatapool.ts(2 hunks)test/common/modules/objects_helper.js(3 hunks)test/common/modules/private_api_recorder.js(1 hunks)test/package/browser/template/src/index-objects.ts(1 hunks)test/realtime/channel.test.js(1 hunks)test/realtime/objects.test.js(98 hunks)
🚧 Files skipped from review as they are similar to previous changes (11)
- scripts/moduleReport.ts
- src/plugins/objects/batchcontextlivecounter.ts
- src/plugins/objects/batchcontextlivemap.ts
- test/common/modules/private_api_recorder.js
- test/package/browser/template/src/index-objects.ts
- test/realtime/channel.test.js
- src/common/lib/transport/protocol.ts
- src/plugins/objects/index.ts
- src/plugins/objects/liveobject.ts
- src/plugins/objects/syncobjectsdatapool.ts
- ably.d.ts
🧰 Additional context used
🧬 Code Definitions (6)
src/common/lib/client/realtimechannel.ts (3)
src/plugins/objects/index.ts (1)
ObjectMessage(4-4)src/common/lib/types/protocolmessage.ts (1)
actions(17-39)ably.d.ts (1)
Message(2795-2856)
src/common/lib/types/protocolmessage.ts (3)
src/plugins/objects/index.ts (1)
ObjectMessage(4-4)test/realtime/objects.test.js (2)
Utils(12-12)MessageEncoding(13-13)src/common/lib/types/message.ts (1)
MessageEncoding(445-450)
test/realtime/objects.test.js (4)
src/plugins/objects/livemap.ts (1)
values(326-330)src/plugins/objects/batchcontextlivemap.ts (1)
values(43-47)test/realtime/channel.test.js (16)
helper(155-155)helper(175-175)helper(213-213)helper(240-240)helper(270-270)helper(308-308)helper(343-343)helper(384-384)helper(414-414)helper(448-448)helper(488-488)helper(510-510)helper(543-543)helper(606-606)helper(661-661)helper(692-692)src/common/lib/client/realtimechannel.ts (1)
objects(156-161)
src/plugins/objects/objects.ts (3)
src/plugins/objects/objectmessage.ts (1)
ObjectMessage(146-575)src/plugins/objects/livemap.ts (1)
LiveMap(54-832)src/plugins/objects/livecounter.ts (1)
LiveCounter(14-337)
src/plugins/objects/livecounter.ts (4)
src/plugins/objects/index.ts (2)
Objects(4-4)ObjectMessage(4-4)src/plugins/objects/objects.ts (1)
Objects(39-501)src/plugins/objects/objectmessage.ts (4)
ObjectState(118-141)ObjectOperation(82-115)ObjectMessage(146-575)CounterOp(47-50)src/plugins/objects/liveobject.ts (1)
LiveObjectUpdateNoop(18-22)
src/plugins/objects/livemap.ts (7)
src/plugins/objects/objectmessage.ts (5)
ObjectValue(23-23)ObjectData(26-36)ObjectOperation(82-115)ObjectMessage(146-575)MapOp(39-44)src/plugins/objects/liveobject.ts (2)
LiveObjectData(10-12)LiveObjectUpdateNoop(18-22)src/common/lib/client/realtimechannel.ts (1)
objects(156-161)src/plugins/objects/index.ts (2)
Objects(4-4)ObjectMessage(4-4)src/plugins/objects/objects.ts (1)
Objects(39-501)src/plugins/objects/livecounter.ts (1)
value(125-128)src/plugins/objects/syncobjectsdatapool.ts (1)
entries(36-38)
🪛 Biome (1.9.4)
src/plugins/objects/livecounter.ts
[error] 54-54: isFinite is unsafe. It attempts a type coercion. Use Number.isFinite instead.
See the MDN documentation for more details.
Unsafe fix: Use Number.isFinite instead.
(lint/suspicious/noGlobalIsFinite)
🪛 LanguageTool
README.md
[style] ~648-~648: Try using a synonym here to strengthen your writing.
Context: ... point for objects within a channel. It gives access to all other nested objects. ``...
(GIVE_PROVIDE)
[uncategorized] ~824-~824: It seems likely that a singular genitive (’s) apostrophe is missing.
Context: ...d synced events notify when the local Objects state on a client is being synchronized...
(AI_HYDRA_LEO_APOSTROPHE_S_XS)
[uncategorized] ~838-~838: Use a comma before ‘and’ if it connects two independent clauses (unless they are closely connected and short).
Context: ...g its data or trying to update its value and you should remove all references to the...
(COMMA_COMPOUND_SENTENCE)
🪛 markdownlint-cli2 (0.17.2)
README.md
650-650: Code block style
Expected: indented; Actual: fenced
(MD046, code-block-style)
777-777: Code block style
Expected: indented; Actual: fenced
(MD046, code-block-style)
840-840: Code block style
Expected: indented; Actual: fenced
(MD046, code-block-style)
⏰ Context from checks skipped due to timeout of 90000ms (6)
- GitHub Check: test-node (20.x)
- GitHub Check: test-browser (webkit)
- GitHub Check: test-node (18.x)
- GitHub Check: test-browser (firefox)
- GitHub Check: test-browser (chromium)
- GitHub Check: test-node (16.x)
🔇 Additional comments (169)
src/plugins/objects/batchcontext.ts (5)
7-7: Import updated successfully.The import has been correctly changed from
StateMessagetoObjectMessageand points to the renamed fileobjectmessage.ts, aligning with the PR objectives to replace "state" terminology with "objects".
13-13: Documentation comment updated properly.The comment has been updated to use "object ids" instead of "live object ids", maintaining consistency with the terminology updates specified in the PR objectives.
15-15: Type declaration updated correctly.The type for
_queuedMessageshas been properly changed fromStateMessage[]toObjectMessage[], consistent with the import change and PR objectives.
52-52: Error message terminology updated.The error message has been updated from "Unknown Live Object instance type" to "Unknown LiveObject instance type", removing the space between "Live" and "Object" to standardize the terminology.
88-89: Method renamed and parameter type updated.The method has been renamed from
queueStateMessageto the more genericqueueMessageand its parameter type updated fromStateMessagetoObjectMessage. The parameter name has also been changed fromstateMessagetomsgto reflect the more generic nature of the method.test/realtime/objects.test.js (8)
90-91: Function renamed to align with updated terminology.The
stateMessageFromValuesfunction has been renamed toobjectMessageFromValuesand now callsObjectsPlugin.ObjectMessage.fromValuesinstead ofStateMessage.fromValues, consistent with the terminology change from "state" to "objects".
114-114: Function renamed to align with updated terminology.Function renamed from
waitForStateOperationtowaitForObjectOperationto maintain consistency with the new object-based terminology.
672-673: Variable renamed to align with updated terminology.The array variable has been renamed from
stateSyncSequenceScenariostoobjectSyncSequenceScenariosto reflect the terminology update.
1111-1112: Test description updated to use "object" terminology.Test description updated to use "object ids" instead of "state ids" terminology, consistent with the PR's objectives.
1601-1601: Operation name updated to align with updated terminology.The operation name has been changed from
STATE_DELETEtoOBJECT_DELETEto maintain consistency across the API.
4520-4521: Section heading updated to align with updated terminology.The describe block has been updated to refer to "ObjectMessage message size" instead of "StateMessage message size".
4732-4739: Function calls updated to use ObjectMessage instead of StateMessage.Function calls have been updated to use
ObjectMessagerelated methods instead ofStateMessagerelated methods, including encode and getMessageSize.
4745-4746: Test description updated to use "Objects modes" terminology.Test description updated to use "Objects modes" instead of "States modes" terminology to maintain consistency.
README.md (8)
648-648: Consistent terminology change from 'state' to 'objects'The description now correctly refers to "objects" instead of "state" within the channel, consistent with the overall PR goal of updating terminology.
🧰 Tools
🪛 LanguageTool
[style] ~648-~648: Try using a synonym here to strengthen your writing.
Context: ... point for objects within a channel. It gives access to all other nested objects. ``...(GIVE_PROVIDE)
656-656: Approved header updateChanged from "Live Object Types" to "Object Types" to use more consistent terminology.
660-661: Revised description for LiveMapThe description now correctly states that LiveMap enables storing "other objects" instead of "other Live Objects", maintaining the terminology consistency.
692-693: Updated object storage explanationChanged to clarify that objects can be stored as well as primitive values, with improved wording.
775-776: Improved object creation descriptionUpdated to refer to "LiveMap and LiveCounter objects" rather than "instances", maintaining the consistent terminology.
824-825: Updated lifecycle events descriptionThe text now refers to "objects' lifecycle changes" instead of "Live Objects emit lifecycle events", focusing on the object-centric terminology.
🧰 Tools
🪛 LanguageTool
[uncategorized] ~824-~824: It seems likely that a singular genitive (’s) apostrophe is missing.
Context: ...dsyncedevents notify when the local Objects state on a client is being synchronized...(AI_HYDRA_LEO_APOSTROPHE_S_XS)
838-839: Improved object deletion descriptionThis documentation update maintains consistent terminology while providing the same information about deleted objects.
🧰 Tools
🪛 LanguageTool
[uncategorized] ~838-~838: Use a comma before ‘and’ if it connects two independent clauses (unless they are closely connected and short).
Context: ...g its data or trying to update its value and you should remove all references to the...(COMMA_COMPOUND_SENTENCE)
845-846: Simplified deletion event messageChanged from "Live Object has been deleted" to the simpler "Object has been deleted", maintaining terminology consistency.
test/common/modules/objects_helper.js (5)
3-5: Updated helper class documentationDocumentation now correctly refers to "objects tree" and "object messages" instead of "state tree" and "state messages", consistent with the terminology change.
239-253: Renamed method: stateOperationMessage → objectOperationMessageThe method has been renamed from
stateOperationMessagetoobjectOperationMessagewhile maintaining the same functionality. The action comment has been updated from "STATE" to "OBJECT".
255-264: Renamed method: stateObjectMessage → objectStateMessageThe method has been renamed from
stateObjectMessagetoobjectStateMessagewhile maintaining the same functionality. The action comment has been updated from "STATE_SYNC" to "OBJECT_SYNC".
266-279: Renamed method: processStateOperationMessageOnChannel → processObjectOperationMessageOnChannelThe method has been renamed from
processStateOperationMessageOnChanneltoprocessObjectOperationMessageOnChannelwhile maintaining the same functionality. It now references the renamedobjectOperationMessagefunction.
281-294: Renamed method: processStateObjectMessageOnChannel → processObjectStateMessageOnChannelThe method has been renamed from
processStateObjectMessageOnChanneltoprocessObjectStateMessageOnChannelwhile maintaining the same functionality. It now references the renamedobjectStateMessagefunction.src/common/lib/types/protocolmessage.ts (6)
37-38: Updated action names for consistencyChanged action names from "STATE" to "OBJECT" and "STATE_SYNC" to "OBJECT_SYNC" while preserving the original action codes (19 and 20).
53-53: Renamed flag for object detectionThe flag has been renamed from "HAS_STATE" to "HAS_OBJECTS" to maintain consistent terminology. The bit position (1 << 7) remains unchanged.
129-137: Updated variable type and message processingThe state variable type has been updated from
ObjectsPlugin.StateMessage[]toObjectsPlugin.ObjectMessage[]. The message processing logic now callsobjectsPlugin.ObjectMessage.fromValuesinstead ofStateMessage.fromValues.
146-147: Updated documentation commentThe documentation comment now correctly mentions "object messages" instead of "state messages" to maintain consistent terminology.
181-183: Updated message array handlingThe stringify method now calls
objectsPlugin.ObjectMessage.fromValuesArrayinstead ofStateMessage.fromValuesArray, maintaining consistent terminology for message handling.
222-222: Updated type definition for state propertyThe type of the
stateproperty in theProtocolMessageclass has been updated fromObjectsPlugin.StateMessage[]toObjectsPlugin.ObjectMessage[].src/common/lib/client/realtimechannel.ts (10)
33-33: Updated import typeChanged the import type from
StateMessagetoObjectMessagefrom the 'plugins/objects' module.
510-519: Renamed sendState parameter and actionThe
sendStatemethod now acceptsobjectMessages: ObjectMessage[]instead ofStateMessage[]and usesactions.OBJECTinstead ofactions.STATE. The functionality remains the same.
526-528: Updated message action checkChanged the condition to check for
actions.OBJECTinstead ofactions.STATEwhen processing messages, maintaining consistent terminology.
545-545: Renamed flag checkUpdated the flag check from
HAS_STATEtoHAS_OBJECTSwhen processing attached messages.
554-556: Updated objects callback with new parameter nameChanged the call to
this._objects.onAttachedto use the renamed parameterhasObjectsinstead ofhasState.
567-567: Updated notifyState callAdded the renamed parameter
hasObjectsto thenotifyStatemethod call, replacinghasState.
615-634: Renamed OBJECT and OBJECT_SYNC message processingThe message processing logic has been updated to handle
actions.OBJECTandactions.OBJECT_SYNCinstead ofSTATEandSTATE_SYNC. The object messages variable naming and method calls have been updated accordingly.
743-743: Updated generic type constraintChanged the generic type constraint in
_decodeAndPrepareMessagesfromT extends Message | PresenceMessage | StateMessagetoT extends Message | PresenceMessage | ObjectMessage.
812-812: Updated notifyState parameterAdded the renamed parameter
hasObjectsto thenotifyStatemethod definition, replacinghasState.
834-834: Updated actOnChannelState callChanged the call to
this._objects.actOnChannelStateto use the renamed parameterhasObjectsinstead ofhasState.src/plugins/objects/objects.ts (34)
10-10: Import change from StateMessage to ObjectMessage aligns with new terminology.The import has been updated to use
ObjectMessageandObjectOperationActioninstead of their state-based counterparts, which is consistent with the PR objective of replacing "state" terminology with "objects".
52-52: Variable name updated to match new terminology.The private member variable has been renamed from
_bufferedStateOperationsto_bufferedObjectOperationsto align with the new terminology.
65-65: Updated initialization of buffered operations.The initialization of the renamed variable
_bufferedObjectOperationsis consistent with the previous implementation.
76-76: Updated comment to use object terminology.The comment has been updated to reflect the new object-based terminology.
112-114: Updated variable names in createMap method.Variables have been renamed from
stateMessagetomsgand the property access has been updated to refer tooperation?.objectIdinstead of the previous state-based version.
115-115: Method call updated to use ObjectMessage array.The publish method now accepts
ObjectMessage[]instead ofStateMessage[].
124-127: Updated comment and object creation to use object terminology.The comment and object creation have been updated to use the term "object" instead of "state" and to call
LiveMap.fromObjectOperationinstead of the previous state-based method.
144-146: Updated variable names in createCounter method.Variables have been renamed from
stateMessagetomsgand the property access has been updated to refer tooperation?.objectIdinstead of the previous state-based version.
147-147: Method call updated to use ObjectMessage array.The publish method now accepts
ObjectMessage[]instead ofStateMessage[].
156-159: Updated comment and object creation to use object terminology.The comment and object creation have been updated to use the term "object" instead of "state" and to call
LiveCounter.fromObjectOperationinstead of the previous state-based method.
215-223: Method signature and parameter type updated.The method
handleObjectSyncMessagesnow acceptsObjectMessage[]instead ofStateMessage[].
222-222: Method call updated to use object terminology.The method call has been updated to use
applyObjectSyncMessagesinstead of the previous state-based method.
235-241: Method signature and comments updated.The method
handleObjectMessagesnow acceptsObjectMessage[]instead ofStateMessage[]. Comments have been updated to use the term "object" instead of "state".
245-245: Method call updated to use object terminology.The method call has been updated to use
_applyObjectMessagesinstead of the previous state-based method.
251-257: Method parameter updated and log message modified.The
onAttachedmethod parameter has been renamed fromhasStatetohasObjectsto align with the new terminology. The log message has been updated accordingly.
260-262: Updated comment to use object terminology.The comment has been updated to use the term
hasObjectsinstead of the previous state-based flag.
266-268: Updated comment regarding hasObjects flag.The comment has been updated to use the term
hasObjectsinstead of the previous state-based flag.
279-282: Method signature updated and method call modified.The
actOnChannelStatemethod now passeshasObjectsinstead ofhasStateto theonAttachedmethod.
296-296: Method signature updated for publish.The
publishmethod now acceptsObjectMessage[]instead ofStateMessage[].
305-307: Updated method calls to use ObjectMessage.The code now calls
ObjectMessage.encodeinstead of the previous state-based method and uses thegetMessageSizemethod on each object message.
310-310: Updated error message to use object terminology.The error message has been updated to use the term "object" instead of "state".
316-316: Method call updated to use sendState.The method call has been updated to use
sendStatewhich should be handling the newObjectMessage[]parameter.
336-337: Comment and variable initialization updated.The comment and variable initialization have been updated to use the term "object" instead of "state".
346-350: Updated comments regarding object operations.The comments have been updated to use the term "object" instead of "state".
348-348: Method call updated to use object terminology.The method call has been updated to use
_applyObjectMessagesinstead of the previous state-based method.
350-350: Variable initialization updated.The variable initialization has been updated to reset
_bufferedObjectOperationsinstead of the previous state-based variable.
388-389: Updated attribute reference for object state.The method now uses
objectStateinstead of the previous state-based attribute when overriding an existing object.
400-409: Updated references to LiveCounter and LiveMap factory methods.The code now calls
LiveCounter.fromObjectStateandLiveMap.fromObjectStateinstead of the previous state-based methods.
408-408: Updated error message to use object terminology.The error message has been updated to use the term "object" instead of "state".
414-414: Updated comment to use object terminology.The comment has been updated to use the term "object" instead of "state".
421-460: Method renamed and implementation updated.The method
_applyObjectMessages(previously_applyStateMessages) has been updated to handleObjectMessage[]instead ofStateMessage[]. The implementation has been updated to useobjectOperationandObjectOperationActioninstead of their state-based counterparts.
427-429: Updated method name in log message.The method name in the log message has been updated to use the new name
_applyObjectMessages.
448-450: Updated method call to check for existing object.The method call has been updated to use
createZeroValueObjectIfNotExistswith theobjectOperation.objectIdparameter.
456-458: Updated method name in log message.The method name in the log message has been updated to use the new name
_applyObjectMessages.src/plugins/objects/objectmessage.ts (34)
9-16: Enum renamed from StateOperationAction to ObjectOperationAction.The enum has been renamed to align with the new terminology, maintaining the same values and semantic meaning.
22-23: Type renamed from StateValue to ObjectValue.The type has been renamed to align with the new terminology, maintaining the same underlying types.
25-36: Interface renamed from StateData to ObjectData.The interface has been renamed to align with the new terminology, with updated documentation that clarifies its role in representing values in an object on a channel.
38-44: Interface renamed from StateMapOp to MapOp.The interface has been renamed to align with the new terminology, maintaining the same properties and semantic meaning.
46-50: Interface renamed from StateCounterOp to CounterOp.The interface has been renamed to align with the new terminology, maintaining the same properties and semantic meaning.
53-65: Interface renamed from StateMapEntry to MapEntry.The interface has been renamed to align with the new terminology, maintaining the same properties while updating the references to use
ObjectDatainstead ofStateData.
67-73: Interface renamed from StateMap to ObjectMap.The interface has been renamed to align with the new terminology, maintaining the same properties while updating the references to use
MapEntryinstead ofStateMapEntry.
75-79: Interface renamed from StateCounter to ObjectCounter.The interface has been renamed to align with the new terminology, maintaining the same properties and semantic meaning.
81-115: Interface renamed from StateOperation to ObjectOperation.The interface has been renamed to align with the new terminology, with updated documentation and property types referring to the renamed interfaces and enums.
117-141: Interface renamed from StateObject to ObjectState.The interface has been renamed to align with the new terminology, with updated documentation and property types referring to the renamed interfaces and enums.
146-168: Class renamed from StateMessage to ObjectMessage with updated properties.The class has been renamed to align with the new terminology. Property documentation has been updated to refer to "object" instead of "state", and property types have been updated to use the new interfaces.
181-196: Static method updated to handle ObjectMessage.The
encodemethod has been updated to work withObjectMessageand to call_encodeObjectOperationand_encodeObjectStatemethods.
203-228: Decode method updated to work with ObjectMessage.The
decodemethod has been updated to handleObjectMessageand to call methods with the "object" prefix instead of the "state" prefix.
230-236: Static factory method updated to create ObjectMessage.The
fromValuesmethod has been updated to create an instance ofObjectMessageinstead ofStateMessage.
238-251: Static factory method for arrays updated.The
fromValuesArraymethod has been updated to work withObjectMessageinstead ofStateMessage.
253-287: Static method for encoding initial values updated.The
encodeInitialValuemethod has been updated to work withObjectOperationinstead ofStateOperation, and the comment has been updated to use the term "object" instead of "state".
289-297: Helper method updated to work with MapEntry.The
_decodeMapEntriesmethod has been updated to work withMapEntryinstead ofStateMapEntry.
299-315: Helper method renamed and updated.The
_decodeStateDatamethod has been renamed to_decodeObjectDataand updated to work withObjectDatainstead ofStateData.
317-341: Helper method renamed and updated.The
_encodeStateOperationmethod has been renamed to_encodeObjectOperationand updated to work withObjectOperationinstead ofStateOperation. References to attributes and methods have been updated accordingly.
343-361: Helper method renamed and updated.The
_encodeStateObjectmethod has been renamed to_encodeObjectStateand updated to work withObjectStateinstead ofStateObject. References to attributes and methods have been updated accordingly.
363-371: Helper method renamed and updated.The
_encodeStateDatamethod has been renamed to_encodeObjectDataand updated to work withObjectDatainstead ofStateData.
373-407: Private method updated to work with ObjectMessage.The
_encodeForWireProtocolmethod has been updated to work withObjectMessageinstead ofStateMessageand to returnObjectOperationandObjectStatetypes instead of their state-based counterparts.
416-436: toJSON method updated to return object-based properties.The
toJSONmethod has been updated to returnoperationandobjectproperties instead of their state-based counterparts.
438-457: toString method updated to reference ObjectMessage.The
toStringmethod has been updated to use the class nameObjectMessageand to reference theoperationandobjectproperties.
459-474: getMessageSize method updated to work with object-based properties.The
getMessageSizemethod has been updated to check for and calculate sizes based onoperationandobjectproperties.
476-493: Helper method renamed.The
_getStateOperationSizemethod has been renamed to_getObjectOperationSizeand updated to call methods with the "object" prefix instead of the "state" prefix.
495-509: Helper method renamed.The
_getStateObjectSizemethod has been renamed to_getObjectStateSizeand updated to call methods with the "object" prefix instead of the "state" prefix.
511-522: Helper method renamed.The
_getStateMapSizemethod has been renamed to_getObjectMapSizeand updated to call methods with the "map" prefix instead of the "state" prefix.
524-530: Helper method renamed.The
_getStateCounterSizemethod has been renamed to_getObjectCounterSize.
532-540: Helper method renamed to work with MapEntry.The
_getStateMapEntrySizemethod has been renamed to_getMapEntrySizeand updated to call methods with the "object" prefix instead of the "state" prefix.
542-552: Helper method renamed.The
_getStateMapOpSizemethod has been renamed to_getMapOpSizeand updated to call methods with the "object" prefix instead of the "state" prefix.
554-560: Helper method renamed.The
_getStateCounterOpSizemethod has been renamed to_getCounterOpSize.
562-570: Helper method renamed.The
_getStateDataSizemethod has been renamed to_getObjectDataSizeand updated to call methods with the "object" prefix instead of the "state" prefix.
572-574: Helper method renamed.The
_getStateValueSizemethod has been renamed to_getObjectValueSize.src/plugins/objects/livecounter.ts (22)
3-3: Updated imports to use object-based types.The import statement has been updated to use the new object-based type names (
CounterOp,ObjectMessage,ObjectOperation,ObjectOperationAction,ObjectState) instead of their state-based counterparts.
24-33: Method renamed from fromStateObject to fromObjectState.The method has been renamed to align with the new terminology, and its parameters and implementation have been updated accordingly.
36-46: Method renamed from fromStateOperation to fromObjectOperation.The method has been renamed to align with the new terminology, and its parameters and implementation have been updated accordingly.
51-71: Method updated to create ObjectMessage instead of StateMessage.The
createCounterIncMessagemethod has been updated to create anObjectMessagewith anObjectOperationinstead of aStateMessagewith aStateOperation.🧰 Tools
🪛 Biome (1.9.4)
[error] 54-54: isFinite is unsafe. It attempts a type coercion. Use Number.isFinite instead.
See the MDN documentation for more details.
Unsafe fix: Use Number.isFinite instead.(lint/suspicious/noGlobalIsFinite)
76-112: Method updated to create ObjectMessage instead of StateMessage.The
createCounterCreateMessagemethod has been updated to create anObjectMessagewith anObjectOperationinstead of aStateMessagewith aStateOperation. The method now returns a Promise ofObjectMessageinstead of a Promise ofStateMessage.
117-123: Method return type updated.The
createInitialValueObjectmethod now returns aPick<ObjectOperation, 'counter'>instead of the previous state-based type.
141-143: Method implementations updated to use ObjectMessage.The
incrementmethod has been updated to use the newcreateCounterIncMessagemethod that returns anObjectMessage, and to pass an array ofObjectMessageto thepublishmethod.
162-220: Method signature and implementation updated.The
applyOperationmethod now acceptsObjectOperationandObjectMessageparameters instead of their state-based counterparts. The switch-case structure has been updated to handleObjectOperationActionenum values.
165-166: Updated error message to use object terminology.The error message has been updated to use the term "object" instead of "state".
225-232: Method renamed from overrideWithStateObject to overrideWithObjectState.The method has been renamed to align with the new terminology, and its parameter type has been updated from
StateObjecttoObjectState.
228-229: Updated error message to use object terminology.The error message has been updated to use the term "object" instead of "state".
234-242: Updated reference checks for createOp.The code now checks for the existence of
objectState.createOpinstead of the previous state-based field.
238-239: Updated error message to use object terminology.The error message has been updated to use the term "object" instead of "state".
244-250: Updated action check to use ObjectOperationAction.The code now checks for
ObjectOperationAction.COUNTER_CREATEinstead of the previous state-based action.
246-247: Updated error message to use object terminology.The error message has been updated to use the term "object" instead of "state".
254-256: Updated comment and parameter reference.The comment has been updated to use the term "object" instead of "state", and the code now references
objectState.siteTimeserialsinstead of the previous state-based field.
263-272: Updated tombstone checking logic.The code now checks for
objectState.tombstoneinstead of the previous state-based field, and updates the data reference withobjectState.counter?.countinstead of the previous state-based field.
276-276: Updated comment to use object terminology.The comment has been updated to use the term "object" instead of "state".
297-306: Method parameter type updated.The
_mergeInitialDataFromCreateOperationmethod now accepts anObjectOperationparameter instead of aStateOperation. The implementation has been updated to referenceobjectOperation.counter?.countinstead of the previous state-based field.
308-314: Method parameter type updated.The
_throwNoPayloadErrormethod now accepts anObjectOperationparameter instead of aStateOperation.
316-331: Method parameter type updated.The
_applyCounterCreatemethod now accepts anObjectOperationparameter instead of aStateOperation.
333-336: Method parameter type updated.The
_applyCounterIncmethod now accepts aCounterOpparameter instead of aStateCounterOp.src/plugins/objects/livemap.ts (37)
7-18: Updated imports to use object-based types.The import statement has been updated to use the new object-based type names and includes a more organized list of imports with
ObjectMessage,ObjectOperation,ObjectOperationAction,ObjectState, andObjectValuereplacing their state-based counterparts.
19-34: Interface renamed from StateIdObjectData to ObjectIdObjectData.The interface has been renamed to align with the new terminology, with updated documentation about its role in supporting composable object structures.
24-32: Interface renamed from ValueStateData to ValueObjectData.The interface has been renamed to align with the new terminology, with updated documentation about its role in representing concrete values in the object graph.
34-34: Type definition updated.The
ObjectDatatype has been updated to be a union ofObjectIdObjectDataandValueObjectDatainstead of their state-based counterparts.
36-44: Interface renamed from MapEntry to LiveMapEntry.The interface has been renamed to avoid confusion with the
MapEntryinterface fromobjectmessage.ts, and itsdataproperty has been updated to referenceObjectDatainstead of the previous state-based type.
47-47: Interface property type updated.The
dataproperty ofLiveMapDatahas been updated to useLiveMapEntryinstead of the previousMapEntry.
72-82: Method renamed from fromStateObject to fromObjectState.The method has been renamed to align with the new terminology, and its parameters have been updated to use
ObjectStateinstead of the previous state-based type.
84-97: Method renamed from fromStateOperation to fromObjectOperation.The method has been renamed to align with the new terminology, and its parameters have been updated to use
ObjectOperationinstead of the previous state-based type.
102-133: Method updated to return ObjectMessage instead of StateMessage.The
createMapSetMessagemethod has been updated to return anObjectMessageinstead of aStateMessage. The method creates an operation withObjectOperationAction.MAP_SETand constructs object data as eitherObjectIdObjectDataorValueObjectDatabased on the value type.
138-162: Method updated to return ObjectMessage instead of StateMessage.The
createMapRemoveMessagemethod has been updated to return anObjectMessageinstead of aStateMessage. The method creates an operation withObjectOperationAction.MAP_REMOVE.
192-230: Method updated to return a Promise of ObjectMessage.The
createMapCreateMessagemethod has been updated to return a Promise ofObjectMessageinstead of a Promise ofStateMessage. The method creates an operation withObjectOperationAction.MAP_CREATE.
196-197: Updated error message wording.Refined the error message for clarity, changing the term "should be" to "should be a" to improve grammar.
235-255: Method return type updated.The
createInitialValueObjectmethod now returns aPick<ObjectOperation, 'map'>instead of the previous state-based type. The method constructs map entries using the new object data types.
263-266: Updated method documentation.The documentation for the
getmethod has been updated to use the term "objectId" instead of the previous state-based terminology.
286-286: Updated method call.The method call has been updated to use
_getResolvedValueFromObjectDatainstead of the previous state-based method.
315-315: Updated method call.The method call has been updated to use
_getResolvedValueFromObjectDatainstead of the previous state-based method.
343-345: Method calls updated to use ObjectMessage.The
setmethod has been updated to callcreateMapSetMessagewhich returns anObjectMessage, and to pass an array ofObjectMessageto thepublishmethod.
358-360: Method calls updated to use ObjectMessage.The
removemethod has been updated to callcreateMapRemoveMessagewhich returns anObjectMessage, and to pass an array ofObjectMessageto thepublishmethod.
365-433: Method signature and implementation updated.The
applyOperationmethod now acceptsObjectOperationandObjectMessageparameters instead of their state-based counterparts. The switch-case structure has been updated to handleObjectOperationActionenum values.
368-369: Updated error message to use object terminology.The error message has been updated to use the term "object" instead of "state".
438-452: Method renamed from overrideWithStateObject to overrideWithObjectState.The method has been renamed to align with the new terminology, and its parameter type has been updated from
StateObjecttoObjectState. The error message has been updated accordingly.
455-480: Updated createOp validation.The code now checks for the existence and validity of
objectState.createOpinstead of the previous state-based field. Error messages have been updated to use object terminology.
483-485: Updated comment and site timeserials reference.The comment has been updated to use the term "object" instead of "state", and the code now references
objectState.siteTimeserialsinstead of the previous state-based field.
492-501: Updated tombstone checking and data override logic.The code now checks for
objectState.tombstoneinstead of the previous state-based field, and updates the data reference with the result of_liveMapDataFromMapEntries(objectState.map?.entries ?? {})instead of the previous state-based field.
504-506: Updated comment to use object terminology.The comment has been updated to use the term "object" instead of "state".
526-526: Updated data initialization.The
_getZeroValueDatamethod now initializes a Map withLiveMapEntryinstead of the previousMapEntry.
583-617: Method parameter type updated.The
_mergeInitialDataFromCreateOperationmethod now accepts anObjectOperationparameter instead of aStateOperation. The implementation has been updated to check forobjectOperation.mapinstead of the previous state-based field.
619-625: Method parameter type updated.The
_throwNoPayloadErrormethod now accepts anObjectOperationparameter instead of aStateOperation.
627-650: Method parameter type updated.The
_applyMapCreatemethod now accepts anObjectOperationparameter instead of aStateOperation.
652-702: Method parameter types updated.The
_applyMapSetmethod now accepts aMapOpparameter instead of aStateMapOp. The implementation constructsObjectDataas eitherObjectIdObjectDataorValueObjectDataand aLiveMapEntryinstead of the previous state-based types.
669-670: Updated error message to use object terminology.The error message has been updated to use the term "object" instead of "state".
704-733: Method parameter types updated.The
_applyMapRemovemethod now accepts aMapOpparameter instead of aStateMapOp. The implementation constructs aLiveMapEntryinstead of the previous state-based type.
763-789: Method parameter type updated.The
_liveMapDataFromMapEntriesmethod now accepts aRecord<string, MapEntry>parameter instead of the previous state-based type. The implementation constructsObjectDataas eitherObjectIdObjectDataorValueObjectDataand aLiveMapEntryinstead of the previous state-based types.
791-812: Method renamed and updated.The
_getResolvedValueFromStateDatamethod has been renamed to_getResolvedValueFromObjectDataand updated to accept anObjectDataparameter instead of aStateData. The implementation has been updated to check for the'value'property in the data object.
796-797: Updated comment for clarity.The comment has been enhanced to clearly state that the object data stores a primitive type value.
800-800: Updated comment to use object terminology.The comment has been updated to use the term "object" instead of "state".
814-831: Method parameter type updated.The
_isMapEntryTombstonedmethod now accepts aLiveMapEntryparameter instead of aMapEntry.
6f8d1d0 to
06591f2
Compare
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: 0
🧹 Nitpick comments (2)
README.md (1)
838-839: Suggestion: Add a comma for better readability.Consider adding a comma before "and" in the sentence to separate the independent clauses for better readability.
-and you should remove all references to the deleted object in your application. +and you should remove all references to the deleted object in your application.🧰 Tools
🪛 LanguageTool
[uncategorized] ~838-~838: Use a comma before ‘and’ if it connects two independent clauses (unless they are closely connected and short).
Context: ...g its data or trying to update its value and you should remove all references to the...(COMMA_COMPOUND_SENTENCE)
src/plugins/objects/livecounter.ts (1)
54-56: Consider using Number.isFinite() instead of isFinite().The
isFinite()function performs type coercion which can lead to unexpected behavior. UsingNumber.isFinite()would be safer as it doesn't attempt to convert non-number values.- if (typeof amount !== 'number' || !isFinite(amount)) { + if (typeof amount !== 'number' || !Number.isFinite(amount)) {🧰 Tools
🪛 Biome (1.9.4)
[error] 54-54: isFinite is unsafe. It attempts a type coercion. Use Number.isFinite instead.
See the MDN documentation for more details.
Unsafe fix: Use Number.isFinite instead.(lint/suspicious/noGlobalIsFinite)
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro (Legacy)
📒 Files selected for processing (21)
README.md(8 hunks)ably.d.ts(11 hunks)scripts/moduleReport.ts(1 hunks)src/common/lib/client/realtimechannel.ts(9 hunks)src/common/lib/transport/protocol.ts(1 hunks)src/common/lib/types/protocolmessage.ts(6 hunks)src/plugins/objects/batchcontext.ts(3 hunks)src/plugins/objects/batchcontextlivecounter.ts(1 hunks)src/plugins/objects/batchcontextlivemap.ts(1 hunks)src/plugins/objects/index.ts(1 hunks)src/plugins/objects/livecounter.ts(10 hunks)src/plugins/objects/livemap.ts(27 hunks)src/plugins/objects/liveobject.ts(4 hunks)src/plugins/objects/objectmessage.ts(13 hunks)src/plugins/objects/objects.ts(17 hunks)src/plugins/objects/syncobjectsdatapool.ts(2 hunks)test/common/modules/objects_helper.js(3 hunks)test/common/modules/private_api_recorder.js(1 hunks)test/package/browser/template/src/index-objects.ts(2 hunks)test/realtime/channel.test.js(1 hunks)test/realtime/objects.test.js(101 hunks)
🚧 Files skipped from review as they are similar to previous changes (13)
- src/common/lib/transport/protocol.ts
- test/package/browser/template/src/index-objects.ts
- src/plugins/objects/batchcontextlivemap.ts
- src/plugins/objects/batchcontextlivecounter.ts
- test/realtime/channel.test.js
- src/plugins/objects/index.ts
- test/common/modules/private_api_recorder.js
- scripts/moduleReport.ts
- test/common/modules/objects_helper.js
- src/plugins/objects/syncobjectsdatapool.ts
- src/common/lib/client/realtimechannel.ts
- src/plugins/objects/liveobject.ts
- ably.d.ts
🧰 Additional context used
🧬 Code Graph Analysis (6)
src/common/lib/types/protocolmessage.ts (3)
src/plugins/objects/index.ts (1)
ObjectMessage(4-4)test/realtime/objects.test.js (2)
Utils(12-12)MessageEncoding(13-13)src/common/lib/types/message.ts (1)
MessageEncoding(445-450)
src/plugins/objects/batchcontext.ts (3)
src/plugins/objects/batchcontextlivecounter.ts (1)
BatchContextLiveCounter(6-41)src/plugins/objects/batchcontextlivemap.ts (1)
BatchContextLiveMap(7-62)src/plugins/objects/objectmessage.ts (1)
ObjectMessage(146-575)
src/plugins/objects/objects.ts (3)
src/plugins/objects/objectmessage.ts (1)
ObjectMessage(146-575)src/plugins/objects/livemap.ts (1)
LiveMap(54-832)src/plugins/objects/livecounter.ts (1)
LiveCounter(14-337)
test/realtime/objects.test.js (6)
src/plugins/objects/livemap.ts (1)
values(326-330)src/plugins/objects/batchcontextlivemap.ts (1)
values(43-47)test/realtime/channel.test.js (20)
helper(155-155)helper(175-175)helper(213-213)helper(240-240)helper(270-270)helper(308-308)helper(343-343)helper(384-384)helper(414-414)helper(448-448)helper(488-488)helper(510-510)helper(543-543)helper(606-606)helper(661-661)helper(692-692)channel(1830-1830)channel(1851-1851)channel(1875-1875)channel(1915-1915)src/common/lib/client/realtimechannel.ts (1)
objects(156-161)src/plugins/objects/livecounter.ts (1)
value(125-128)src/plugins/objects/batchcontextlivecounter.ts (1)
value(17-21)
src/plugins/objects/livecounter.ts (2)
src/plugins/objects/objects.ts (1)
Objects(39-501)src/plugins/objects/objectmessage.ts (4)
ObjectState(118-141)ObjectOperation(82-115)ObjectMessage(146-575)CounterOp(47-50)
src/plugins/objects/livemap.ts (3)
src/plugins/objects/objectmessage.ts (5)
ObjectValue(23-23)ObjectData(26-36)ObjectOperation(82-115)ObjectMessage(146-575)MapOp(39-44)src/plugins/objects/index.ts (2)
Objects(4-4)ObjectMessage(4-4)src/plugins/objects/objects.ts (1)
Objects(39-501)
🪛 Biome (1.9.4)
src/plugins/objects/livecounter.ts
[error] 54-54: isFinite is unsafe. It attempts a type coercion. Use Number.isFinite instead.
See the MDN documentation for more details.
Unsafe fix: Use Number.isFinite instead.
(lint/suspicious/noGlobalIsFinite)
🪛 LanguageTool
README.md
[style] ~648-~648: Try using a synonym here to strengthen your writing.
Context: ... point for objects within a channel. It gives access to all other nested objects. ``...
(GIVE_PROVIDE)
[uncategorized] ~838-~838: Use a comma before ‘and’ if it connects two independent clauses (unless they are closely connected and short).
Context: ...g its data or trying to update its value and you should remove all references to the...
(COMMA_COMPOUND_SENTENCE)
🪛 markdownlint-cli2 (0.17.2)
README.md
650-650: Code block style
Expected: indented; Actual: fenced
(MD046, code-block-style)
777-777: Code block style
Expected: indented; Actual: fenced
(MD046, code-block-style)
840-840: Code block style
Expected: indented; Actual: fenced
(MD046, code-block-style)
⏰ Context from checks skipped due to timeout of 90000ms (6)
- GitHub Check: test-node (20.x)
- GitHub Check: test-browser (webkit)
- GitHub Check: test-node (18.x)
- GitHub Check: test-browser (firefox)
- GitHub Check: test-browser (chromium)
- GitHub Check: test-node (16.x)
🔇 Additional comments (107)
src/plugins/objects/batchcontext.ts (5)
7-7: Updated import to align with new terminologyThe import has been correctly updated from
StateMessagetoObjectMessagewhich aligns with the PR objectives to replace internal usage of 'state' term with 'objects' in the LiveObjects implementation.
13-13: Updated documentation comment for improved terminology consistencyThe comment has been appropriately updated from "live object ids" to "object ids", which aligns with the terminology changes outlined in the PR objectives.
15-15: Updated type annotation to match new message typeThe type annotation has been correctly changed from
StateMessage[]toObjectMessage[]to be consistent with the terminology changes and the imported type.
52-52: Updated error message with consistent terminologyThe error message has been updated from "Live Object" to "LiveObject" to standardize the naming convention throughout the codebase.
88-89: Renamed method to align with new message typeThe method has been appropriately renamed from
queueStateMessage(stateMessage: StateMessage)toqueueMessage(msg: ObjectMessage)which not only aligns with the new terminology but also makes the method name more generic and descriptive of its purpose.Based on the code snippets from related files, this change appears consistent with how the method is used in
BatchContextLiveCounterandBatchContextLiveMapclasses.test/realtime/objects.test.js (19)
90-92: Function rename fromstateMessageFromValuestoobjectMessageFromValuesaligns with PR objectives.The function name has been updated to reflect the terminology change from "state" to "object". This is consistent with the PR goals of replacing internal usage of 'state' term with 'objects' for LiveObjects.
114-136: Function renamed fromwaitForStateOperationtowaitForObjectOperationwhile preserving functionality.The function has been properly renamed, however the internal implementation still references
message.state[0]?.operation?.action. This appears to be intentional as the underlying protocol message structure still maintains thestateproperty. This matches the pattern seen throughout the codebase where function names are updated but the protocol message structure remains the same.
182-211: Test case updated to reference OBJECT ProtocolMessage.The test description and comments have been appropriately updated to use "OBJECT" terminology instead of "STATE". This is consistent with the PR's goal of updating terminology.
214-247: Test case updated to reference OBJECT_SYNC ProtocolMessage.Both the test description and comments have been properly updated to use "OBJECT_SYNC" terminology instead of "STATE_SYNC", which aligns with the PR objectives.
276-290: Test case terminology updated to reference "LiveObject".This test case properly uses the new terminology, referring to "LiveObject" and "object id" rather than previous "state" terminology.
293-306: Test case terminology updated to reference "objects".The test description has been updated to refer to "objects" instead of "states" which is consistent with the PR objectives.
309-335: Test case updated to reference OBJECT_SYNC sequence.The test description and assertions have been properly updated to use "OBJECT_SYNC" terminology, which aligns with the PR objectives for consistent naming.
338-361: Test correctly renamed to reference OBJECT_SYNC sequence completion.The test description and related comments have been updated from STATE_SYNC to OBJECT_SYNC, which is consistent with the terminology changes in the PR.
364-418: Test case for OBJECT_SYNC with empty cursor properly renamed.The test description, comments, and assertions have been correctly updated to use the new "OBJECT_SYNC" terminology, maintaining consistency with the PR objectives.
423-481: Test renamed to reference building object tree from OBJECT_SYNC sequence.The test description and assertions have been updated to use the "object" and "OBJECT_SYNC" terminology, which is consistent with the PR changes.
486-514: Test case properly updated to reference OBJECT_SYNC initialization.The test description has been changed to reference "OBJECT_SYNC" instead of "STATE_SYNC", maintaining consistency with the terminology changes.
659-762: Scenario tests for OBJECT_SYNC updated with proper terminology.The scenario descriptions and assertions have been updated to use "OBJECT_SYNC", "object state", and "tombstone" terminology consistently throughout the test cases.
767-819: OBJECT_SYNC scenario with subscription callback properly renamed.The test description, comments, and expected update object have been correctly updated to use the new terminology, including the reference to "OBJECT_SYNC" and related assertions.
1783-1790: Counter subscription update format updated consistently.The expected update format for counter subscription callbacks after OBJECT_DELETE operations has been maintained consistently. The update object format matches other similar counter operations in the codebase.
1934-1963: Test for object operation buffering during OBJECT_SYNC properly renamed.The test description, comments, and assertions have been updated to use "object operation" and "OBJECT_SYNC" terminology consistently.
2734-2743: Parameter renamed from stateMessages to objectMessages.The publish function parameter has been updated to use
objectMessagesinstead of what was likelystateMessagesbefore, which is consistent with the PR objectives of updating terminology.
4460-4502: Test for object message publish constraints updated.The test description and error message have been updated to use "object messages" terminology, which is consistent with the PR changes.
4504-4725: ObjectMessage size test section properly renamed.The describe section for message size tests has been updated to reference "ObjectMessage" rather than "StateMessage", and all test cases have been updated to use the new
objectMessageFromValuesfunction instead of the previous state-based function.
4729-4745: Test for channel attachment with Object modes uses correct terminology.The test correctly references "Objects modes" rather than "State modes", maintaining consistency with the terminology changes in the PR.
README.md (7)
648-648: LGTM! Updated terminology for clarity.The change from "Live Objects" to "objects" clarifies that this is referring to the general instance being accessed rather than the feature name.
🧰 Tools
🪛 LanguageTool
[style] ~648-~648: Try using a synonym here to strengthen your writing.
Context: ... point for objects within a channel. It gives access to all other nested objects. ``...(GIVE_PROVIDE)
660-661: LGTM! Clear and consistent terminology.Updating "Live Objects" to "objects" in the description of LiveMap maintains consistency throughout the documentation while preserving the technical accuracy of what's being stored.
750-750: Minor improvement in representation of update details.This line change follows the standardization pattern of replacing "state" terminology with "object" terminology.
754-754: Consistent terminology update.The terminology change in the example output maintains consistency with the rest of the documentation.
775-776: LGTM! Improved wording in documentation.The change from "Live Map and LiveCounter instances" to "LiveMap and LiveCounter objects" is more consistent with the object-oriented terminology being adopted throughout the codebase.
822-823: LGTM! More accurate event description.The revised description more accurately portrays the relationship between objects and lifecycle events, focusing on monitoring changes rather than emission.
845-845: LGTM! Simplified message text.The simplified deletion message is clear and consistent with the object-oriented terminology.
src/common/lib/types/protocolmessage.ts (6)
37-38: LGTM! Updated message action constants for consistency.The renaming from
STATEtoOBJECTandSTATE_SYNCtoOBJECT_SYNCaligns with the PR objectives to update terminology from state-based to object-based.
53-53: LGTM! Updated flag name with plural form.The flag has been renamed from
HAS_STATEtoHAS_OBJECTS(note the plural form), which aligns with the suggestion in the PR comments for consistency.
129-137: LGTM! Updated state message handling to object message handling.The type declaration and handling logic have been properly updated to use
ObjectMessageinstead ofStateMessage. The function still maintains the same functionality with the updated types.
146-147: LGTM! Updated comment to reflect object terminology.The comment has been updated to correctly refer to "object messages" instead of "state messages".
181-182: LGTM! Updated object property access in stringify method.The property access in the string concatenation has been updated to use the
ObjectMessageclass correctly.
222-222: LGTM! Updated type definition in ProtocolMessage class.The type of the
stateproperty has been updated toObjectMessage[]to match the renamed type.src/plugins/objects/objects.ts (17)
10-10: LGTM! Updated import statement.Import statement has been updated to use the new type names
ObjectMessageandObjectOperationAction.
52-53: LGTM! Updated private member variable name.Renamed from
_bufferedStateOperationsto_bufferedObjectOperationsto maintain consistency with the new terminology.
112-114: LGTM! Updated variable naming in createMap method.Changed from
stateMessagetomsgand updated property access to work with the newObjectMessagetype.
144-146: LGTM! Updated variable naming in createCounter method.Changed from
stateMessagetomsgand updated property access to work with the newObjectMessagetype.
215-215: LGTM! Renamed method for consistency.Method
handleStateSyncMessageshas been renamed tohandleObjectSyncMessagesto reflect the new terminology.
235-242: LGTM! Updated method and comments for handling object messages.The method has been renamed from
handleStateMessagestohandleObjectMessagesand all comments have been updated to refer to "object messages" instead of "state messages".
251-257: LGTM! Updated parameter name in onAttached method.The parameter has been renamed from
hasStatetohasObjectsto match the renamed flagHAS_OBJECTS.
260-262: LGTM! Updated comments for clarity.Comments have been updated to refer to the
HAS_OBJECTSflag instead of the previousHAS_STATEflag.
266-268: LGTM! Updated condition and comments.The condition and comments have been updated to check for the absence of the
hasObjectsflag.
279-283: LGTM! Updated parameter name in actOnChannelState method.The parameter has been renamed from
hasStatetohasObjectsto match the flag rename.
296-306: LGTM! Updated publish method signature and type usage.The method signature now accepts
ObjectMessage[]instead ofStateMessage[]and correctly uses theObjectMessage.encodemethod.
307-311: LGTM! Updated error message terminology.Error message text has been updated to use "object messages" instead of "state messages".
336-338: LGTM! Updated comment and buffer reset.Comment and buffer reset have been updated to use the new buffer name
_bufferedObjectOperations.
347-351: LGTM! Updated method call and comments.Method call has been updated to use
_applyObjectMessagesinstead of_applyStateMessagesand comments have been updated to mention object operations.
421-430: LGTM! Updated method name and implementation.Method has been renamed from
_applyStateMessagesto_applyObjectMessagesand implementation updated to work withObjectMessageand handle operation fields correctly.
433-458: LGTM! Updated switch statement to use ObjectOperationAction.Switch statement now uses the renamed enum
ObjectOperationActionfor case statements and log messages have been updated accordingly.
316-316:Details
❓ Verification inconclusive
Verify the method name of
sendState.The method name
sendStatestill contains "state" terminology while acceptingobjectMessages. Verify whether this method should also be renamed for consistency or if it's intentionally kept as is.
🏁 Script executed:
#!/bin/bash # Search for the sendState method definition to see if it should be renamed rg -A 3 'sendState\(' --type tsLength of output: 573
Action Required: Confirm Consistency of Method Naming
The
sendStatemethod is defined in bothsrc/plugins/objects/objects.tsandsrc/common/lib/client/realtimechannel.ts, where it accepts an array ofobjectMessagesand dispatches an action (actions.OBJECT). This introduces a potential naming mismatch, as "state" suggests a broader context, yet the payload specifically deals with object messages. Please verify whether the method name is intentionally retained assendState(perhaps as a legacy reference) or if the method should be renamed (e.g., tosendObjects) for better semantic clarity.
- Location:
- File:
src/plugins/objects/objects.ts, line 316- File:
src/common/lib/client/realtimechannel.ts(definition)src/plugins/objects/objectmessage.ts (24)
9-16: LGTM! Renamed enum for consistency.Renamed from
StateOperationActiontoObjectOperationActionto align with the new terminology.
22-23: LGTM! Renamed type and updated documentation.
StateValuehas been renamed toObjectValuewith updated JSDoc comment.
25-36: LGTM! Renamed interface and updated documentation.
StateDatahas been renamed toObjectDatawith thorough updates to the documentation comments.
38-44: LGTM! Renamed interface and updated documentation.
StateMapOphas been renamed toMapOpwith updated property type references.
46-50: LGTM! Renamed interface and updated documentation.
StateCounterOphas been renamed toCounterOpwith consistent documentation.
53-65: LGTM! Renamed interface and updated property type.
StateMapEntryhas been renamed toMapEntryand the data property type updated toObjectData.
67-73: LGTM! Renamed interface and updated documentation.
StateMaphas been renamed toObjectMapwith updated property types forentries.
75-79: LGTM! Renamed interface and updated documentation.
StateCounterhas been renamed toObjectCounterwith consistent documentation.
81-115: LGTM! Renamed interface and updated all property types.
StateOperationhas been renamed toObjectOperationwith all property types updated to use the new type names.
117-141: LGTM! Renamed interface and updated all property types.
StateObjecthas been renamed toObjectStatewith all property types and documentation updated accordingly.
146-169: LGTM! Renamed class and updated property types and documentation.Class has been renamed from
StateMessagetoObjectMessagewith thorough updates to property types and documentation.
176-197: LGTM! Updated method documentation and implementation.The
encodemethod's documentation and implementation have been updated to work withObjectMessage.
203-228: LGTM! Updated method parameter type.The
decodemethod's parameter type has been updated fromStateMessagetoObjectMessage.
230-236: LGTM! Updated static method signatures.The
fromValuesstatic method signatures have been updated to useObjectMessagetype.
238-251: LGTM! Updated static method signatures.The
fromValuesArraystatic method signatures have been updated to useObjectMessagetype.
253-287: LGTM! Updated method implementation for object terminology.The method implementation has been updated to use terms like "object message" instead of "state message".
290-297: LGTM! Updated method parameter types.Method parameter types have been updated from
StateMapEntrytoMapEntry.
299-315: LGTM! Renamed method and updated parameter types.Method has been renamed from
_decodeStateDatato_decodeObjectDatawith updated parameter types.
317-341: LGTM! Renamed method and updated implementation.Method has been renamed from
_encodeStateOperationto_encodeObjectOperationwith updated implementation details.
343-361: LGTM! Renamed method and updated implementation.Method has been renamed from
_encodeStateObjectto_encodeObjectStatewith updated variable names and method calls.
363-371: LGTM! Renamed method and updated parameter types.Method has been renamed from
_encodeStateDatato_encodeObjectDatawith updated parameter types.
373-407: LGTM! Updated method documentation and implementation.The private method documentation and implementation have been updated to reference object terminology instead of state.
409-457: LGTM! Updated toString method implementation.The toString method has been updated to return a string starting with
[ObjectMessageinstead of[StateMessage].
459-574: LGTM! Updated size calculation methods.All the size calculation methods have been renamed to use the "object" prefix instead of "state" and their implementations updated accordingly.
src/plugins/objects/livecounter.ts (12)
3-3: Imports updated to use new object-based terminology.The import statement has been correctly updated to use the new object-based types from the objectmessage module.
11-11: Property renamed from 'inc' to 'amount'.The LiveCounterUpdate interface property has been changed from "inc" to "amount" which aligns with the PR objective to replace state-based terminology.
25-33: Method and docs updated to use object-based terminology.The method has been correctly renamed from
fromStateObjecttofromObjectStatewith updated documentation and parameter types.
37-45: Method and docs updated to use object-based terminology.The method has been correctly renamed from
fromStateOperationtofromObjectOperationwith updated documentation and parameter types.
51-70: Method updated to return ObjectMessage instead of StateMessage.The method signature and implementation have been correctly updated to use the new ObjectMessage type and ObjectOperationAction enum.
🧰 Tools
🪛 Biome (1.9.4)
[error] 54-54: isFinite is unsafe. It attempts a type coercion. Use Number.isFinite instead.
See the MDN documentation for more details.
Unsafe fix: Use Number.isFinite instead.(lint/suspicious/noGlobalIsFinite)
76-111: Method updated to return ObjectMessage instead of StateMessage.The method signature and implementation have been correctly updated to use the new ObjectMessage type and ObjectOperationAction enum. The encoder function has also been updated to use the appropriate object-based types.
117-117: Return type updated to use ObjectOperation.The return type has been correctly updated to use the new ObjectOperation type.
162-220: Method updated to handle ObjectOperation and ObjectMessage types.The applyOperation method has been correctly updated to handle ObjectOperation and ObjectMessage types. The switch cases now properly use ObjectOperationAction enum values instead of StateOperationAction.
225-278: Method renamed and updated to handle ObjectState.The method has been correctly renamed from
overrideWithStateObjecttooverrideWithObjectStateand its implementation has been updated to handle ObjectState instead of StateObject.
294-295: Update property name in return value.The returned property name has been changed from "inc" to "amount" for consistency with the updated interface.
297-306: Method parameter updated to use ObjectOperation.The method parameter has been correctly updated from StateOperation to ObjectOperation with corresponding implementation changes.
333-336: Parameter type and implementation updated.The parameter type has been updated from StateCounterOp to CounterOp, and the returned update property has also been updated from "inc" to "amount" for consistency.
src/plugins/objects/livemap.ts (17)
8-17: Imports updated to use new object-based terminology.The import statements have been correctly updated to use the object-based types instead of state-based types.
19-34: Interfaces renamed to use object-based terminology.The interfaces have been correctly renamed from state-related (
ObjectIdStateData,ValueStateData,StateData) to object-related (ObjectIdObjectData,ValueObjectData,ObjectData) maintaining the same structure and purpose.
36-48: LiveMapEntry interface updated to use ObjectData.The LiveMapEntry interface now correctly uses ObjectData instead of StateData, and LiveMapData has been updated accordingly.
73-81: Method renamed to fromObjectState.The method has been correctly renamed from
fromStateObjecttofromObjectStatewith updated documentation and parameter types.
85-97: Method renamed to fromObjectOperation.The method has been correctly renamed from
fromStateOperationtofromObjectOperationwith updated parameter types.
102-133: Method updated to return ObjectMessage.The createMapSetMessage method now correctly returns ObjectMessage instead of StateMessage and uses ObjectOperation and ObjectData types.
138-162: Method updated to return ObjectMessage.The createMapRemoveMessage method now correctly returns ObjectMessage instead of StateMessage and uses ObjectOperation.
192-230: Method updated to return ObjectMessage.The createMapCreateMessage method now correctly returns ObjectMessage instead of StateMessage and uses ObjectOperation and encoder for the new type.
235-255: Method updated to use ObjectOperation.The createInitialValueObject method now correctly returns a Pick of ObjectOperation instead of StateOperation, with corresponding implementation changes.
286-286: Method call updated to use new method name.The method call has been updated from
_getResolvedValueFromStateDatato_getResolvedValueFromObjectData.
315-315: Method call updated to use new method name.The method call has been updated from
_getResolvedValueFromStateDatato_getResolvedValueFromObjectData.
365-433: Method updated to handle ObjectOperation and ObjectMessage types.The applyOperation method has been correctly updated to handle ObjectOperation and ObjectMessage types. The switch cases now properly use ObjectOperationAction enum values.
438-507: Method renamed and updated to handle ObjectState.The method has been correctly renamed from
overrideWithStateObjecttooverrideWithObjectStateand its implementation has been updated to handle ObjectState.
583-617: Method parameter updated to use ObjectOperation.The _mergeInitialDataFromCreateOperation method parameter has been correctly updated from StateOperation to ObjectOperation with corresponding implementation changes.
763-789: Method updated to use new types.The _liveMapDataFromMapEntries method now correctly works with MapEntry instead of StateMapEntry and creates LiveMapEntry objects with the correct structure.
794-812: Method renamed and updated to use ObjectData.The method has been correctly renamed from
_getResolvedValueFromStateDatato_getResolvedValueFromObjectDataand updated to work with ObjectData and return ObjectValue.
814-831: Method parameter updated to use LiveMapEntry.The _isMapEntryTombstoned method parameter type has been updated from MapEntry to LiveMapEntry.
06591f2 to
8c825c5
Compare
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
🔭 Outside diff range comments (3)
test/realtime/objects.test.js (3)
114-136: 🛠️ Refactor suggestionFunction renamed correctly but contains "state" reference that should be updated
The function has been correctly renamed from
waitForStateOperationtowaitForObjectOperation, but there's still a reference tomessage.state[0]?.operation?.actionon line 126 that should also be updated to use "object" terminology for consistency.- if (message.action === 19 && message.state[0]?.operation?.action === waitForAction) { + if (message.action === 19 && message.object[0]?.operation?.action === waitForAction) {
196-208: 🛠️ Refactor suggestionUpdated comment and method name but "state" property remains
Comment and method name correctly updated from STATE to OBJECT terminology, but the property
state:in the object passed toprocessObjectOperationMessageOnChannelstill uses the old "state" terminology.This pattern appears throughout the file. For consistency, consider updating all occurrences of the
state:property in objects passed to functions likeprocessObjectOperationMessageOnChannelto match the new "object" terminology:await objectsHelper.processObjectOperationMessageOnChannel({ channel: testChannel, serial: lexicoTimeserial('aaa', 0, 0), siteCode: 'aaa', - state: [objectsHelper.mapSetOp({ objectId: 'root', key: 'stringKey', data: { value: 'stringValue' } })], + object: [objectsHelper.mapSetOp({ objectId: 'root', key: 'stringKey', data: { value: 'stringValue' } })], });
1934-2071: 🛠️ Refactor suggestionConsistent terminology in test descriptions but inconsistent in implementation details
The test descriptions have been properly updated to use "object" terminology instead of "state", but the implementation details in some functions like
processObjectOperationMessageOnChannelstill use thestate:property. This inconsistency appears throughout many tests in this file.For consistency across the codebase, ensure all property names in the test implementation use the new "object" terminology. For example:
await objectsHelper.processObjectOperationMessageOnChannel({ channel, serial: lexicoTimeserial('aaa', i, 0), siteCode: 'aaa', - state: [objectsHelper.mapSetOp({ objectId: 'root', key: keyData.key, data: { ...keyData.data } })], + object: [objectsHelper.mapSetOp({ objectId: 'root', key: keyData.key, data: { ...keyData.data } })], });This pattern needs to be applied consistently throughout the file.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro (Legacy)
📒 Files selected for processing (21)
README.md(7 hunks)ably.d.ts(10 hunks)scripts/moduleReport.ts(1 hunks)src/common/lib/client/realtimechannel.ts(9 hunks)src/common/lib/transport/protocol.ts(1 hunks)src/common/lib/types/protocolmessage.ts(6 hunks)src/plugins/objects/batchcontext.ts(3 hunks)src/plugins/objects/batchcontextlivecounter.ts(1 hunks)src/plugins/objects/batchcontextlivemap.ts(1 hunks)src/plugins/objects/index.ts(1 hunks)src/plugins/objects/livecounter.ts(10 hunks)src/plugins/objects/livemap.ts(27 hunks)src/plugins/objects/liveobject.ts(4 hunks)src/plugins/objects/objectmessage.ts(13 hunks)src/plugins/objects/objects.ts(17 hunks)src/plugins/objects/syncobjectsdatapool.ts(2 hunks)test/common/modules/objects_helper.js(3 hunks)test/common/modules/private_api_recorder.js(1 hunks)test/package/browser/template/src/index-objects.ts(1 hunks)test/realtime/channel.test.js(1 hunks)test/realtime/objects.test.js(99 hunks)
🚧 Files skipped from review as they are similar to previous changes (13)
- src/plugins/objects/index.ts
- src/plugins/objects/batchcontextlivecounter.ts
- src/common/lib/transport/protocol.ts
- test/package/browser/template/src/index-objects.ts
- test/common/modules/private_api_recorder.js
- src/plugins/objects/batchcontextlivemap.ts
- scripts/moduleReport.ts
- test/realtime/channel.test.js
- src/plugins/objects/syncobjectsdatapool.ts
- src/common/lib/client/realtimechannel.ts
- src/plugins/objects/liveobject.ts
- test/common/modules/objects_helper.js
- ably.d.ts
🧰 Additional context used
🧬 Code Graph Analysis (4)
src/common/lib/types/protocolmessage.ts (3)
src/plugins/objects/index.ts (1)
ObjectMessage(4-4)test/realtime/objects.test.js (2)
Utils(12-12)MessageEncoding(13-13)src/common/lib/types/message.ts (1)
MessageEncoding(445-450)
src/plugins/objects/objects.ts (3)
src/plugins/objects/objectmessage.ts (1)
ObjectMessage(146-575)src/plugins/objects/livemap.ts (1)
LiveMap(54-832)src/plugins/objects/livecounter.ts (1)
LiveCounter(14-337)
src/plugins/objects/livecounter.ts (2)
src/plugins/objects/objects.ts (1)
Objects(39-501)src/plugins/objects/objectmessage.ts (4)
ObjectState(118-141)ObjectOperation(82-115)ObjectMessage(146-575)CounterOp(47-50)
src/plugins/objects/livemap.ts (3)
src/plugins/objects/objectmessage.ts (5)
ObjectValue(23-23)ObjectData(26-36)ObjectOperation(82-115)ObjectMessage(146-575)MapOp(39-44)src/plugins/objects/index.ts (2)
Objects(4-4)ObjectMessage(4-4)src/plugins/objects/objects.ts (1)
Objects(39-501)
🪛 Biome (1.9.4)
src/plugins/objects/livecounter.ts
[error] 54-54: isFinite is unsafe. It attempts a type coercion. Use Number.isFinite instead.
See the MDN documentation for more details.
Unsafe fix: Use Number.isFinite instead.
(lint/suspicious/noGlobalIsFinite)
🪛 LanguageTool
README.md
[style] ~648-~648: Try using a synonym here to strengthen your writing.
Context: ... point for objects within a channel. It gives access to all other nested objects. ``...
(GIVE_PROVIDE)
[uncategorized] ~838-~838: Use a comma before ‘and’ if it connects two independent clauses (unless they are closely connected and short).
Context: ...g its data or trying to update its value and you should remove all references to the...
(COMMA_COMPOUND_SENTENCE)
🪛 markdownlint-cli2 (0.17.2)
README.md
650-650: Code block style
Expected: indented; Actual: fenced
(MD046, code-block-style)
777-777: Code block style
Expected: indented; Actual: fenced
(MD046, code-block-style)
840-840: Code block style
Expected: indented; Actual: fenced
(MD046, code-block-style)
🔇 Additional comments (88)
src/plugins/objects/batchcontext.ts (5)
7-7: Import path update correctly reflects the file renaming.The import statement has been updated to reference
ObjectMessagefrom the renamed fileobjectmessage.ts, which aligns with the PR objective to replace "state" terminology with "objects".
13-13: Documentation comment updated for consistency.The comment now refers to "object ids" instead of "live object ids", maintaining consistency with the terminology updates throughout the codebase.
15-15: Property type updated correctly.The
_queuedMessagesproperty type has been changed fromStateMessage[]toObjectMessage[], which aligns with the type renaming specified in the PR objectives.
52-52: Error message terminology updated.The error message now uses "LiveObject" (without a space) instead of "Live Object", providing consistent terminology across the codebase.
88-89: Method renamed and signature updated.The method has been renamed from
queueStateMessagetoqueueMessageand its parameter type changed fromStateMessagetoObjectMessage, consistent with the broader refactoring effort.test/realtime/objects.test.js (3)
90-91: Name change aligned with terminology updateChanged from
stateMessageFromValuestoobjectMessageFromValuesand the implementation now callsObjectMessage.fromValuesinstead ofStateMessage.fromValues, consistent with the PR objective to replace "state" terminology with "objects".
4504-4725: Successfully transitioned from StateMessage to ObjectMessageThe test suite for message size calculations has been properly migrated from
StateMessagetoObjectMessage. All test scenarios and method calls are now correctly using the "object" terminology.
4729-4744: Successfully updated test case to use "Objects modes"Test description updated from "can attach to channel with States modes" to "can attach to channel with Objects modes", which aligns with the PR objective.
README.md (6)
648-649: LGTM: Updated terminology from "Live Objects" to "objects"This change aligns with the PR's goal of replacing "state" terminology with "objects", making the documentation more consistent with the updated specification.
🧰 Tools
🪛 LanguageTool
[style] ~648-~648: Try using a synonym here to strengthen your writing.
Context: ... point for objects within a channel. It gives access to all other nested objects. ``...(GIVE_PROVIDE)
660-661: LGTM: Updated LiveMap documentation to reflect object-based modelThe change clarifies that LiveMap enables you to store other objects, which more accurately reflects the component's functionality in the new object-oriented model.
717-722: LGTM: Revised subscription update description for clarityThis update improves clarity by focusing on "updates on objects" rather than "Live Objects", providing a more accurate description of the subscription mechanism.
775-783: LGTM: Updated object creation terminologyThe revised text now correctly refers to "LiveMap and LiveCounter objects" which is more consistent with the object-based model being implemented across the codebase.
🧰 Tools
🪛 markdownlint-cli2 (0.17.2)
777-777: Code block style
Expected: indented; Actual: fenced(MD046, code-block-style)
822-825: LGTM: Improved lifecycle events descriptionThe text now more accurately describes how events allow monitoring of objects' lifecycle changes, which reflects the new object-oriented model terminology.
838-846: LGTM: Updated object deletion event descriptionThe deletion notification message has been simplified from "Live Object has been deleted" to "Object has been deleted", which is more consistent with the object-based terminology.
🧰 Tools
🪛 LanguageTool
[uncategorized] ~838-~838: Use a comma before ‘and’ if it connects two independent clauses (unless they are closely connected and short).
Context: ...g its data or trying to update its value and you should remove all references to the...(COMMA_COMPOUND_SENTENCE)
🪛 markdownlint-cli2 (0.17.2)
840-840: Code block style
Expected: indented; Actual: fenced(MD046, code-block-style)
src/common/lib/types/protocolmessage.ts (6)
37-38: LGTM: Renamed STATE actions to OBJECT actionsRenamed
STATEtoOBJECTandSTATE_SYNCtoOBJECT_SYNCin the protocol message actions, aligning with the new object-based terminology.
53-53: LGTM: Updated flag from HAS_STATE to HAS_OBJECTSThe flag
HAS_STATEhas been renamed toHAS_OBJECTS, which is consistent with the PR's objective to move away from state-based terminology.
129-137: LGTM: Updated state handling to use ObjectMessageUpdated the type of the
statevariable fromStateMessage[]toObjectMessage[]and correctly used the newObjectMessage.fromValuesmethod for message conversion. These changes align with the broader refactoring from state to object-based messaging.
146-147: LGTM: Updated documentation for object messagesThe comment now correctly refers to building object messages instead of state messages, maintaining consistency with the new terminology.
181-183: LGTM: Updated stringify to use ObjectMessageUpdated the stringify method to reference
objectsPlugin.ObjectMessage.fromValuesArrayinstead of a previous state-related method, ensuring consistency with the new object-based model.
222-222: LGTM: Updated state property type to ObjectMessageChanged the type of the state property from
StateMessage[]toObjectMessage[], completing the transition to the object-based model in the protocol message class.src/plugins/objects/objects.ts (15)
10-10: LGTM: Updated imports to use ObjectMessageReplaced the import of
StateMessage, StateOperationActionwithObjectMessage, ObjectOperationAction, which is consistent with the renamed file and types.
52-52: LGTM: Renamed buffered operations to match new terminologyPrivate member
_bufferedStateOperationshas been renamed to_bufferedObjectOperationsand its initialization updated, maintaining consistency with the object-based terminology.Also applies to: 65-65
112-116: LGTM: Updated createMap to use ObjectMessageThe
createMapmethod now correctly usesmsgand references itsoperationproperty, replacing previous state-based variables and method calls.
127-128: LGTM: Updated object creation from ObjectOperationChanged from
LiveMap.fromStateOperationtoLiveMap.fromObjectOperation, which aligns with the renamed method in the LiveMap class.
144-159: LGTM: Updated createCounter to use ObjectMessageSimilar to createMap, the createCounter method has been updated to use ObjectMessage and reference the operation property, with appropriate method name changes from state to object.
215-230: LGTM: Renamed sync message handler methodsRenamed method from
handleStateSyncMessagestohandleObjectSyncMessagesand updated the call toapplyObjectSyncMessages, maintaining consistency with the object-based terminology.
235-246: LGTM: Updated object messages handlerRenamed method from
handleStateMessagestohandleObjectMessagesand updated the buffering logic to use_bufferedObjectOperations. Also updated the method call from_applyStateMessagesto_applyObjectMessages.
251-257: LGTM: Updated onAttached to use hasObjects flagChanged parameter from
hasStatetohasObjectsand updated the log message to include the new parameter name, aligning with the renamed flag in the protocol message.
260-274: LGTM: Updated conditional checks in onAttachedThe conditional logic now correctly references the
hasObjectsflag instead of a previoushasStateflag, maintaining consistent terminology throughout the method.
279-283: LGTM: Updated actOnChannelState parameterChanged parameter type from
hasStatetohasObjectsand updated the method call to pass the renamed parameter, ensuring consistency throughout the codebase.
296-317: LGTM: Updated publish method to use ObjectMessageUpdated method signature from
publish(stateMessages: StateMessage[])topublish(objectMessages: ObjectMessage[]), and made corresponding changes to encoding and error message to reference "object messages" instead of "state messages".
336-351: LGTM: Updated sync methods to use object terminologyUpdated method implementations to reference "object operation" instead of "state operation" and updated variable names from
_bufferedStateOperationsto_bufferedObjectOperations.
388-389: LGTM: Updated object state handlingChanged method call from
overrideWithStateObjecttooverrideWithObjectState, which aligns with renamed methods in the LiveObject class.
400-405: LGTM: Updated object creation from ObjectStateChanged method calls from
LiveCounter.fromStateObjectandLiveMap.fromStateObjecttofromObjectState, maintaining consistency with renamed methods in the respective classes.
421-461: LGTM: Renamed object message application methodRenamed method from
_applyStateMessagesto_applyObjectMessagesand updated the implementation to use object-based terminology throughout. The switch statement now correctly usesObjectOperationActionconstants.src/plugins/objects/objectmessage.ts (18)
9-16: LGTM: Renamed operation action enumRenamed enum from
StateOperationActiontoObjectOperationAction, maintaining the same action constants but with updated terminology.
22-36: LGTM: Renamed value and data typesRenamed
StateValuetoObjectValueandStateDatatoObjectData, with updated documentation to reflect the object-based model.
38-50: LGTM: Renamed operation typesRenamed interfaces from
StateMapOptoMapOpandStateCounterOptoCounterOp, simplifying the naming while maintaining the object-based focus.
53-79: LGTM: Renamed map and counter interfacesRenamed interfaces from
StateMapEntrytoMapEntry,StateMaptoObjectMap, andStateCountertoObjectCounter, keeping a consistent naming pattern across related types.
81-115: LGTM: Renamed operation interfaceRenamed interface from
StateOperationtoObjectOperationand updated property types to reference the newly renamed interfaces, maintaining type consistency.
117-141: LGTM: Renamed state interface to ObjectStateRenamed interface from
StateObjecttoObjectStateand updated property types to reference the newly renamed interfaces, completing the transition to object-based terminology.
146-169: LGTM: Renamed message class and updated documentationRenamed class from
StateMessagetoObjectMessageand updated the property documentation to reference "object" instead of "state", maintaining consistent terminology.
181-197: LGTM: Updated encode method for ObjectMessageUpdated method signature and implementation to reference
ObjectMessageand updated encoding logic to use the renamed helper methods.
203-228: LGTM: Updated decode method for ObjectMessageUpdated method signature and implementation to reference
ObjectMessageand updated decoding logic to use the renamed helper methods such as_decodeObjectData.
231-251: LGTM: Updated fromValues methods for ObjectMessageUpdated method signatures and implementations to reference
ObjectMessagein both thefromValuesandfromValuesArraymethods.
254-287: LGTM: Updated encodeInitialValue for ObjectOperationUpdated parameter type and implementation to use
ObjectMessageand the renamed encoding methods, ensuring consistent object-based terminology.
290-315: LGTM: Renamed decoding methods for object dataRenamed methods from
_decodeStateMapEntriesto_decodeMapEntriesand_decodeStateDatato_decodeObjectData, with updated parameter types to match the renamed interfaces.
317-341: LGTM: Renamed encoding method for object operationsRenamed method from
_encodeStateOperationto_encodeObjectOperationand updated implementation to use the renamed helper methods and object properties.
343-371: LGTM: Renamed encoding methods for object state and dataRenamed methods from
_encodeStateObjectto_encodeObjectStateand_encodeStateDatato_encodeObjectData, with updated implementations to reference the new object-based terminology.
373-407: LGTM: Updated wire protocol encoding for ObjectMessageUpdated method documentation and implementation to reference
ObjectMessageand the renamed helper methods, ensuring consistent object-based terminology throughout the encoding process.
417-436: LGTM: Updated toJSON for ObjectMessageUpdated method signature and implementation to reference
operationandobjectproperties instead of previous state-related properties, maintaining consistent object-based terminology.
438-457: LGTM: Updated toString for ObjectMessageUpdated class name in output and property references to align with the object-based model, improving consistency in debugging output.
459-574: LGTM: Renamed size calculation methodsRenamed multiple size calculation methods to use object-based terminology instead of state-based terminology, such as
_getObjectOperationSizeinstead of_getStateOperationSize, ensuring consistency throughout the class.src/plugins/objects/livecounter.ts (15)
3-3: Consistent import rename to object-based entities.
No issues found with the updated import references; the shift to object-based types is clearly in line with the PR’s objective.
25-26: Accurate updated JSDoc references.
The documentation now correctly refers to "object state" rather than "state object," aligning with the new terminology.
30-32: Correct constructor call infromObjectState.
The method properly instantiates aLiveCounterand callsoverrideWithObjectState, ensuring object state is applied as intended.
37-38: Well-formed JSDoc forfromObjectOperation.
Renaming from a state-based to an object-based approach is consistent with the rest of the refactor.
42-44:fromObjectOperationlogic looks sound.
Summarily replicates the same approach asfromObjectState, focusing on object-based creation. No concerns found.
51-70: Creation ofCOUNTER_INCmessages is solid.
The function checks for valid numeric input and constructs anObjectMessagewithCOUNTER_INCaction. No issues spotted.🧰 Tools
🪛 Biome (1.9.4)
[error] 54-54: isFinite is unsafe. It attempts a type coercion. Use Number.isFinite instead.
See the MDN documentation for more details.
Unsafe fix: Use Number.isFinite instead.(lint/suspicious/noGlobalIsFinite)
76-111: Appropriate pattern for creatingCOUNTER_CREATEmessages.
The logic for encoding the initial value, generating a newobjectId, and returning anObjectMessageis consistent and matches the new object paradigm.
117-117: Helper method for initial value object.
The refactor is straightforward; returning only thecounterfield is in line with the newObjectOperationdefinition.
141-142: Publish call on increment.
These lines ensure that the user’s increment value is published via anObjectMessage. Implementation correctly delegates toLiveCounter.createCounterIncMessage.
162-220:applyOperationrefactored for object-based operations.
The switch correctly handlesCOUNTER_CREATE,COUNTER_INC, andOBJECT_DELETE. No concurrency or logic issues noted.
225-274: Seamless override with object state.
The checks for a valid create operation, tombstoning, and data override are logically sound. The approach is consistent with object-based semantics.
297-305: Logical merging of initial data.
Summing thecounter?.countis correct for applying the create operation’s starting value. No issues found.
308-308: Clear error handling in_throwNoPayloadError.
Throws an error if the payload is absent, protecting against malformed operations.
316-316: Clean creation logic in_applyCounterCreate.
Avoids reapplying create operations once merged, preventing duplicate initialization. Nicely done.
333-333: Increment logic is concise and correct.
Addsop.amountto the existing count, matching the new object-based structure.src/plugins/objects/livemap.ts (20)
8-17: Renamed imports align with object-based model.
No problems with removing state-based imports in favor ofObjectMessage,ObjectOperation, etc.
19-35: New object data interfaces.
ObjectIdObjectDataandValueObjectDatacorrectly replace state-based definitions. Documentation is clear and consistent.
36-47:LiveMapEntryandLiveMapDataupdates.
Switching fromMapEntrytoLiveMapEntryand naming the fielddata: Map<string, LiveMapEntry>is coherent with the object-based approach.
73-82:fromObjectStateforLiveMap.
The method callsoverrideWithObjectStateto sync data from the new object state. Looks consistent and correct.
85-97:fromObjectOperationfor MAP_CREATE objects.
Mimics the pattern inLiveCounter, bridging the initial create operation into this live map’s data. Code is sound.
107-133:createMapSetMessagelogic.
Checks validity of key-value, buildsObjectMessagewithMAP_SETaction, and ensures the correctmapOppayload. Implementation is coherent.
142-162:createMapRemoveMessagelogic.
Validates key, constructsMAP_REMOVEoperation message. Straightforward and consistent.
192-230: Creation of MAP_CREATE messages.
GeneratesobjectIdfrom the initial entries, encodes them, and sets theMAP_CREATEaction. Cleanly implemented.
235-255:createInitialValueObjectfor map.
Constructs a map from the given entries, referencing objects where applicable. Accurately sets up the initial map data prior to creation.
264-285: Correct retrieval of map entry values.
Theget()method and tombstone checks ensure that only non-deleted and existing references are returned.
315-315: Resolved value from_getResolvedValueFromObjectData.
Uses the existing reference-check logic to retrieveLiveObjector a primitive as needed. No issues here.
343-345:set()method callscreateMapSetMessage.
Ensures the MAP_SET operation is published. Implementation is aligned with the new object-based design.
358-359:remove()method callscreateMapRemoveMessage.
Similarly, publishes a MAP_REMOVE operation. No concerns identified.
365-433:applyOperationadopting object operations.
The switch statement properly coversMAP_CREATE,MAP_SET,MAP_REMOVE, andOBJECT_DELETE. Good CRDT checks ensure timeserial ordering.
438-507: Override logic withoverrideWithObjectState.
Matches the approach used in other refactored classes, carefully tombstoning or merging data as required. Implementation aligns with object-based naming.
583-616: Merging initial data from create operation.
Applying each entry as though it were MAP_SET or MAP_REMOVE is a proper approach for the MAP_CREATE scenario. Solid CRDT logic.
704-733: Safe approach to_applyMapRemove.
Ensures skip if timeserial is not strictly newer, tombstones the entry otherwise, and updates relevant metadata. Code is consistent.
763-789: Building_liveMapDataFromMapEntries.
Data is transformed into aMap<string, LiveMapEntry>with appropriate tombstone flags and timeserial references. No issues found.
795-812: Distinguishing primitives vs. object references in_getResolvedValueFromObjectData.
Returns theLiveObjectfrom the pool or the primitive, skipping if tombstoned. Solid resolution logic.
814-831:_isMapEntryTombstonedchecks entry and object references.
Appropriately excludes references to tombstoned objects, ensuring the map entry is also treated as tombstoned. Matches the CRDT approach.
… feature This commit does next changes: - removes `state` mentions in comments / internal API. Uses `objects` instead where possible - normalizes terminology used when referencing "LiveObjects" product and objects on a channel according to LiveObjects product docs PR [1] - `STATE` message action -> `OBJECT` - `STATE_SYNC` message action -> `OBJECT_SYNC` - `HAS_STATE` flag -> `HAS_OBJECT` - `StateMessage` type -> `ObjectMessage` - `StateOperation` type -> `ObjectOperation` - `StateObject` type -> `ObjectState` - `StateData` type -> `ObjectData` - `StateValue` type -> `ObjectValue` This brings ably-js LiveObjects implementation in line with the naming changes introduced in the spec PR [2]. [1] ably/docs#2463 (review) [2] ably/specification#279 (comment)
8c825c5 to
8846a8b
Compare
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: 0
🧹 Nitpick comments (2)
README.md (2)
824-824: Synchronization events description updated.Minor grammatical suggestion: Consider adding an apostrophe to "client's" to indicate possession.
- the `syncing` and `synced` events notify when the local Objects state on a client is being synchronized with the Ably service. + the `syncing` and `synced` events notify when the local Objects state on a client's is being synchronized with the Ably service.🧰 Tools
🪛 LanguageTool
[uncategorized] ~824-~824: It seems likely that a singular genitive (’s) apostrophe is missing.
Context: ...dsyncedevents notify when the local Objects state on a client is being synchronized...(AI_HYDRA_LEO_APOSTROPHE_S_XS)
838-839: Deletion events description improved.Consider adding a comma before "and" in this sentence to improve readability.
- Once an object is deleted, it can no longer be interacted with. You should avoid accessing its data or trying to update its value and you should remove all references to the deleted object in your application. + Once an object is deleted, it can no longer be interacted with. You should avoid accessing its data or trying to update its value, and you should remove all references to the deleted object in your application.🧰 Tools
🪛 LanguageTool
[uncategorized] ~838-~838: Use a comma before ‘and’ if it connects two independent clauses (unless they are closely connected and short).
Context: ...g its data or trying to update its value and you should remove all references to the...(COMMA_COMPOUND_SENTENCE)
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro (Legacy)
📒 Files selected for processing (21)
README.md(7 hunks)ably.d.ts(10 hunks)scripts/moduleReport.ts(1 hunks)src/common/lib/client/realtimechannel.ts(9 hunks)src/common/lib/transport/protocol.ts(1 hunks)src/common/lib/types/protocolmessage.ts(6 hunks)src/plugins/objects/batchcontext.ts(3 hunks)src/plugins/objects/batchcontextlivecounter.ts(1 hunks)src/plugins/objects/batchcontextlivemap.ts(1 hunks)src/plugins/objects/index.ts(1 hunks)src/plugins/objects/livecounter.ts(11 hunks)src/plugins/objects/livemap.ts(27 hunks)src/plugins/objects/liveobject.ts(4 hunks)src/plugins/objects/objectmessage.ts(13 hunks)src/plugins/objects/objects.ts(17 hunks)src/plugins/objects/syncobjectsdatapool.ts(2 hunks)test/common/modules/objects_helper.js(3 hunks)test/common/modules/private_api_recorder.js(1 hunks)test/package/browser/template/src/index-objects.ts(1 hunks)test/realtime/channel.test.js(1 hunks)test/realtime/objects.test.js(99 hunks)
🚧 Files skipped from review as they are similar to previous changes (14)
- src/plugins/objects/batchcontextlivemap.ts
- scripts/moduleReport.ts
- src/plugins/objects/index.ts
- src/plugins/objects/batchcontextlivecounter.ts
- src/common/lib/transport/protocol.ts
- test/package/browser/template/src/index-objects.ts
- test/realtime/channel.test.js
- test/common/modules/private_api_recorder.js
- src/common/lib/types/protocolmessage.ts
- src/common/lib/client/realtimechannel.ts
- src/plugins/objects/liveobject.ts
- src/plugins/objects/syncobjectsdatapool.ts
- test/common/modules/objects_helper.js
- ably.d.ts
🧰 Additional context used
🧬 Code Graph Analysis (4)
src/plugins/objects/objects.ts (3)
src/plugins/objects/objectmessage.ts (1)
ObjectMessage(146-575)src/plugins/objects/livemap.ts (1)
LiveMap(54-832)src/plugins/objects/livecounter.ts (1)
LiveCounter(14-337)
test/realtime/objects.test.js (3)
src/plugins/objects/livemap.ts (1)
values(326-330)src/plugins/objects/batchcontextlivemap.ts (1)
values(43-47)src/common/lib/client/realtimechannel.ts (1)
objects(156-161)
src/plugins/objects/livecounter.ts (1)
src/plugins/objects/objectmessage.ts (4)
ObjectState(118-141)ObjectOperation(82-115)ObjectMessage(146-575)CounterOp(47-50)
src/plugins/objects/livemap.ts (3)
src/plugins/objects/objectmessage.ts (5)
ObjectValue(23-23)ObjectData(26-36)ObjectOperation(82-115)ObjectMessage(146-575)MapOp(39-44)src/plugins/objects/index.ts (2)
Objects(4-4)ObjectMessage(4-4)src/plugins/objects/objects.ts (1)
Objects(39-501)
🪛 Biome (1.9.4)
src/plugins/objects/livecounter.ts
[error] 54-54: isFinite is unsafe. It attempts a type coercion. Use Number.isFinite instead.
See the MDN documentation for more details.
Unsafe fix: Use Number.isFinite instead.
(lint/suspicious/noGlobalIsFinite)
[error] 152-152: isFinite is unsafe. It attempts a type coercion. Use Number.isFinite instead.
See the MDN documentation for more details.
Unsafe fix: Use Number.isFinite instead.
(lint/suspicious/noGlobalIsFinite)
🪛 LanguageTool
README.md
[style] ~648-~648: Try using a synonym here to strengthen your writing.
Context: ... point for objects within a channel. It gives access to all other nested objects. ``...
(GIVE_PROVIDE)
[uncategorized] ~824-~824: It seems likely that a singular genitive (’s) apostrophe is missing.
Context: ...d synced events notify when the local Objects state on a client is being synchronized...
(AI_HYDRA_LEO_APOSTROPHE_S_XS)
[uncategorized] ~838-~838: Use a comma before ‘and’ if it connects two independent clauses (unless they are closely connected and short).
Context: ...g its data or trying to update its value and you should remove all references to the...
(COMMA_COMPOUND_SENTENCE)
🪛 markdownlint-cli2 (0.17.2)
README.md
650-650: Code block style
Expected: indented; Actual: fenced
(MD046, code-block-style)
777-777: Code block style
Expected: indented; Actual: fenced
(MD046, code-block-style)
840-840: Code block style
Expected: indented; Actual: fenced
(MD046, code-block-style)
⏰ Context from checks skipped due to timeout of 90000ms (6)
- GitHub Check: test-node (20.x)
- GitHub Check: test-node (18.x)
- GitHub Check: test-browser (webkit)
- GitHub Check: test-node (16.x)
- GitHub Check: test-browser (firefox)
- GitHub Check: test-browser (chromium)
🔇 Additional comments (218)
src/plugins/objects/batchcontext.ts (5)
7-7: Import updated correctly.The import has been properly updated to use
ObjectMessagefrom the renamed fileobjectmessage.tsinstead ofStateMessagefromstatemessage.ts, aligning with the PR objective to replace "state" terminology with "objects".
13-13: Documentation comment updated correctly.The comment has been appropriately updated from "live object ids" to "object ids" to maintain consistency with the new terminology standards.
15-15: Type definition updated correctly.The type of
_queuedMessageshas been properly updated fromStateMessage[]toObjectMessage[]to align with the renamed type.
52-52: Error message terminology updated correctly.The error message has been updated from "Live Object" to "LiveObject" to ensure consistent terminology throughout the codebase.
88-89:Details
❓ Verification inconclusive
Method renamed and parameter type updated correctly.
The method has been properly renamed from
queueStateMessagetoqueueMessageand its parameter type updated fromStateMessagetoObjectMessageto align with the new terminology.
🏁 Script executed:
#!/bin/bash # Check if all references to the old method name have been updated throughout the codebase rg -i "queueStateMessage" --type tsLength of output: 35
Renaming Verified – Please Manually Confirm
The method in
src/plugins/objects/batchcontext.ts(lines 88-89) has been updated fromqueueStateMessagetoqueueMessagewith its parameter type changed fromStateMessagetoObjectMessageto match the new terminology. A preliminary search usingrg -i "queueStateMessage"returned no results, suggesting that all outdated references have been removed. However, because the command output was minimal and may lead to a low-confidence inference, please verify this manually in the codebase to ensure no lingering references remain.queueMessage(msg: ObjectMessage): void { this._queuedMessages.push(msg);test/realtime/objects.test.js (126)
90-91: Function renamed to follow object terminologyThe function has been successfully renamed from
stateMessageFromValuestoobjectMessageFromValuesto align with the new object-based terminology, and it now correctly callsObjectMessage.fromValuesinstead ofStateMessage.fromValues.
114-114: Function renamed to follow object terminologyThe function has been successfully renamed from
waitForStateOperationtowaitForObjectOperation, maintaining the same functionality but aligned with the new naming convention.
182-183: Updated test descriptionTest description has been updated to reference "OBJECT ProtocolMessage" instead of "STATE ProtocolMessage" to align with the new terminology.
196-198: Updated comment and method referenceComment now references "OBJECT message" and the method call has been updated to
processObjectOperationMessageOnChannel, both following the new terminology.
214-215: Updated test descriptionTest description has been updated to reference "OBJECT_SYNC ProtocolMessage" instead of "STATE_SYNC ProtocolMessage" to align with the new terminology.
228-230: Updated comment and method referenceComment now references "OBJECT_SYNC message" and the method call has been updated to
processObjectStateMessageOnChannel, both following the new terminology.
276-277: Updated test descriptionTest description has been updated to reference "LiveObject" instead of what was likely "LiveState" before, aligning with the new object-based terminology.
293-294: Updated test descriptionTest description has been updated to reference "objects" instead of "states" to align with the new terminology.
309-310: Updated test descriptionTest description has been updated to reference "OBJECT_SYNC" instead of "STATE_SYNC" to align with the new terminology.
327-329: Updated assertion messageAssertion message has been updated to reference "OBJECT_SYNC" instead of "STATE_SYNC" to align with the new terminology.
338-339: Updated test descriptionTest description has been updated to reference "OBJECT_SYNC sequence" instead of "STATE_SYNC sequence" to align with the new terminology.
364-365: Updated test descriptionTest description has been updated to reference "OBJECT_SYNC" instead of "STATE_SYNC" to align with the new terminology.
377-379: Updated comment and method referenceComment now references "OBJECT_SYNC message" and the method call has been updated to
processObjectStateMessageOnChannel, both following the new terminology.
395-396: Updated assertion messageAssertion message has been updated to reference "OBJECT_SYNC" instead of "STATE_SYNC" to align with the new terminology.
397-399: Updated comment and method referenceComment now references "OBJECT_SYNC message" and the method call has been updated to
processObjectStateMessageOnChannel, both following the new terminology.
415-417: Updated assertion messagesAssertion messages have been updated to reference "OBJECT_SYNC sequence" instead of "STATE_SYNC sequence" to align with the new terminology.
423-424: Updated test descriptionTest description has been updated to reference "OBJECT_SYNC sequence" instead of "STATE_SYNC sequence" to align with the new terminology.
442-443: Updated assertion messageAssertion message has been updated to reference "OBJECT_SYNC sequence" instead of "STATE_SYNC sequence" to align with the new terminology.
486-487: Updated test descriptionTest description has been updated to reference "OBJECT_SYNC sequence" instead of "STATE_SYNC sequence" to align with the new terminology.
519-520: Updated test descriptionTest description has been updated to reference "OBJECT_SYNC sequence" instead of "STATE_SYNC sequence" to align with the new terminology.
659-660: Updated variable nameVariable name has been updated from
stateSyncSequenceScenariostoobjectSyncSequenceScenariosto align with the new terminology.
661-662: Updated test descriptionTest description has been updated to reference "OBJECT_SYNC sequence" instead of "STATE_SYNC sequence" to align with the new terminology.
667-669: Updated method referenceMethod call has been updated to
processObjectStateMessageOnChannelfollowing the new terminology.
702-710: Updated assertion messagesAssertion messages have been updated to reference "OBJECT_SYNC" instead of "STATE_SYNC" to align with the new terminology.
715-716: Updated test descriptionTest description has been updated to reference "OBJECT_SYNC sequence" instead of "STATE_SYNC sequence" to align with the new terminology.
727-731: Updated assertion messageAssertion message has been updated to reference "before OBJECT_SYNC sequence" instead of "before STATE_SYNC sequence" to align with the new terminology.
732-734: Updated comment and method referenceComment now references "OBJECT_SYNC message" and the method call has been updated to
processObjectStateMessageOnChannel, both following the new terminology.
758-762: Updated assertion messagesAssertion messages have been updated to reference "OBJECT_SYNC" instead of "STATE_SYNC" to align with the new terminology.
767-769: Updated test descriptionTest description has been updated to reference "OBJECT_SYNC sequence" instead of "STATE_SYNC sequence" to align with the new terminology.
785-786: Updated assertion messageAssertion message has been updated to reference "OBJECT_SYNC sequence" instead of "STATE_SYNC sequence" to align with the new terminology.
794-796: Updated comment and method referenceComment now references "OBJECT_SYNC message" and the method call has been updated to
processObjectStateMessageOnChannel, both following the new terminology.
825-826: Updated test descriptionTest description has been updated to reference "object operation messages" instead of "state operation messages" to align with the new terminology.
889-890: Updated test descriptionTest description has been updated to reference "object operation messages" instead of "state operation messages" to align with the new terminology.
965-966: Updated test descriptionTest description has been updated to reference "object operation messages" instead of "state operation messages" to align with the new terminology.
980-981: Updated method referenceMethod call has been updated to
processObjectOperationMessageOnChannelfollowing the new terminology.
986-987: Updated method referenceMethod call has been updated to
processObjectOperationMessageOnChannelfollowing the new terminology.
1003-1016: Updated method referenceMethod call has been updated to
processObjectOperationMessageOnChannelfollowing the new terminology.
1047-1048: Updated test descriptionTest description has been updated to reference "object operation messages" instead of "state operation messages" to align with the new terminology.
1096-1097: Updated test descriptionTest description has been updated to reference "object operation messages" instead of "state operation messages" to align with the new terminology.
1154-1155: Updated test descriptionTest description has been updated to reference "object operation messages" instead of "state operation messages" to align with the new terminology.
1160-1161: Updated method referenceMethod call has been updated to
processObjectOperationMessageOnChannelfollowing the new terminology.
1178-1179: Updated method referenceMethod call has been updated to
processObjectOperationMessageOnChannelfollowing the new terminology.
1194-1195: Updated method referenceMethod call has been updated to
processObjectOperationMessageOnChannelfollowing the new terminology.
1223-1224: Updated test descriptionTest description has been updated to reference "object operation messages" instead of "state operation messages" to align with the new terminology.
1287-1288: Updated test descriptionTest description has been updated to reference "object operation messages" instead of "state operation messages" to align with the new terminology.
1292-1293: Updated method referenceMethod call has been updated to
processObjectOperationMessageOnChannelfollowing the new terminology.
1310-1311: Updated method referenceMethod call has been updated to
processObjectOperationMessageOnChannelfollowing the new terminology.
1326-1327: Updated method referenceMethod call has been updated to
processObjectOperationMessageOnChannelfollowing the new terminology.
1358-1359: Updated test descriptionTest description has been updated to reference "object operation messages" instead of "state operation messages" to align with the new terminology.
1411-1412: Updated test descriptionTest description has been updated to reference "object operation messages" instead of "state operation messages" to align with the new terminology.
1426-1427: Updated method referenceMethod call has been updated to
processObjectOperationMessageOnChannelfollowing the new terminology.
1432-1433: Updated method referenceMethod call has been updated to
processObjectOperationMessageOnChannelfollowing the new terminology.
1449-1450: Updated method referenceMethod call has been updated to
processObjectOperationMessageOnChannelfollowing the new terminology.
1479-1480: Updated test descriptionTest description has been updated to reference "object operation messages" instead of "state operation messages" to align with the new terminology.
1543-1544: Updated test descriptionTest description has been updated to reference "object operation messages" instead of "state operation messages" to align with the new terminology.
1549-1550: Updated method referenceMethod call has been updated to
processObjectOperationMessageOnChannelfollowing the new terminology.
1555-1556: Updated method referenceMethod call has been updated to
processObjectOperationMessageOnChannelfollowing the new terminology.
1571-1572: Updated method referenceMethod call has been updated to
processObjectOperationMessageOnChannelfollowing the new terminology.
1588-1589: Updated test descriptionTest description has been updated to reference "OBJECT_DELETE object operation messages" instead of "STATE_DELETE state operation messages" to align with the new terminology.
1613-1614: Updated method referenceMethod call has been updated to
processObjectOperationMessageOnChannelfollowing the new terminology.
1619-1620: Updated method referenceMethod call has been updated to
processObjectOperationMessageOnChannelfollowing the new terminology.
1638-1639: Updated method referenceMethod call has been updated to
processObjectOperationMessageOnChannelfollowing the new terminology.
1646-1647: Updated method referenceMethod call has been updated to
processObjectOperationMessageOnChannelfollowing the new terminology.
1652-1653: Updated method referenceMethod call has been updated to
processObjectOperationMessageOnChannelfollowing the new terminology.
1665-1666: Updated test descriptionTest description has been updated to reference "OBJECT_DELETE object operation messages" instead of "STATE_DELETE state operation messages" to align with the new terminology.
1680-1681: Updated method referenceMethod call has been updated to
processObjectOperationMessageOnChannelfollowing the new terminology.
1686-1687: Updated method referenceMethod call has been updated to
processObjectOperationMessageOnChannelfollowing the new terminology.
1703-1704: Updated method referenceMethod call has been updated to
processObjectOperationMessageOnChannelfollowing the new terminology.
1793-1794: Updated method referenceMethod call has been updated to
processObjectOperationMessageOnChannelfollowing the new terminology.
1799-1800: Updated method referenceMethod call has been updated to
processObjectOperationMessageOnChannelfollowing the new terminology.
1827-1828: Updated method referenceMethod call has been updated to
processObjectOperationMessageOnChannelfollowing the new terminology.
1835-1836: Updated method referenceMethod call has been updated to
processObjectOperationMessageOnChannelfollowing the new terminology.
1848-1849: Updated test descriptionTest description has been updated to reference "object operation message" instead of "state operation message" to align with the new terminology.
1880-1881: Updated method referenceMethod call has been updated to
processObjectOperationMessageOnChannelfollowing the new terminology.
1886-1887: Updated method referenceMethod call has been updated to
processObjectOperationMessageOnChannelfollowing the new terminology.
1892-1893: Updated method referenceMethod call has been updated to
processObjectOperationMessageOnChannelfollowing the new terminology.
1900-1901: Updated method referenceMethod call has been updated to
processObjectOperationMessageOnChannelfollowing the new terminology.
1906-1907: Updated method referenceMethod call has been updated to
processObjectOperationMessageOnChannelfollowing the new terminology.
1912-1913: Updated method referenceMethod call has been updated to
processObjectOperationMessageOnChannelfollowing the new terminology.
1920-1927: Updated assertion messagesAssertion messages have been updated to reference "OBJECT_DELETE and another object op" instead of "STATE_DELETE and another state op" to align with the new terminology.
1934-1935: Updated test descriptionTest description has been updated to reference "object operation messages" instead of "state operation messages" to align with the new terminology.
1938-1942: Updated comment and method referenceComment now references "new sync sequence" instead of "new state sync sequence" and the method call has been updated to
processObjectStateMessageOnChannel, both following the new terminology.
1947-1948: Updated method referenceMethod call has been updated to
processObjectOperationMessageOnChannelfollowing the new terminology.
1959-1961: Updated assertion messageAssertion message has been updated to reference "during OBJECT_SYNC" instead of "during STATE_SYNC" to align with the new terminology.
1966-1967: Updated test descriptionTest description has been updated to reference "object operation messages" instead of "state operation messages" to align with the new terminology.
1970-1974: Updated comment and method referenceComment now references "sync sequence" instead of "state sync sequence" and the method call has been updated to
processObjectStateMessageOnChannel, both following the new terminology.
1979-1980: Updated method referenceMethod call has been updated to
processObjectOperationMessageOnChannelfollowing the new terminology.
1990-1993: Updated method referenceMethod call has been updated to
processObjectStateMessageOnChannelfollowing the new terminology.
2002-2008: Updated assertion messagesAssertion messages have been updated to reference "OBJECT_SYNC has ended" instead of "STATE_SYNC has ended" to align with the new terminology.
2015-2016: Updated test descriptionTest description has been updated to reference "object operation messages" instead of "state operation messages" to align with the new terminology.
2019-2023: Updated comment and method referenceComment now references "sync sequence" instead of "state sync sequence" and the method call has been updated to
processObjectStateMessageOnChannel, both following the new terminology.
2028-2029: Updated method referenceMethod call has been updated to
processObjectOperationMessageOnChannelfollowing the new terminology.
2038-2042: Updated method referenceMethod call has been updated to
processObjectStateMessageOnChannelfollowing the new terminology.
2045-2046: Updated method referenceMethod call has been updated to
processObjectOperationMessageOnChannelfollowing the new terminology.
2053-2056: Updated method referenceMethod call has been updated to
processObjectStateMessageOnChannelfollowing the new terminology.
2062-2070: Updated assertion messagesAssertion messages have been updated to reference "OBJECT_SYNC has ended" instead of "STATE_SYNC has ended" to align with the new terminology.
2076-2077: Updated test descriptionTest description has been updated to reference "object operation messages" instead of "state operation messages" to align with the new terminology.
2080-2123: Updated method reference and commentsMethod call has been updated to
processObjectStateMessageOnChanneland comments have been updated to reference "object state messages" instead of "state state messages" to align with the new terminology.
2166-2168: Updated method referenceMethod call has been updated to
processObjectStateMessageOnChannelfollowing the new terminology.
2185-2192: Updated assertion messagesAssertion messages have been updated to reference "OBJECT_SYNC has ended" instead of "STATE_SYNC has ended" to align with the new terminology.
2198-2199: Updated test descriptionTest description has been updated to reference "object operation messages" and "OBJECT_SYNC" instead of "state operation messages" and "STATE_SYNC" to align with the new terminology.
2202-2206: Updated method referenceMethod call has been updated to
processObjectStateMessageOnChannelfollowing the new terminology.
2211-2217: Updated method referenceMethod call has been updated to
processObjectOperationMessageOnChannelfollowing the new terminology.
2222-2225: Updated method referenceMethod call has been updated to
processObjectStateMessageOnChannelfollowing the new terminology.
2240-2258: Updated assertion messagesAssertion messages have been updated to reference "OBJECT_SYNC has ended" instead of "STATE_SYNC has ended" to align with the new terminology.
2684-2685: Updated test descriptionTest description has been updated to reference "object tree" instead of "state tree" to align with the new terminology.
2705-2706: Updated assertion messageAssertion message has been updated to reference "object tree" instead of "state tree" to align with the new terminology.
2734-2736: Updated method reference and variable nameMethod reference and variable name have been updated to use
objectMessagesinstead ofstateMessagesto align with the new terminology.
2737-2738: Updated method referenceMethod call has been updated to
processObjectOperationMessageOnChannelfollowing the new terminology.
2919-2920: Updated test descriptionTest description has been updated to reference "object tree" instead of "state tree" to align with the new terminology.
2934-2943: Updated assertion messagesAssertion messages have been updated to reference "object tree" instead of "state tree" to align with the new terminology.
2970-2971: Updated method reference and variable nameMethod reference and variable name have been updated to use
objectMessagesinstead ofstateMessagesto align with the new terminology.
2973-2974: Updated method referenceMethod call has been updated to
processObjectOperationMessageOnChannelfollowing the new terminology.
3012-3013: Updated method referenceMethod call has been updated to
processObjectOperationMessageOnChannelfollowing the new terminology.
3042-3053: Updated error messageError message has been updated from "State entries should be a key-value object" to "Map entries should be a key-value object", which is more descriptive for the object-based model.
3090-3091: Updated test descriptionTest description has been updated to reference object-based terminology in the batch API context.
3417-3418: Updated method referenceMethod call has been updated to
processObjectStateMessageOnChannelfollowing the new terminology.
3475-3476: Updated method referenceMethod call has been updated to
processObjectStateMessageOnChannelfollowing the new terminology.
4098-4098: Updated method referenceMethod call has been updated from
waitForStateOperationtowaitForObjectOperationfollowing the new terminology.
4110-4111: Updated method referenceMethod call has been updated to
processObjectOperationMessageOnChannelfollowing the new terminology.
4460-4461: Updated test descriptionTest description has been updated to reference "object message publish" instead of "state message publish" to align with the new terminology.
4497-4498: Updated error messageError message has been updated to reference "object messages" instead of "state messages" to align with the new terminology.
4504-4505: Updated describe section titleDescribe section title has been updated to reference "ObjectMessage message size" instead of "StateMessage message size" to align with the new terminology.
4508-4510: Updated method referenceMethod reference has been updated from
stateMessageFromValuestoobjectMessageFromValuesto align with the new terminology.
4717-4721: Updated method referencesMultiple method references have been updated from
StateMessagetoObjectMessageto align with the new terminology.
4729-4730: Updated test descriptionTest description has been updated to reference "Objects modes" instead of "State modes" to align with the new terminology.
README.md (8)
648-648: Terminology updated correctly.The terminology change from "Live Objects" to "objects" has been applied consistently here, aligning with the overall PR objective to update internal terminology.
🧰 Tools
🪛 LanguageTool
[style] ~648-~648: Try using a synonym here to strengthen your writing.
Context: ... point for objects within a channel. It gives access to all other nested objects. ``...(GIVE_PROVIDE)
656-656: Section heading updated from "Live Object Types" to "Object Types".This change aligns with the PR objective to replace internal usage of "state" term with "objects" for LiveObjects.
660-661: Description updated to use consistent terminology.The LiveMap description has been modified to refer to "other objects" instead of "other Live Objects", maintaining consistency with the new terminology throughout the documentation.
717-717: Updated explanation of subscribing to updates.The description now uses the term "objects" instead of "Live Objects" which is consistent with the terminology changes throughout the PR.
721-721: Subscription description terminology updated.Changed from "subscribing to updates on all Live Objects" to "subscribing to updates on all objects" for consistency.
775-775: Updated object creation terminology.The text now refers to creating "LiveMap and LiveCounter objects" instead of "Live Objects", making the documentation more specific and aligned with the new terminology.
822-823: Lifecycle events description updated.The text now states that "LiveObjects emit events that allow you to monitor objects' lifecycle changes" rather than referring to "Live Objects" emitting lifecycle events, which is more accurate and consistent with the new terminology.
845-845: Deletion event log message updated.The console log message has been updated from "Live Object has been deleted" to "Object has been deleted" to align with the new terminology.
src/plugins/objects/objects.ts (23)
10-10: Import statement updated to use object-based terminology.The import has been correctly updated from
StateMessage, StateOperationActiontoObjectMessage, ObjectOperationAction, which aligns with the PR objective to rename state-related terms to object-related terms.
52-52: Updated buffer variable to use object-based terminology.The private member variable has been renamed from
_bufferedStateOperationsto_bufferedObjectOperationsto align with the terminology changes in the PR.
65-65: Updated buffer initialization to use object-based terminology.The initialization of the buffer has been updated to match the renamed variable
_bufferedObjectOperations.
215-215: Method renamed to use object-based terminology.The method has been renamed from
handleStateSyncMessagestohandleObjectSyncMessagesand its parameter type updated fromStateMessage[]toObjectMessage[], which is consistent with the PR objectives.
235-235: Method renamed to use object-based terminology.The method has been renamed from
handleStateMessagestohandleObjectMessagesand its parameter type updated fromStateMessage[]toObjectMessage[].
237-241: Updated comments to use object-based terminology.The comments have been updated to refer to "object messages" and "object operations" instead of "state messages" and "state operations", which maintains consistency in the code base.
251-251: Method parameter renamed to use object-based terminology.The parameter has been renamed from
hasStatetohasObjectsto align with the PR objective of replacing "state" with "objects".
260-261: Updated condition and comment to use object-based terminology.The condition now checks for
hasObjectsinstead ofhasState, and the comment has been updated accordingly.
296-296: Method parameter type updated to use object-based terminology.The publish method now accepts
ObjectMessage[]instead ofStateMessage[], maintaining consistency with the renamed types.
305-307: Updated encoding and size calculation to use object-based terminology.The method calls and variable names have been updated to use
ObjectMessageand related naming conventions.
310-310: Updated error message to use object-based terminology.The error message now refers to "object messages" instead of "state messages".
316-316: Updated channel method call to use object-based messages.The channel's sendState method is now called with
objectMessagesinstead ofstateMessages.
336-338: Updated comment and buffer reset in _startNewSync method.The comment now refers to "object operation" messages instead of "state operation" messages, and the buffer variable has been updated to match.
346-350: Updated comment and method call in _endSync method.The comments and method call have been updated to use object-based terminology, and the buffer variable reset has been updated to match.
388-389: Updated method call to use object-based terminology.The method call has been changed from
overrideWithStateObjecttooverrideWithObjectState, and the parameter name has been updated fromentry.stateObjecttoentry.objectState.
400-400: Updated method call to use object-based terminology.The method call has been changed from
LiveCounter.fromStateObjecttoLiveCounter.fromObjectState, and the parameter name has been updated.
404-404: Updated method call to use object-based terminology.The method call has been changed from
LiveMap.fromStateObjecttoLiveMap.fromObjectState, and the parameter name has been updated.
421-423: Method renamed to use object-based terminology.The method has been renamed from
_applyStateMessagesto_applyObjectMessagesand the parameter type updated fromStateMessage[]toObjectMessage[]. The loop variable name has also been updated to match.
427-429: Updated logging to use object-based terminology.The logging statement has been updated to use the new method name and to refer to "object operation" instead of "state operation".
433-433: Updated variable assignment to use object-based terminology.The variable assignment has been updated from
stateOperationtoobjectOperationand the property access has been updated fromstateMessage.stateOperationtoobjectMessage.operation.
435-442: Updated switch statement to use object-based action types.The switch statement now uses
ObjectOperationActionenum values instead ofStateOperationActionenum values.
448-449: Updated object pool access and method call to use object-based terminology.The code now uses
objectOperation.objectIdinstead ofstateOperation.objectId, and passesobjectOperationandobjectMessageinstead ofstateOperationandstateMessageto the method.
456-458: Updated logging to use object-based terminology.The logging statement has been updated to use the new method name and to refer to "object operation" instead of "state operation".
src/plugins/objects/objectmessage.ts (21)
9-16: Renamed enum to use object-based terminology.The
StateOperationActionenum has been renamed toObjectOperationActionwith the same set of values, which aligns with the PR objective of updating terminology.
22-23: Updated type definition and comment to use object-based terminology.The
StateValuetype has been renamed toObjectValuewith its comment updated accordingly.
25-26: Renamed interface to use object-based terminology.The
StateDatainterface has been renamed toObjectDatawith its comment updated to reflect the change.
34-35: Updated type reference in interface.The property type reference has been updated from
StateValuetoObjectValueto maintain consistency with the renamed type.
38-44: Renamed interface and updated its properties to use object-based terminology.The
StateMapOpinterface has been renamed toMapOpwith its comment updated, and its property type reference has been updated fromStateDatatoObjectData.
46-50: Renamed interface to use object-based terminology.The
StateCounterOpinterface has been renamed toCounterOpwith its comment updated.
53-65: Renamed interface and updated its properties to use object-based terminology.The
StateMapEntryinterface has been renamed toMapEntry, and its property type reference has been updated fromStateDatatoObjectData.
67-73: Renamed interface and updated its properties to use object-based terminology.The
StateMapinterface has been renamed toObjectMap, and its property type reference has been updated fromRecord<string, StateMapEntry>toRecord<string, MapEntry>.
75-79: Renamed interface to use object-based terminology.The
StateCounterinterface has been renamed toObjectCounterwith its comment updated.
81-116: Renamed interface and updated its properties to use object-based terminology.The
StateOperationinterface has been renamed toObjectOperation, with its properties and comments updated to reflect the new terminology. Property names likestateMapOp,stateCounterOp,stateMap, andstateCounterhave been renamed to their object-based equivalents.
117-141: Renamed interface and updated its properties to use object-based terminology.The
StateObjectinterface has been renamed toObjectState, with its properties and comments updated to reflect the new terminology. The type reference forcreateOphas been updated fromStateOperationtoObjectOperation, and properties likestateMapandstateCounterhave been renamed to their object-based equivalents.
146-168: Renamed class and updated its properties to use object-based terminology.The
StateMessageclass has been renamed toObjectMessage, with its properties and comments updated to reflect the new terminology. Properties likestateOperationandstateObjecthave been renamed tooperationandobject, and their type references have been updated accordingly.
181-196: Updated method signature and implementation to use object-based terminology.The
encodestatic method now works withObjectMessageinstead ofStateMessage, and the method calls inside have been updated to use the new names like_encodeObjectOperationand_encodeObjectState.
317-341: Renamed method and updated its implementation to use object-based terminology.The
_encodeStateOperationmethod has been renamed to_encodeObjectOperation, with its parameter type, variable names, and method calls updated to reflect the new terminology.
343-361: Renamed method and updated its implementation to use object-based terminology.The
_encodeStateObjectmethod has been renamed to_encodeObjectState, with its parameter type, variable names, and method calls updated to reflect the new terminology.
363-371: Renamed method to use object-based terminology.The
_encodeStateDatamethod has been renamed to_encodeObjectData, maintaining the same functionality but with updated naming.
379-407: Updated method implementation to use object-based terminology.The
_encodeForWireProtocolmethod now works withObjectMessageinstead ofStateMessage, and its return type, variable names, and method calls have been updated to reflect the new terminology.
416-436: Updated toJSON method to use object-based terminology.The
toJSONmethod's return type, variable names, and property names have been updated to reflect the new object-based terminology.
439-457: Updated toString method to use object-based terminology.The string representation now starts with
[ObjectMessageinstead of[StateMessage], and refers tooperationandobjectproperties instead ofstateOperationandstateObject.
476-507: Renamed methods for calculating message size to use object-based terminology.Methods like
_getStateOperationSize,_getStateMapOpSize, etc. have been renamed to their object-based equivalents, with their implementation updated to call the newly renamed methods.
511-574: Renamed remaining methods for calculating message size to use object-based terminology.Methods like
_getStateMapSize,_getStateCounterSize, etc. have been renamed to their object-based equivalents, with their implementation updated accordingly.src/plugins/objects/livecounter.ts (14)
3-3: Updated imports to use object-based terminology.The imports have been updated to use the new object-based types:
CounterOp,ObjectMessage,ObjectOperation,ObjectOperationAction, andObjectStateinstead of their state-based equivalents.
30-33: Method renamed to use object-based terminology.The
fromStateObjectmethod has been renamed tofromObjectStatewith its parameter type updated fromStateObjecttoObjectState. The implementation has been updated to calloverrideWithObjectStateinstead ofoverrideWithStateObject.
42-45: Method renamed to use object-based terminology.The
fromStateOperationmethod has been renamed tofromObjectOperationwith its parameter type updated fromStateOperationtoObjectOperation. The implementation has been updated to use the new parameter name.
51-71: Updated method to return ObjectMessage and use Number.isFinite.The
createCounterIncMessagemethod now returnsObjectMessageinstead ofStateMessage, and has been updated to useNumber.isFiniteinstead ofisFinitefor safer numeric checks. The implementation creates anObjectMessagewith anObjectOperationcontaining the COUNTER_INC action.The change from
isFinitetoNumber.isFiniteis important because the globalisFinite()attempts type coercion whileNumber.isFinite()does not, making it safer for strict number validation.🧰 Tools
🪛 Biome (1.9.4)
[error] 54-54: isFinite is unsafe. It attempts a type coercion. Use Number.isFinite instead.
See the MDN documentation for more details.
Unsafe fix: Use Number.isFinite instead.(lint/suspicious/noGlobalIsFinite)
76-112: Updated method to return ObjectMessage with proper object operation.The
createCounterCreateMessagemethod now returnsPromise<ObjectMessage>instead ofPromise<StateMessage>, and has been updated to create anObjectMessagewith anObjectOperationcontaining the COUNTER_CREATE action.
117-123: Updated method return type to use object-based terminology.The
createInitialValueObjectmethod now returnsPick<ObjectOperation, 'counter'>instead ofPick<StateOperation, 'stateCounter'>, with the property name updated to match the new terminology.
141-143: Updated method calls to use object-based terminology.The
incrementmethod now callscreateCounterIncMessageto create anObjectMessageinstead of aStateMessage.
152-154: Updated numeric validation to use Number.isFinite.Similar to the change in line 54, the code now uses
Number.isFiniteinstead ofisFinitefor safer numeric validation.🧰 Tools
🪛 Biome (1.9.4)
[error] 152-152: isFinite is unsafe. It attempts a type coercion. Use Number.isFinite instead.
See the MDN documentation for more details.
Unsafe fix: Use Number.isFinite instead.(lint/suspicious/noGlobalIsFinite)
162-220: Updated method to accept object-based parameters and use object-based action types.The
applyOperationmethod now acceptsObjectOperationandObjectMessageinstead ofStateOperationandStateMessage, and the switch statement now usesObjectOperationActionenum values. Error messages and variable names have been updated to reflect the new terminology.
225-278: Method renamed and updated to use object-based terminology.The
overrideWithStateObjectmethod has been renamed tooverrideWithObjectStatewith its parameter type updated fromStateObjecttoObjectState. The implementation has been updated to use the new parameter name and access properties with the new naming convention.
297-306: Method updated to use object-based parameter and property access.The
_mergeInitialDataFromCreateOperationmethod now acceptsobjectOperation: ObjectOperationinstead ofstateOperation: StateOperation, and accesses the counter property asobjectOperation.counter?.countinstead ofstateOperation.stateCounter?.count.
308-314: Method updated to use object-based parameter.The
_throwNoPayloadErrormethod now acceptsop: ObjectOperationinstead ofop: StateOperation.
316-331: Method updated to use object-based parameter.The
_applyCounterCreatemethod now acceptsop: ObjectOperationinstead ofop: StateOperation.
333-336: Method updated to use object-based parameter.The
_applyCounterIncmethod now acceptsop: CounterOpinstead ofop: StateCounterOp.src/plugins/objects/livemap.ts (21)
7-16: Properly renamed imports and exports from 'state' to 'object' terminology.All imports and exports have been correctly updated to use the new object-based terminology in line with the PR objectives. The imports now properly reference the renamed file 'objectmessage.ts' and all imported types use the 'Object' prefix instead of 'State'.
19-32: Interface and type names successfully transformed to object-based terminology.The interfaces have been consistently renamed from 'StateIdStateData' to 'ObjectIdObjectData' and 'ValueStateData' to 'ValueObjectData', maintaining the same structure and documentation while aligning with the new terminology.
34-48: Data structures appropriately updated with new type names.The type and interface definitions have been properly updated, including the rename of 'StateData' to 'ObjectData' and 'MapEntry' to 'LiveMapEntry'. All references in properties like the 'data' field now correctly use the new types.
72-82: Successfully renamed method signatures to match new terminology.The method signatures have been properly updated from 'fromStateObject' to 'fromObjectState' and corresponding parameter names have been changed from 'stateObject' to 'objectState'. The method still maintains the same functionality.
90-97: Method signature correctly updated from State to Object terminology.The 'fromStateOperation' method has been properly renamed to 'fromObjectOperation' with updated parameter types to align with the new object-based model.
102-133: Method return type properly updated from StateMessage to ObjectMessage.The 'createMapSetMessage' method now correctly returns an 'ObjectMessage' instead of 'StateMessage', and all internal references now use the new 'ObjectOperationAction' and 'ObjectOperation' types.
138-162: Method properly updates return type to ObjectMessage.The 'createMapRemoveMessage' method has been successfully updated to return an 'ObjectMessage' and all internal references now use the new terminology.
192-230: Promise return type correctly updated to ObjectMessage.The createMapCreateMessage method now properly returns a Promise instead of Promise, and all internal references to ObjectOperationAction and ObjectMessage are correctly updated.
235-255: Type definitions and internal object creation properly updated.The 'createInitialValueObject' method now correctly returns a Pick<ObjectOperation, 'map'> and uses the new MapEntry type in its local variable declarations and object creation.
285-287: Method reference renamed from StateData to ObjectData.The internal call has been properly renamed from '_getResolvedValueFromStateData' to '_getResolvedValueFromObjectData' to match the new method name.
315-316: Variable type and method call correctly updated.The value retrieval now correctly uses the renamed '_getResolvedValueFromObjectData' method, maintaining consistency with the new object-based terminology.
365-433: Operation action enums properly updated to object-based terminology.The 'applyOperation' method signature has been correctly updated to use 'ObjectOperation' and 'ObjectMessage', and all case statements now use the correct 'ObjectOperationAction' enum values like 'MAP_CREATE', 'MAP_SET', 'MAP_REMOVE', and 'OBJECT_DELETE'.
438-507: Method and parameter names correctly updated for consistency.The 'overrideWithStateObject' method has been renamed to 'overrideWithObjectState' and all internal references to 'createOp' and object state properties now use the new object-based terminology.
583-617: Method parameter type properly updated.The '_mergeInitialDataFromCreateOperation' method now correctly takes an 'ObjectOperation' parameter instead of a 'StateOperation', maintaining consistent terminology throughout the class.
619-625: Error handling updated with new terminology.The '_throwNoPayloadError' method now correctly expects an 'ObjectOperation' parameter rather than a 'StateOperation', ensuring consistent error handling.
627-650: Internal method properly updated to use object terminology.The '_applyMapCreate' method has been updated to use 'ObjectOperation' instead of 'StateOperation', maintaining the semantic consistency of the codebase.
652-702: Map operation type updated correctly.The '_applyMapSet' method parameter has been updated from 'StateMapOp' to 'MapOp', and all internal references to data structures have been updated to use the new object-based terminology.
704-733: Map remove operation parameter type updated.The '_applyMapRemove' method parameter has been correctly changed from 'StateMapOp' to 'MapOp', and all internal references to entry types use the new terminology.
763-789: Map entries method parameter type updated.The '_liveMapDataFromMapEntries' method now correctly accepts a parameter of type 'Record<string, MapEntry>' instead of 'Record<string, StateMapEntry>', and all internal data structure references have been updated accordingly.
791-812: Method renamed and updated to reflect object terminology.The '_getResolvedValueFromStateData' method has been properly renamed to '_getResolvedValueFromObjectData' and its parameter and return types have been updated to use 'ObjectData' and 'ObjectValue' respectively.
814-831: Method parameter type updated for consistency.The '_isMapEntryTombstoned' method now correctly accepts a parameter of type 'LiveMapEntry' instead of 'MapEntry', completing the terminology update throughout the class.
This PR introduces next changes
statementions in comments / internal API. Usesobjectsinstead where possibleSTATEmessage action ->OBJECTSTATE_SYNCmessage action ->OBJECT_SYNCHAS_STATEflag ->HAS_OBJECTStateMessagetype ->ObjectMessageStateOperationtype ->ObjectOperationStateObjecttype ->ObjectStateStateDatatype ->ObjectDataStateValuetype ->ObjectValuestatemessage.tsfilename toobjectmessage.tsThis brings ably-js LiveObjects implementation in line with the naming changes introduced in the spec PR.
Resolves PUB-1539
Summary by CodeRabbit
Documentation
Refactor
Tests