Skip to content

Conversation

@VeskeR
Copy link
Contributor

@VeskeR VeskeR commented Mar 27, 2025

This PR introduces 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
  • 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
  • changes statemessage.ts filename to objectmessage.ts

This brings ably-js LiveObjects implementation in line with the naming changes introduced in the spec PR.

Resolves PUB-1539

Summary by CodeRabbit

  • Documentation

    • Enhanced the documentation by standardizing terminology and headers for improved clarity.
  • Refactor

    • Streamlined naming conventions across APIs and operations, shifting from older state-based terms to more consistent object-based language.
  • Tests

    • Updated test cases and examples to reflect the new messaging and operation conventions, ensuring consistency with the object-based model.

@VeskeR VeskeR requested a review from mschristensen March 27, 2025 10:52
@coderabbitai
Copy link

coderabbitai bot commented Mar 27, 2025

Walkthrough

This 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

File(s) Change Summary
README.md Updated terminology in documentation, replacing "Live Objects" with "objects" and adjusting section headers.
ably.d.ts, src/common/lib/types/protocolmessage.ts Renamed types and constants (e.g., StateValueObjectValue; STATE/STATE_SYNCOBJECT/OBJECT_SYNC), updated comments for consistency.
src/common/lib/client/realtimechannel.ts, src/common/lib/transport/protocol.ts Changed method parameters and internal logic from StateMessage to ObjectMessage; updated action and flag checks accordingly.
scripts/moduleReport.ts Modified allowed file list by replacing statemessage.ts with objectmessage.ts.
src/plugins/objects/* Across multiple files (e.g., livecounter, livemap, liveobject, batchcontext, index.ts, objectmessage.ts): Renamed methods, variables, and types from state-based to object-based nomenclature; updated imports/exports and documentation comments.
test/* Updated test helpers, private API identifiers, and test cases by renaming functions and comments from state to object terminology.

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
Loading

Possibly related PRs

Suggested reviewers

  • kaschula

Poem

I hopped through the code with a twitch and a bound,
Changing “state” to “object” in every sight and sound.
My little paws dance on keys so bright,
Bringing clarity and order into the light.
A rabbit’s joy in each rename we found!
🥕🐇

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.js

Warning

Review ran into problems

🔥 Problems

Errors were encountered while retrieving linked issues.

Errors (1)
  • PUB-1539: Cannot read properties of undefined (reading 'displayName')

🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

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

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

CodeRabbit Commands (Invoked using PR comments)

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

Other keywords and placeholders

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

CodeRabbit Configuration File (.coderabbit.yaml)

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

Documentation and Community

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

@github-actions github-actions bot temporarily deployed to staging/pull/1992/bundle-report March 27, 2025 10:52 Inactive
@github-actions github-actions bot temporarily deployed to staging/pull/1992/features March 27, 2025 10:52 Inactive
@github-actions github-actions bot temporarily deployed to staging/pull/1992/typedoc March 27, 2025 10:52 Inactive
@VeskeR VeskeR force-pushed the PUB-1539/rename-internal-state-term-to-objects branch from 70b532e to c6deab8 Compare March 27, 2025 10:54
@github-actions github-actions bot temporarily deployed to staging/pull/1992/bundle-report March 27, 2025 10:54 Inactive
@github-actions github-actions bot temporarily deployed to staging/pull/1992/typedoc March 27, 2025 10:54 Inactive
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 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: ...d synced events 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 terminology

The 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 processing
src/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 the synced event, consider adding additional checks or error handling to avoid hanging.


296-317: publish method
Emits object-based operations via this._channel.sendState(...).

Consider renaming sendState to better reflect the shift to object operations, e.g. sendObjects.

src/plugins/objects/objectmessage.ts (1)

146-582: ObjectMessage class
Refactor from StateMessage to ObjectMessage is thorough, covering encode/decode logic consistently.

The channel field 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; prefer Number.isFinite for 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

📥 Commits

Reviewing files that changed from the base of the PR and between 480ff4c and c6deab8.

📒 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.STATE has been properly replaced with actions.OBJECT in the condition that determines when acknowledgment is required for messages. This change is consistent with the updates to action constants in protocolmessage.ts.

src/plugins/objects/batchcontextlivemap.ts (2)

52-53: Variable and method names updated correctly.

The variable name has been changed from stateMessage to msg, and the method call from queueStateMessage to queueMessage, 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 stateMessage to msg, and the method call from queueStateMessage to queueMessage, consistent with the changes made in the set method 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 ObjectMessage instead of StateMessage, which is consistent with the file renaming from statemessage.ts to objectmessage.ts as 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.ts to objectmessage.ts in 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:

  1. Variable renamed from stateMessage to msg
  2. Method call updated from queueStateMessage to queueMessage

This 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 StateMessage to ObjectMessage to align with the renaming of the file from statemessage.ts to objectmessage.ts as 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 _queuedMessages has been properly changed from StateMessage[] to ObjectMessage[] 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 queueStateMessage to queueMessage and its parameter type changed from StateMessage to ObjectMessage, maintaining the intended functionality while using the new terminology.

test/realtime/objects.test.js (122)

90-91: Function rename aligns with terminology update

The function has been properly renamed from stateMessageFromValues to objectMessageFromValues and now correctly calls ObjectsPlugin.ObjectMessage.fromValues instead of StateMessage.fromValues.


114-114: Function rename for consistency with terminology changes

Function waitForStateOperation has been appropriately renamed to waitForObjectOperation to align with the object-based terminology.


139-140: Updated comment to reflect new terminology

Comment has been updated to reference "fixture data" instead of potentially using "state" terminology.


182-197: Updated test and comments to use new OBJECT terminology

Test description and comments have been updated to reference "OBJECT" protocol message instead of "STATE".


207-208: Updated comment to reflect OBJECT_SYNC terminology

Comment now correctly refers to "OBJECT_SYNC" instead of "STATE_SYNC" message.


214-229: Updated test and comments for OBJECT_SYNC terminology

Test description and code now properly use "OBJECT_SYNC" protocol message references.


243-244: Updated comments to use OBJECT_SYNC terminology

Comment now correctly refers to "OBJECT_SYNC" instead of "STATE_SYNC" message.


276-298: Updated test description to use object terminology

Test description properly updated to reference "LiveObject" instead of likely "LiveState".


309-320: Updated test description to use objects terminology

Test description now properly uses "objects" instead of "states" terminology.


327-328: Updated expectation message to use OBJECT_SYNC terminology

The expectation message now correctly refers to "OBJECT_SYNC" instead of "STATE_SYNC".


338-342: Updated test description to use OBJECT_SYNC terminology

Test description now properly refers to "OBJECT_SYNC" instead of "STATE_SYNC".


364-373: Updated test description and expectations to use OBJECT_SYNC terminology

Test description and expectations now correctly use "OBJECT_SYNC" instead of "STATE_SYNC".


395-395: Updated expectation message to use OBJECT_SYNC terminology

Expectation message now correctly refers to "OBJECT_SYNC" instead of "STATE_SYNC".


415-416: Updated expectation messages to use OBJECT_SYNC terminology

Expectation messages now correctly refer to "OBJECT_SYNC" instead of "STATE_SYNC".


423-424: Updated test description to use OBJECT_SYNC terminology

Test description now correctly refers to "OBJECT_SYNC" instead of "STATE_SYNC".


442-442: Updated expectation message to use OBJECT_SYNC terminology

Expectation message now correctly refers to "OBJECT_SYNC" instead of "STATE_SYNC".


486-487: Updated test description to use OBJECT_SYNC terminology

Test description now correctly refers to "OBJECT_SYNC" instead of "STATE_SYNC".


519-520: Updated test description to use OBJECT_SYNC terminology

Test description now correctly refers to "OBJECT_SYNC" instead of "STATE_SYNC".


672-673: Updated variable name to use objects terminology

Variable renamed from stateSyncSequenceScenarios to objectSyncSequenceScenarios.


674-675: Updated test description to use OBJECT_SYNC terminology

Test description now correctly refers to "OBJECT_SYNC" instead of "STATE_SYNC".


680-684: Updated comments and method call to use object terminology

Updated to use processObjectStateMessageOnChannel and OBJECT_SYNC terminology in comments.


715-716: Updated expectation message to use object terminology

Expectation message now correctly refers to OBJECT_SYNC with "tombstone=true" for a map object.


719-722: Updated expectation messages to use object terminology

Expectation messages now correctly refer to OBJECT_SYNC with "tombstone=true" for objects.


728-729: Updated test description to use OBJECT_SYNC terminology

Test description now correctly refers to "OBJECT_SYNC" instead of "STATE_SYNC".


740-743: Updated expectation message to use OBJECT_SYNC terminology

Expectation message now correctly refers to "OBJECT_SYNC" with "tombstone=true".


746-748: Updated comment to use OBJECT_SYNC terminology

Comment now correctly refers to "OBJECT_SYNC" message where an object is tombstoned.


771-774: Updated expectation message to use OBJECT_SYNC terminology

Expectation message now correctly refers to "OBJECT_SYNC" with "tombstone=true".


781-782: Updated test description to use OBJECT_SYNC terminology

Test description now correctly refers to "OBJECT_SYNC" instead of "STATE_SYNC".


798-799: Updated expectation message to use OBJECT_SYNC terminology

Expectation message now correctly refers to "OBJECT_SYNC sequence with 'tombstone=true'".


807-808: Updated comment to use OBJECT_SYNC terminology

Comment now correctly refers to "OBJECT_SYNC" message with tombstoned object.


838-839: Updated test description to use object terminology

Test description now correctly refers to "object operation messages" instead of "state operation messages".


902-903: Updated test description to use object terminology

Test description now correctly refers to "MAP_CREATE with object ids object operation messages".


978-979: Updated test description to use object terminology

Test description now correctly refers to "MAP_CREATE object operation messages".


993-1004: Updated method calls to use object terminology

Method calls now correctly use processObjectOperationMessageOnChannel instead of likely processStateOperationMessageOnChannel.


1016-1029: Updated method call to use object terminology

Method call now correctly uses processObjectOperationMessageOnChannel.


1060-1061: Updated test description to use object terminology

Test description now correctly refers to "MAP_SET with primitives object operation messages".


1109-1110: Updated test description to use object terminology

Test description now correctly refers to "MAP_SET with object ids object operation messages".


1167-1168: Updated test description to use object terminology

Test description now correctly refers to "MAP_SET object operation messages".


1173-1196: Updated method calls to use object terminology

Method calls now correctly use processObjectOperationMessageOnChannel.


1236-1237: Updated test description to use object terminology

Test description now correctly refers to "MAP_REMOVE object operation messages".


1299-1300: Updated test description to use object terminology

Test description now correctly refers to "MAP_REMOVE object operation messages".


1305-1344: Updated method calls to use object terminology

Method calls now correctly use processObjectOperationMessageOnChannel.


1371-1372: Updated test description to use object terminology

Test description now correctly refers to "COUNTER_CREATE object operation messages".


1424-1425: Updated test description to use object terminology

Test description now correctly refers to "COUNTER_CREATE object operation messages".


1439-1468: Updated method calls to use object terminology

Method calls now correctly use processObjectOperationMessageOnChannel.


1492-1493: Updated test description to use object terminology

Test description now correctly refers to "COUNTER_INC object operation messages".


1556-1557: Updated test description to use object terminology

Test description now correctly refers to "COUNTER_INC object operation messages".


1562-1598: Updated method calls to use object terminology

Method calls now correctly use processObjectOperationMessageOnChannel.


1601-1602: Updated test description to use object terminology

Test description now correctly refers to "OBJECT_DELETE object operation messages".


1626-1637: Updated method calls to use object terminology

Method calls now correctly use processObjectOperationMessageOnChannel.


1651-1670: Updated method calls to use object terminology

Method calls now correctly use processObjectOperationMessageOnChannel.


1678-1679: Updated test description to use object terminology

Test description now correctly refers to "OBJECT_DELETE object operation messages".


1693-1722: Updated method calls to use object terminology

Method calls now correctly use processObjectOperationMessageOnChannel.


1806-1817: Updated method calls to use object terminology

Method calls now correctly use processObjectOperationMessageOnChannel.


1840-1853: Updated method calls to use object terminology

Method calls now correctly use processObjectOperationMessageOnChannel.


1861-1862: Updated test description to use object terminology

Test description now correctly refers to "object operation message" instead of "state operation message".


1893-1940: Updated method calls and comments to use object terminology

Method calls now correctly use processObjectOperationMessageOnChannel and comments have been updated to reflect object terminology.


1947-1948: Updated test description to use object terminology

Test description now correctly refers to "object operation messages" instead of "state operation messages".


1951-1955: Updated comments and method call to use object terminology

Comments and method call now correctly use OBJECT_SYNC terminology.


1960-1973: Updated method call and comments to use object terminology

Method call now correctly uses processObjectOperationMessageOnChannel and comments have been updated.


1979-1980: Updated test description to use object terminology

Test description now correctly refers to "object operation messages" instead of "state operation messages".


1983-1987: Updated comment and method call to use object terminology

Comment and method call now correctly use OBJECT_SYNC terminology.


1992-2006: Updated method call to use object terminology

Method call now correctly uses processObjectOperationMessageOnChannel.


2015-2016: Updated expectation message to use object terminology

Expectation message now correctly refers to operations after OBJECT_SYNC has ended.


2019-2021: Updated expectation message to use object terminology

Expectation message now correctly refers to operations after OBJECT_SYNC has ended.


2028-2029: Updated test description to use object terminology

Test description now correctly refers to "object operation messages" instead of "state operation messages".


2032-2036: Updated comment and method call to use object terminology

Comment and method call now correctly use OBJECT_SYNC terminology.


2041-2063: Updated method call to use object terminology

Method call now correctly uses processObjectOperationMessageOnChannel.


2066-2069: Updated method call to use object terminology

Method call now correctly uses processObjectStateMessageOnChannel.


2075-2076: Updated expectation message to use object terminology

Expectation message now correctly refers to operations when OBJECT_SYNC has ended.


2082-2083: Updated expectation message to use object terminology

Expectation message now correctly refers to operations received during OBJECT_SYNC sequence.


2089-2090: Updated test description to use object terminology

Test description now correctly refers to "object operation messages" instead of "state operation messages".


2094-2101: Updated comments and method call to use object terminology

Comments and method call now correctly use OBJECT_SYNC terminology.


2178-2181: Updated method call to use object terminology

Method call now correctly uses processObjectStateMessageOnChannel.


2198-2199: Updated expectation message to use object terminology

Expectation message now correctly refers to operations after OBJECT_SYNC has ended.


2204-2205: Updated expectation message to use object terminology

Expectation message now correctly refers to counter value after OBJECT_SYNC has ended.


2211-2212: Updated test description to use object terminology

Test description now correctly refers to "object operation messages" instead of "state operation messages".


2215-2219: Updated comment and method call to use object terminology

Comment and method call now correctly use OBJECT_SYNC terminology.


2224-2230: Updated method call to use object terminology

Method call now correctly uses processObjectOperationMessageOnChannel.


2235-2238: Updated method call to use object terminology

Method call now correctly uses processObjectStateMessageOnChannel.


2252-2253: Updated comment to use object terminology

Comment now correctly refers to operations after OBJECT_SYNC has ended.


2259-2260: Updated expectation message to use object terminology

Expectation message now correctly refers to operations after OBJECT_SYNC has ended.


2264-2265: Updated expectation message to use object terminology

Expectation message now correctly refers to operations after OBJECT_SYNC has ended.


2270-2271: Updated expectation message to use object terminology

Expectation message now correctly refers to operations received outside of OBJECT_SYNC.


2697-2698: Updated test description to use object terminology

Test description now correctly refers to "LiveCounter created with Objects.createCounter".


2718-2719: Updated expectation message to use object terminology

Expectation message now correctly refers to "counter assigned to the object tree".


2747-2749: Updated method name to use object terminology

Method name now correctly uses objectMessages parameter name.


2750-2751: Updated method call to use object terminology

Method call now correctly uses processObjectOperationMessageOnChannel.


2932-2933: Updated test description to use object terminology

Test description now correctly refers to "LiveMap created with Objects.createMap".


2947-2948: Updated expectation message to use object terminology

Expectation message now correctly refers to "map assigned to the object tree".


2951-2952: Updated expectation message to use object terminology

Expectation message now correctly refers to "map assigned to the object tree".


2955-2956: Updated expectation message to use object terminology

Expectation message now correctly refers to "map assigned to the object tree".


2983-2987: Updated method parameters to use object terminology

Method parameters now correctly use objectMessages instead of likely stateMessages.


3026-3039: Updated method call to use object terminology

Method call now correctly uses processObjectOperationMessageOnChannel.


3103-3104: Updated test description to use object terminology

Test 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 terminology

Test description now correctly refers to "batch API access API methods on objects".


3188-3189: Updated test description to use object terminology

Test description now correctly refers to objects rather than states.


4476-4477: Updated test description to use object terminology

Test description now correctly refers to "object message publish" instead of "state message publish".


4513-4514: Updated error message to use object terminology

Error message now correctly refers to "object messages" instead of "state messages".


4520-4521: Updated section header to use object terminology

Section header now correctly refers to "ObjectMessage message size".


4524-4525: Updated method call to use object terminology

Method call now correctly uses objectMessageFromValues instead of stateMessageFromValues.


4531-4532: Updated method call to use object terminology

Method call now correctly uses objectMessageFromValues instead of stateMessageFromValues.


4538-4539: Updated method call to use object terminology

Method call now correctly uses objectMessageFromValues instead of stateMessageFromValues.


4545-4546: Updated method call to use object terminology

Method call now correctly uses objectMessageFromValues instead of stateMessageFromValues.


4552-4564: Updated method call to use object terminology

Method call now correctly uses objectMessageFromValues instead of stateMessageFromValues.


4569-4578: Updated method call to use object terminology

Method call now correctly uses objectMessageFromValues instead of stateMessageFromValues.


4583-4595: Updated method call to use object terminology

Method call now correctly uses objectMessageFromValues instead of stateMessageFromValues.


4600-4609: Updated method call to use object terminology

Method call now correctly uses objectMessageFromValues instead of stateMessageFromValues.


4614-4615: Updated method call to use object terminology

Method call now correctly uses objectMessageFromValues instead of stateMessageFromValues.


4621-4627: Updated method call to use object terminology

Method call now correctly uses objectMessageFromValues instead of stateMessageFromValues.


4632-4634: Updated method call to use object terminology

Method call now correctly uses objectMessageFromValues instead of stateMessageFromValues.


4639-4645: Updated method call to use object terminology

Method call now correctly uses objectMessageFromValues instead of stateMessageFromValues.


4650-4652: Updated method call to use object terminology

Method call now correctly uses objectMessageFromValues instead of stateMessageFromValues.


4657-4659: Updated method call to use object terminology

Method call now correctly uses objectMessageFromValues instead of stateMessageFromValues.


4664-4682: Updated method call to use object terminology

Method call now correctly uses objectMessageFromValues instead of stateMessageFromValues.


4693-4695: Updated method call to use object terminology

Method call now correctly uses objectMessageFromValues instead of stateMessageFromValues.


4700-4702: Updated method call to use object terminology

Method call now correctly uses objectMessageFromValues instead of stateMessageFromValues.


4707-4709: Updated method call to use object terminology

Method call now correctly uses objectMessageFromValues instead of stateMessageFromValues.


4714-4726: Updated method call to use object terminology

Method call now correctly uses objectMessageFromValues instead of stateMessageFromValues.


4732-4738: Updated private API recording and method calls to use object terminology

Private API recordings and method calls now correctly use ObjectMessage instead of StateMessage.


4745-4746: Updated test description to use object terminology

Test description now correctly refers to "Objects modes" instead of "States modes".


5552-5557: Updated variable name to use object terminology

Variable references now correctly use objectSyncSequenceScenarios instead of stateSyncSequenceScenarios.

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 STATE to OBJECT and STATE_SYNC to OBJECT_SYNC while preserving the same action codes.


53-53: Flag name updated correctly.

Changed flag name from HAS_STATE to HAS_OBJECT while preserving the bit position (1 << 7).


129-135: Type and method calls updated correctly.

Updated the variable type from StateMessage[] to ObjectMessage[] and corresponding method calls to use the new ObjectMessage.fromValues method.


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 stringify method to use ObjectMessage.fromValuesArray.


222-222: Property type updated correctly.

Updated the state property type in the ProtocolMessage class from StateMessage[] to ObjectMessage[] to match the renamed type.

src/common/lib/client/realtimechannel.ts (9)

33-33: Import statement updated correctly.

Changed the import to use ObjectMessage instead of StateMessage while 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 STATE to OBJECT.


527-527: Message action check updated correctly.

Updated the action check in the processMessage method to use actions.OBJECT instead of actions.STATE.


545-545: Flag check updated correctly.

Changed the flag check from HAS_STATE to HAS_OBJECT in the attached handler.


555-556: Method call updated correctly.

Updated the method call to onAttached to pass the hasObject flag instead of the hasState flag.


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 _decodeAndPrepareMessages method to use ObjectMessage instead of StateMessage.


812-812: Method parameter updated correctly.

Added hasObject parameter to the notifyState method to replace the previous hasState parameter.


834-835: Method call updated correctly.

Updated the method call to actOnChannelState to provide the hasObject flag instead of hasState.

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 stateOperationMessage to objectOperationMessage and 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 stateObjectMessage to objectStateMessage and maintained the same functionality. The action code (20) remains the same.


266-279: Method renamed and call updated correctly.

Renamed the method from processStateOperationMessageOnChannel to processObjectOperationMessageOnChannel and updated the method call inside to use the new name.


281-294: Method renamed and call updated correctly.

Renamed the method from processStateObjectMessageOnChannel to processObjectStateMessageOnChannel and 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 terminology

The import statement now correctly uses ObjectMessage and ObjectState instead of their state-based counterparts, in line with the PR objectives.


7-7: Interface property renamed for consistency

The property has been updated from stateObject to objectState, keeping the same functionality while aligning with the new terminology.


52-62: Method name and parameters updated successfully

The method has been properly renamed from applyStateSyncMessages to applyObjectSyncMessages, with parameters updated accordingly. The logging message has also been updated to reflect the new terminology.


64-69: Variable names updated to match new terminology

Variable 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 terminology

The error logging message correctly uses the updated method name and terminology, ensuring consistency in the codebase.


81-88: Method signature and implementation updated correctly

Both the method signature and implementation details for _createLiveCounterDataEntry have been properly updated to use the new ObjectState type instead of StateObject.


90-97: Method signature and implementation updated correctly

Both the method signature and implementation details for _createLiveMapDataEntry have been properly updated to use the new ObjectState type instead of StateObject.

src/plugins/objects/liveobject.ts (7)

3-3: Imports updated to align with new terminology

The imports have been updated from state-related types to object-related types, consistent with the PR objectives.


47-49: Documentation comment updated correctly

The 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 terminology

The 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 updated

Both 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 correctly

The method has been renamed from overrideWithStateObject to overrideWithObjectState, and its documentation has been updated to use object-based terminology throughout.


233-236: Documentation comment updated

The comment has been updated to use the new terminology while maintaining the same meaning.


237-247: Documentation and method parameter updated

Both 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 standard

The comment terminology has been appropriately updated from "Objects messages" to "object messages" for both OBJECT_PUBLISH and OBJECT_SUBSCRIBE type descriptions, ensuring consistency with the refactoring objectives.


2184-2186: Type definition migrated from StateValue to ObjectValue

The LiveMapType definition has been correctly updated to use ObjectValue instead of StateValue, aligning with the PR's goal of replacing the internal usage of 'state' term with 'objects' for LiveObjects.


2296-2298: Documentation improvement for LiveMap class

The 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 documentation

Updated terminology from "key/value pairs" to "key-value pairs" for consistency with general TypeScript/JavaScript conventions.


2428-2444: Documentation updated for LiveObject interface methods

The 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 interface

The interface description has been updated to match the new object-based terminology.


2376-2376: Renamed StateValue type to ObjectValue

The 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 _bufferedStateOperations to _bufferedObjectOperations of type ObjectMessage[] aligns well with the object-based approach.


112-131: Check for nullish operation or objectId
Ensure msg.operation always returns a valid objectId in case LiveMap.createMapCreateMessage fails 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 from hasState to hasObject aligns 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 _startNewSync and applying them after _applySync ensures 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 from STATE_* constants toward OBJECT_* 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-in ObjectState into a new LiveCounter instance.


37-46: fromObjectOperation
Gracefully handles initialization from a COUNTER_CREATE operation, 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 a COUNTER_INC operation, 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.
ObjectIdObjectData and ValueObjectData are 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. The ObjectData type union and data: Map<string, LiveMapEntry> property are coherent and consistent with the PR’s objectives.

Also applies to: 36-36, 43-43, 47-47


73-80: fromObjectState method refactor.
Renaming from fromStateObject is consistent with the new object-based model. The logic simply instantiates a LiveMap and applies the passed-in state. No issues spotted.


85-95: fromObjectOperation method refactor.
Renamed from fromStateOperation. The method’s workflow for creating a LiveMap and applying the initial create operation is sensible. The non-null assertion on objectOperation.map?.semantics! is acceptable if the calling code guarantees a valid map.

Please ensure upstream logic consistently sets objectOperation.map before calling this method. If not, consider a graceful error check.


108-133: createMapSetMessage now 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: createMapRemoveMessage aligns with object-based approach.
The method constructs a MAP_REMOVE operation in an ObjectMessage. The type checks on key still stand. No concerns.


193-245: createMapCreateMessage and createInitialValueObject reworked for object-based creation.
The changes properly handle map entries under the new naming convention, encoding the initial value, and generating an ID with ObjectId.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 of element.data! is guarded by tombstone checks, making it safe.

Also applies to: 286-286, 315-315


343-344: Refined set and remove methods to publish object-based messages.
The updated calls to createMapSetMessage and createMapRemoveMessage maintain consistency with the object-based rewrite. No issues.

Also applies to: 358-359


365-365: applyOperation updated 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: overrideWithObjectState correctly applies the new object state.
Renamed from overrideWithStateObject to align with the new model. Checks for semantics, tombstones, and createOp remain consistent. No red flags in the updated logic.


583-593: _mergeInitialDataFromCreateOperation for 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: _applyMapCreate method 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: _applyMapSet object-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: _liveMapDataFromMapEntries constructs live map data around ObjectData.
This is the direct counterpart to the old state-based approach. The logic to handle objectId vs. value is clear.

Also applies to: 770-770, 772-772, 774-774, 777-777, 785-785


794-794: _getResolvedValueFromObjectData now resolves object references vs. primitives.
Proper name change from _getResolvedValueFromStateData to _getResolvedValueFromObjectData. The logic correctly checks if the reference object is tombstoned or not.

Also applies to: 795-795, 796-796, 800-800


814-814: _isMapEntryTombstoned accounts 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

@github-actions github-actions bot temporarily deployed to staging/pull/1992/features March 27, 2025 11:09 Inactive
@VeskeR VeskeR force-pushed the PUB-1539/rename-internal-state-term-to-objects branch from c6deab8 to 8f9bd30 Compare March 31, 2025 09:22
@github-actions github-actions bot temporarily deployed to staging/pull/1992/bundle-report March 31, 2025 09:22 Inactive
@github-actions github-actions bot temporarily deployed to staging/pull/1992/features March 31, 2025 09:22 Inactive
@github-actions github-actions bot temporarily deployed to staging/pull/1992/typedoc March 31, 2025 09:22 Inactive
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (2)
src/plugins/objects/objects.ts (1)

296-316: publish(ObjectMessage[]): rename sendState?
The method is properly refactored to handle ObjectMessage[]. However, consider renaming sendState to something like sendObject for 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. Use Number.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)

📥 Commits

Reviewing files that changed from the base of the PR and between c6deab8 and 8f9bd30.

📒 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 _queuedMessages array type from StateMessage[] to ObjectMessage[] 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 from StateMessage to ObjectMessage matches the broader shift in terminology.

src/plugins/objects/syncobjectsdatapool.ts (5)

3-3: Import refactor
Adding ObjectMessage and ObjectState while dropping references to old state-based types is consistent with the rename.


7-7: Property rename to objectState
Changing stateObject to objectState clarifies usage of the new object-based approach.


52-79: applyStateSyncMessages → applyObjectSyncMessages
Refactoring the logic to handle objectMessage.object instead of stateMessage.state keeps the method aligned with the new terminology. The updated logging and skip conditions look correct.


81-84: _createLiveCounterDataEntry
Replacing stateObject with objectState is consistent with the rest of this refactor.


90-93: _createLiveMapDataEntry
Similarly, changing to objectState follows 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 to ObjectMessage and ObjectOperationAction completes the rename in this file.


52-65: Introduction of _bufferedObjectOperations
Renaming _bufferedStateOperations to _bufferedObjectOperations and changing its type to ObjectMessage[] fits the new object-based workflow.


76-77: Sync waiting logic
Retaining the check for this._state !== ObjectsState.synced before returning the root keeps usage consistent and ensures the required sync is completed first.


112-131: Refactor createMap to use ObjectMessage
Using LiveMap.createMapCreateMessage and then publishing a list of ObjectMessage is 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 from handleStateSyncMessages to handleObjectSyncMessages and usage of _syncObjectsDataPool.applyObjectSyncMessages confirm 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 !hasObject is well-structured and aligns with the rename from “state” to “object.”


279-284: actOnChannelState
Calling onAttached for the 'attached' event with the new hasObject parameter follows the revised naming.


335-350: _startNewSync and _endSync
Clearing _bufferedObjectOperations before/after the sync then applying them once the sync completes is a sensible flow.


388-389: overrideWithObjectState usage
Ensuring existingObject updates with entry.objectState aligns with the new naming scheme and object-based logic.


400-404: LiveCounter & LiveMap fromObjectState
Refactoring the creation logic to rely on objectState matches 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 checks objectMessage.operation before 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 StateOperationAction to ObjectOperationAction is 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 StateValue to ObjectValue has been properly implemented while maintaining the same underlying types.


25-36: LGTM! Interface renamed with documentation updates.

The interface rename from StateData to ObjectData is 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 StateMapOp to MapOp is well-implemented with documentation properly updated.


46-50: LGTM! Counter operation interface rename.

The interface rename from StateCounterOp to CounterOp is correctly implemented.


53-65: LGTM! Map entry interface with updated references.

The interface rename to use ObjectData in line 64 is correctly implemented.


67-73: LGTM! Map interface rename.

The interface rename from StateMap to ObjectMap is correctly implemented with proper documentation updates.


75-79: LGTM! Counter interface rename.

The interface rename from StateCounter to ObjectCounter is correctly implemented with proper documentation updates.


81-116: LGTM! Operation interface rename with comprehensive updates.

The interface rename from StateOperation to ObjectOperation is 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 StateObject to ObjectState is 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 StateMessage to ObjectMessage is consistently applied, with all class properties and documentation properly updated to use the new terminology.


175-197: LGTM! Method implementation with updated references.

The encode static method has been updated to use the new terminology (ObjectMessage and ObjectOperation) throughout its implementation.


199-228: LGTM! Decode method with updated references.

The decode static method has been updated to properly handle ObjectMessage and related types.


230-251: LGTM! Factory methods with updated references.

The factory methods fromValues and fromValuesArray have been updated to properly handle ObjectMessage types.


253-287: LGTM! Initial value encoding with updated references.

The encodeInitialValue method has been updated to work with ObjectOperation and ObjectMessage types.


289-315: LGTM! Map entries decoding method with updated references.

The private _decodeMapEntries method has been updated to work with the new MapEntry and ObjectData types.


317-341: LGTM! Object operation encoding with thorough updates.

The _encodeObjectOperation method has been renamed from _encodeStateOperation and all references within have been properly updated to use the new terminology.


343-361: LGTM! Object state encoding with thorough updates.

The _encodeObjectState method has been renamed from _encodeStateObject and all references have been properly updated.


363-371: LGTM! Object data encoding method updated.

The _encodeObjectData method has been renamed from _encodeStateData and correctly handles the new ObjectData type.


373-407: LGTM! Wire protocol encoding with updated references.

The _encodeForWireProtocol method has been updated to work with ObjectMessage, ObjectOperation, and ObjectState types.


409-436: LGTM! JSON serialization with updated references.

The toJSON method has been updated to handle ObjectOperation and ObjectState properties correctly.


438-457: LGTM! String representation updated.

The toString method has been updated to output ObjectMessage in its output along with property references.


459-474: LGTM! Message size calculation with updated references.

The getMessageSize method 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 _getObjectOperationSize method has been renamed from _getStateOperationSize and correctly uses the renamed helper methods.


495-509: LGTM! Object state size calculation method.

The _getObjectStateSize method has been renamed from _getStateObjectSize and 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, and ObjectState from the renamed file.


24-34: LGTM! Method rename with updated documentation.

The method has been properly renamed from fromStateObject to fromObjectState with corresponding parameter type updates and documentation changes.


36-46: LGTM! Method rename with parameter updates.

The method has been properly renamed from fromStateOperation to fromObjectOperation with corresponding parameter type updates and documentation changes.


48-71: LGTM! Counter increment message creation updated.

The createCounterIncMessage method has been updated to use ObjectMessage and ObjectOperationAction.COUNTER_INC correctly.

🧰 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 createCounterCreateMessage method has been updated to use ObjectMessage and ObjectOperationAction.COUNTER_CREATE correctly.


114-123: LGTM! Initial value object creation method updated.

The createInitialValueObject method has been updated to use ObjectOperation as the type parameter.


139-143: LGTM! Increment method implementation updated.

The increment method has been updated to use the renamed message creation method correctly.


159-190: LGTM! Apply operation method updated.

The applyOperation method has been updated to use ObjectOperation and ObjectMessage parameter 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 ObjectOperationAction enum values correctly.


222-278: LGTM! Object state override method updated.

The overrideWithObjectState method has been renamed from overrideWithStateObject and thoroughly updated to handle the new ObjectState type with proper error messages.


297-306: LGTM! Initial data merging method updated.

The _mergeInitialDataFromCreateOperation method has been updated to use ObjectOperation parameter type with correct property references.


308-314: LGTM! Error handling method updated.

The _throwNoPayloadError method has been updated to use ObjectOperation parameter type.


316-331: LGTM! Counter creation application method updated.

The _applyCounterCreate method has been updated to use ObjectOperation parameter type.


333-336: LGTM! Counter increment application method updated.

The _applyCounterInc method has been updated to use CounterOp parameter 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 ObjectIdStateData to ObjectIdObjectData and ValueStateData to ValueObjectData with corresponding documentation updates.


36-44: LGTM! Map entry interface updated.

The LiveMapEntry interface now references ObjectData instead of StateData, maintaining consistency with the terminology change.


46-48: LGTM! Map data interface updated.

The LiveMapData interface has been updated to use LiveMapEntry consistently.


72-82: LGTM! State object method rename.

The method has been properly renamed from fromStateObject to fromObjectState with corresponding parameter updates and documentation changes.


84-97: LGTM! State operation method rename.

The method has been properly renamed from fromStateOperation to fromObjectOperation with corresponding parameter updates and documentation changes.


99-133: LGTM! Map set message creation updated.

The createMapSetMessage method has been updated to use ObjectMessage, ObjectOperationAction.MAP_SET, and properly handle ObjectData types.


135-162: LGTM! Map remove message creation updated.

The createMapRemoveMessage method has been updated to use ObjectMessage and ObjectOperationAction.MAP_REMOVE correctly.


192-230: LGTM! Map create message method updated.

The createMapCreateMessage method has been updated to use ObjectMessage, ObjectOperationAction.MAP_CREATE, and properly handle the changed interfaces.


232-255: LGTM! Initial value object creation method updated.

The createInitialValueObject method has been updated to use ObjectOperation as the type parameter and MapEntry interfaces properly.


257-287: LGTM! Documentation updates for map properties.

The documentation for the get method has been updated to reflect the new terminology around object references.


341-345: LGTM! Set method implementation updated.

The set method has been updated to use the renamed message creation methods correctly.


356-360: LGTM! Remove method implementation updated.

The remove method has been updated to use the renamed message creation methods correctly.


362-433: LGTM! Apply operation method updated.

The applyOperation method has been updated to use ObjectOperation and ObjectMessage parameter types, and the switch cases use ObjectOperationAction enum values correctly.


435-507: LGTM! Object state override method updated.

The overrideWithObjectState method has been renamed from overrideWithStateObject and thoroughly updated to handle the new ObjectState type with proper error messages and logic.


583-617: LGTM! Initial data merging method updated.

The _mergeInitialDataFromCreateOperation method has been updated to use ObjectOperation parameter type correctly.


619-625: LGTM! Error handling method updated.

The _throwNoPayloadError method has been updated to use ObjectOperation parameter type.


627-650: LGTM! Map creation application method updated.

The _applyMapCreate method has been updated to use ObjectOperation parameter type.


652-702: LGTM! Map set application method updated.

The _applyMapSet method has been updated to use MapOp parameter type and handle ObjectData correctly.


704-733: LGTM! Map remove application method updated.

The _applyMapRemove method has been updated to use MapOp parameter type and handle LiveMapEntry correctly.


763-789: LGTM! Map entries conversion method updated.

The _liveMapDataFromMapEntries method has been updated to properly convert from MapEntry to LiveMapEntry while handling ObjectData correctly.


791-812: LGTM! Value resolution method updated.

The _getResolvedValueFromObjectData method has been renamed and updated to handle ObjectData and return ObjectValue correctly.


814-831: LGTM! Map entry check method updated.

The _isMapEntryTombstoned method has been updated to use LiveMapEntry parameter type correctly.

Copy link
Contributor

@mschristensen mschristensen left a 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 :)

@VeskeR VeskeR force-pushed the PUB-1539/rename-internal-state-term-to-objects branch from 8f9bd30 to 6f8d1d0 Compare April 1, 2025 08:24
@VeskeR
Copy link
Contributor Author

VeskeR commented Apr 1, 2025

Small comment: I think HAS_OBJECT should be HAS_OBJECTS

Otherwise lgtm, thanks :)

Yeah, agree, updated in https://github.com/ably/ably-js/compare/8f9bd302574e359a424f045747ef7eef9d26c2f0..6f8d1d0d4b5f97b2e1fe7a46d4c711704ef40d5a.

Will update the spec too

@github-actions github-actions bot temporarily deployed to staging/pull/1992/bundle-report April 1, 2025 08:25 Inactive
@github-actions github-actions bot temporarily deployed to staging/pull/1992/features April 1, 2025 08:25 Inactive
@github-actions github-actions bot temporarily deployed to staging/pull/1992/typedoc April 1, 2025 08:25 Inactive
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (1)
src/plugins/objects/livecounter.ts (1)

54-54: Use Number.isFinite instead of isFinite.

The global isFinite function attempts a type coercion which could lead to unexpected behavior. Use Number.isFinite instead 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)

📥 Commits

Reviewing files that changed from the base of the PR and between 8f9bd30 and 6f8d1d0.

📒 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 StateMessage to ObjectMessage and points to the renamed file objectmessage.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 _queuedMessages has been properly changed from StateMessage[] to ObjectMessage[], 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 queueStateMessage to the more generic queueMessage and its parameter type updated from StateMessage to ObjectMessage. The parameter name has also been changed from stateMessage to msg to reflect the more generic nature of the method.

test/realtime/objects.test.js (8)

90-91: Function renamed to align with updated terminology.

The stateMessageFromValues function has been renamed to objectMessageFromValues and now calls ObjectsPlugin.ObjectMessage.fromValues instead of StateMessage.fromValues, consistent with the terminology change from "state" to "objects".


114-114: Function renamed to align with updated terminology.

Function renamed from waitForStateOperation to waitForObjectOperation to maintain consistency with the new object-based terminology.


672-673: Variable renamed to align with updated terminology.

The array variable has been renamed from stateSyncSequenceScenarios to objectSyncSequenceScenarios to 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_DELETE to OBJECT_DELETE to 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 ObjectMessage related methods instead of StateMessage related 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 update

Changed from "Live Object Types" to "Object Types" to use more consistent terminology.


660-661: Revised description for LiveMap

The description now correctly states that LiveMap enables storing "other objects" instead of "other Live Objects", maintaining the terminology consistency.


692-693: Updated object storage explanation

Changed to clarify that objects can be stored as well as primitive values, with improved wording.


775-776: Improved object creation description

Updated to refer to "LiveMap and LiveCounter objects" rather than "instances", maintaining the consistent terminology.


824-825: Updated lifecycle events description

The 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: ...d synced events notify when the local Objects state on a client is being synchronized...

(AI_HYDRA_LEO_APOSTROPHE_S_XS)


838-839: Improved object deletion description

This 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 message

Changed 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 documentation

Documentation 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 → objectOperationMessage

The method has been renamed from stateOperationMessage to objectOperationMessage while maintaining the same functionality. The action comment has been updated from "STATE" to "OBJECT".


255-264: Renamed method: stateObjectMessage → objectStateMessage

The method has been renamed from stateObjectMessage to objectStateMessage while maintaining the same functionality. The action comment has been updated from "STATE_SYNC" to "OBJECT_SYNC".


266-279: Renamed method: processStateOperationMessageOnChannel → processObjectOperationMessageOnChannel

The method has been renamed from processStateOperationMessageOnChannel to processObjectOperationMessageOnChannel while maintaining the same functionality. It now references the renamed objectOperationMessage function.


281-294: Renamed method: processStateObjectMessageOnChannel → processObjectStateMessageOnChannel

The method has been renamed from processStateObjectMessageOnChannel to processObjectStateMessageOnChannel while maintaining the same functionality. It now references the renamed objectStateMessage function.

src/common/lib/types/protocolmessage.ts (6)

37-38: Updated action names for consistency

Changed 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 detection

The 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 processing

The state variable type has been updated from ObjectsPlugin.StateMessage[] to ObjectsPlugin.ObjectMessage[]. The message processing logic now calls objectsPlugin.ObjectMessage.fromValues instead of StateMessage.fromValues.


146-147: Updated documentation comment

The documentation comment now correctly mentions "object messages" instead of "state messages" to maintain consistent terminology.


181-183: Updated message array handling

The stringify method now calls objectsPlugin.ObjectMessage.fromValuesArray instead of StateMessage.fromValuesArray, maintaining consistent terminology for message handling.


222-222: Updated type definition for state property

The type of the state property in the ProtocolMessage class has been updated from ObjectsPlugin.StateMessage[] to ObjectsPlugin.ObjectMessage[].

src/common/lib/client/realtimechannel.ts (10)

33-33: Updated import type

Changed the import type from StateMessage to ObjectMessage from the 'plugins/objects' module.


510-519: Renamed sendState parameter and action

The sendState method now accepts objectMessages: ObjectMessage[] instead of StateMessage[] and uses actions.OBJECT instead of actions.STATE. The functionality remains the same.


526-528: Updated message action check

Changed the condition to check for actions.OBJECT instead of actions.STATE when processing messages, maintaining consistent terminology.


545-545: Renamed flag check

Updated the flag check from HAS_STATE to HAS_OBJECTS when processing attached messages.


554-556: Updated objects callback with new parameter name

Changed the call to this._objects.onAttached to use the renamed parameter hasObjects instead of hasState.


567-567: Updated notifyState call

Added the renamed parameter hasObjects to the notifyState method call, replacing hasState.


615-634: Renamed OBJECT and OBJECT_SYNC message processing

The message processing logic has been updated to handle actions.OBJECT and actions.OBJECT_SYNC instead of STATE and STATE_SYNC. The object messages variable naming and method calls have been updated accordingly.


743-743: Updated generic type constraint

Changed the generic type constraint in _decodeAndPrepareMessages from T extends Message | PresenceMessage | StateMessage to T extends Message | PresenceMessage | ObjectMessage.


812-812: Updated notifyState parameter

Added the renamed parameter hasObjects to the notifyState method definition, replacing hasState.


834-834: Updated actOnChannelState call

Changed the call to this._objects.actOnChannelState to use the renamed parameter hasObjects instead of hasState.

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 ObjectMessage and ObjectOperationAction instead 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 _bufferedStateOperations to _bufferedObjectOperations to align with the new terminology.


65-65: Updated initialization of buffered operations.

The initialization of the renamed variable _bufferedObjectOperations is 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 stateMessage to msg and the property access has been updated to refer to operation?.objectId instead of the previous state-based version.


115-115: Method call updated to use ObjectMessage array.

The publish method now accepts ObjectMessage[] instead of StateMessage[].


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.fromObjectOperation instead of the previous state-based method.


144-146: Updated variable names in createCounter method.

Variables have been renamed from stateMessage to msg and the property access has been updated to refer to operation?.objectId instead of the previous state-based version.


147-147: Method call updated to use ObjectMessage array.

The publish method now accepts ObjectMessage[] instead of StateMessage[].


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.fromObjectOperation instead of the previous state-based method.


215-223: Method signature and parameter type updated.

The method handleObjectSyncMessages now accepts ObjectMessage[] instead of StateMessage[].


222-222: Method call updated to use object terminology.

The method call has been updated to use applyObjectSyncMessages instead of the previous state-based method.


235-241: Method signature and comments updated.

The method handleObjectMessages now accepts ObjectMessage[] instead of StateMessage[]. 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 _applyObjectMessages instead of the previous state-based method.


251-257: Method parameter updated and log message modified.

The onAttached method parameter has been renamed from hasState to hasObjects to 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 hasObjects instead of the previous state-based flag.


266-268: Updated comment regarding hasObjects flag.

The comment has been updated to use the term hasObjects instead of the previous state-based flag.


279-282: Method signature updated and method call modified.

The actOnChannelState method now passes hasObjects instead of hasState to the onAttached method.


296-296: Method signature updated for publish.

The publish method now accepts ObjectMessage[] instead of StateMessage[].


305-307: Updated method calls to use ObjectMessage.

The code now calls ObjectMessage.encode instead of the previous state-based method and uses the getMessageSize method 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 sendState which should be handling the new ObjectMessage[] 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 _applyObjectMessages instead of the previous state-based method.


350-350: Variable initialization updated.

The variable initialization has been updated to reset _bufferedObjectOperations instead of the previous state-based variable.


388-389: Updated attribute reference for object state.

The method now uses objectState instead 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.fromObjectState and LiveMap.fromObjectState instead 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 handle ObjectMessage[] instead of StateMessage[]. The implementation has been updated to use objectOperation and ObjectOperationAction instead 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 createZeroValueObjectIfNotExists with the objectOperation.objectId parameter.


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 ObjectData instead of StateData.


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 MapEntry instead of StateMapEntry.


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 encode method has been updated to work with ObjectMessage and to call _encodeObjectOperation and _encodeObjectState methods.


203-228: Decode method updated to work with ObjectMessage.

The decode method has been updated to handle ObjectMessage and to call methods with the "object" prefix instead of the "state" prefix.


230-236: Static factory method updated to create ObjectMessage.

The fromValues method has been updated to create an instance of ObjectMessage instead of StateMessage.


238-251: Static factory method for arrays updated.

The fromValuesArray method has been updated to work with ObjectMessage instead of StateMessage.


253-287: Static method for encoding initial values updated.

The encodeInitialValue method has been updated to work with ObjectOperation instead of StateOperation, and the comment has been updated to use the term "object" instead of "state".


289-297: Helper method updated to work with MapEntry.

The _decodeMapEntries method has been updated to work with MapEntry instead of StateMapEntry.


299-315: Helper method renamed and updated.

The _decodeStateData method has been renamed to _decodeObjectData and updated to work with ObjectData instead of StateData.


317-341: Helper method renamed and updated.

The _encodeStateOperation method has been renamed to _encodeObjectOperation and updated to work with ObjectOperation instead of StateOperation. References to attributes and methods have been updated accordingly.


343-361: Helper method renamed and updated.

The _encodeStateObject method has been renamed to _encodeObjectState and updated to work with ObjectState instead of StateObject. References to attributes and methods have been updated accordingly.


363-371: Helper method renamed and updated.

The _encodeStateData method has been renamed to _encodeObjectData and updated to work with ObjectData instead of StateData.


373-407: Private method updated to work with ObjectMessage.

The _encodeForWireProtocol method has been updated to work with ObjectMessage instead of StateMessage and to return ObjectOperation and ObjectState types instead of their state-based counterparts.


416-436: toJSON method updated to return object-based properties.

The toJSON method has been updated to return operation and object properties instead of their state-based counterparts.


438-457: toString method updated to reference ObjectMessage.

The toString method has been updated to use the class name ObjectMessage and to reference the operation and object properties.


459-474: getMessageSize method updated to work with object-based properties.

The getMessageSize method has been updated to check for and calculate sizes based on operation and object properties.


476-493: Helper method renamed.

The _getStateOperationSize method has been renamed to _getObjectOperationSize and updated to call methods with the "object" prefix instead of the "state" prefix.


495-509: Helper method renamed.

The _getStateObjectSize method has been renamed to _getObjectStateSize and updated to call methods with the "object" prefix instead of the "state" prefix.


511-522: Helper method renamed.

The _getStateMapSize method has been renamed to _getObjectMapSize and updated to call methods with the "map" prefix instead of the "state" prefix.


524-530: Helper method renamed.

The _getStateCounterSize method has been renamed to _getObjectCounterSize.


532-540: Helper method renamed to work with MapEntry.

The _getStateMapEntrySize method has been renamed to _getMapEntrySize and updated to call methods with the "object" prefix instead of the "state" prefix.


542-552: Helper method renamed.

The _getStateMapOpSize method has been renamed to _getMapOpSize and updated to call methods with the "object" prefix instead of the "state" prefix.


554-560: Helper method renamed.

The _getStateCounterOpSize method has been renamed to _getCounterOpSize.


562-570: Helper method renamed.

The _getStateDataSize method has been renamed to _getObjectDataSize and updated to call methods with the "object" prefix instead of the "state" prefix.


572-574: Helper method renamed.

The _getStateValueSize method 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 createCounterIncMessage method has been updated to create an ObjectMessage with an ObjectOperation instead of a StateMessage with a StateOperation.

🧰 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 createCounterCreateMessage method has been updated to create an ObjectMessage with an ObjectOperation instead of a StateMessage with a StateOperation. The method now returns a Promise of ObjectMessage instead of a Promise of StateMessage.


117-123: Method return type updated.

The createInitialValueObject method now returns a Pick<ObjectOperation, 'counter'> instead of the previous state-based type.


141-143: Method implementations updated to use ObjectMessage.

The increment method has been updated to use the new createCounterIncMessage method that returns an ObjectMessage, and to pass an array of ObjectMessage to the publish method.


162-220: Method signature and implementation updated.

The applyOperation method now accepts ObjectOperation and ObjectMessage parameters instead of their state-based counterparts. The switch-case structure has been updated to handle ObjectOperationAction enum 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 StateObject to ObjectState.


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.createOp instead 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_CREATE instead 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.siteTimeserials instead of the previous state-based field.


263-272: Updated tombstone checking logic.

The code now checks for objectState.tombstone instead of the previous state-based field, and updates the data reference with objectState.counter?.count instead 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 _mergeInitialDataFromCreateOperation method now accepts an ObjectOperation parameter instead of a StateOperation. The implementation has been updated to reference objectOperation.counter?.count instead of the previous state-based field.


308-314: Method parameter type updated.

The _throwNoPayloadError method now accepts an ObjectOperation parameter instead of a StateOperation.


316-331: Method parameter type updated.

The _applyCounterCreate method now accepts an ObjectOperation parameter instead of a StateOperation.


333-336: Method parameter type updated.

The _applyCounterInc method now accepts a CounterOp parameter instead of a StateCounterOp.

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, and ObjectValue replacing 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 ObjectData type has been updated to be a union of ObjectIdObjectData and ValueObjectData instead of their state-based counterparts.


36-44: Interface renamed from MapEntry to LiveMapEntry.

The interface has been renamed to avoid confusion with the MapEntry interface from objectmessage.ts, and its data property has been updated to reference ObjectData instead of the previous state-based type.


47-47: Interface property type updated.

The data property of LiveMapData has been updated to use LiveMapEntry instead of the previous MapEntry.


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 ObjectState instead 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 ObjectOperation instead of the previous state-based type.


102-133: Method updated to return ObjectMessage instead of StateMessage.

The createMapSetMessage method has been updated to return an ObjectMessage instead of a StateMessage. The method creates an operation with ObjectOperationAction.MAP_SET and constructs object data as either ObjectIdObjectData or ValueObjectData based on the value type.


138-162: Method updated to return ObjectMessage instead of StateMessage.

The createMapRemoveMessage method has been updated to return an ObjectMessage instead of a StateMessage. The method creates an operation with ObjectOperationAction.MAP_REMOVE.


192-230: Method updated to return a Promise of ObjectMessage.

The createMapCreateMessage method has been updated to return a Promise of ObjectMessage instead of a Promise of StateMessage. The method creates an operation with ObjectOperationAction.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 createInitialValueObject method now returns a Pick<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 get method 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 _getResolvedValueFromObjectData instead of the previous state-based method.


315-315: Updated method call.

The method call has been updated to use _getResolvedValueFromObjectData instead of the previous state-based method.


343-345: Method calls updated to use ObjectMessage.

The set method has been updated to call createMapSetMessage which returns an ObjectMessage, and to pass an array of ObjectMessage to the publish method.


358-360: Method calls updated to use ObjectMessage.

The remove method has been updated to call createMapRemoveMessage which returns an ObjectMessage, and to pass an array of ObjectMessage to the publish method.


365-433: Method signature and implementation updated.

The applyOperation method now accepts ObjectOperation and ObjectMessage parameters instead of their state-based counterparts. The switch-case structure has been updated to handle ObjectOperationAction enum 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 StateObject to ObjectState. The error message has been updated accordingly.


455-480: Updated createOp validation.

The code now checks for the existence and validity of objectState.createOp instead 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.siteTimeserials instead of the previous state-based field.


492-501: Updated tombstone checking and data override logic.

The code now checks for objectState.tombstone instead 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 _getZeroValueData method now initializes a Map with LiveMapEntry instead of the previous MapEntry.


583-617: Method parameter type updated.

The _mergeInitialDataFromCreateOperation method now accepts an ObjectOperation parameter instead of a StateOperation. The implementation has been updated to check for objectOperation.map instead of the previous state-based field.


619-625: Method parameter type updated.

The _throwNoPayloadError method now accepts an ObjectOperation parameter instead of a StateOperation.


627-650: Method parameter type updated.

The _applyMapCreate method now accepts an ObjectOperation parameter instead of a StateOperation.


652-702: Method parameter types updated.

The _applyMapSet method now accepts a MapOp parameter instead of a StateMapOp. The implementation constructs ObjectData as either ObjectIdObjectData or ValueObjectData and a LiveMapEntry instead 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 _applyMapRemove method now accepts a MapOp parameter instead of a StateMapOp. The implementation constructs a LiveMapEntry instead of the previous state-based type.


763-789: Method parameter type updated.

The _liveMapDataFromMapEntries method now accepts a Record<string, MapEntry> parameter instead of the previous state-based type. The implementation constructs ObjectData as either ObjectIdObjectData or ValueObjectData and a LiveMapEntry instead of the previous state-based types.


791-812: Method renamed and updated.

The _getResolvedValueFromStateData method has been renamed to _getResolvedValueFromObjectData and updated to accept an ObjectData parameter instead of a StateData. 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 _isMapEntryTombstoned method now accepts a LiveMapEntry parameter instead of a MapEntry.

@VeskeR VeskeR force-pushed the PUB-1539/rename-internal-state-term-to-objects branch from 6f8d1d0 to 06591f2 Compare April 9, 2025 06:47
@github-actions github-actions bot temporarily deployed to staging/pull/1992/features April 9, 2025 06:48 Inactive
@github-actions github-actions bot temporarily deployed to staging/pull/1992/bundle-report April 9, 2025 06:48 Inactive
@github-actions github-actions bot temporarily deployed to staging/pull/1992/typedoc April 9, 2025 06:48 Inactive
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 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. Using Number.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)

📥 Commits

Reviewing files that changed from the base of the PR and between 6f8d1d0 and 06591f2.

📒 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 terminology

The import has been correctly updated from StateMessage to ObjectMessage which 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 consistency

The 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 type

The type annotation has been correctly changed from StateMessage[] to ObjectMessage[] to be consistent with the terminology changes and the imported type.


52-52: Updated error message with consistent terminology

The 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 type

The method has been appropriately renamed from queueStateMessage(stateMessage: StateMessage) to queueMessage(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 BatchContextLiveCounter and BatchContextLiveMap classes.

test/realtime/objects.test.js (19)

90-92: Function rename from stateMessageFromValues to objectMessageFromValues aligns 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 from waitForStateOperation to waitForObjectOperation while 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 the state property. 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 objectMessages instead of what was likely stateMessages before, 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 objectMessageFromValues function 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 STATE to OBJECT and STATE_SYNC to OBJECT_SYNC aligns 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_STATE to HAS_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 ObjectMessage instead of StateMessage. 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 ObjectMessage class correctly.


222-222: LGTM! Updated type definition in ProtocolMessage class.

The type of the state property has been updated to ObjectMessage[] 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 ObjectMessage and ObjectOperationAction.


52-53: LGTM! Updated private member variable name.

Renamed from _bufferedStateOperations to _bufferedObjectOperations to maintain consistency with the new terminology.


112-114: LGTM! Updated variable naming in createMap method.

Changed from stateMessage to msg and updated property access to work with the new ObjectMessage type.


144-146: LGTM! Updated variable naming in createCounter method.

Changed from stateMessage to msg and updated property access to work with the new ObjectMessage type.


215-215: LGTM! Renamed method for consistency.

Method handleStateSyncMessages has been renamed to handleObjectSyncMessages to reflect the new terminology.


235-242: LGTM! Updated method and comments for handling object messages.

The method has been renamed from handleStateMessages to handleObjectMessages and 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 hasState to hasObjects to match the renamed flag HAS_OBJECTS.


260-262: LGTM! Updated comments for clarity.

Comments have been updated to refer to the HAS_OBJECTS flag instead of the previous HAS_STATE flag.


266-268: LGTM! Updated condition and comments.

The condition and comments have been updated to check for the absence of the hasObjects flag.


279-283: LGTM! Updated parameter name in actOnChannelState method.

The parameter has been renamed from hasState to hasObjects to match the flag rename.


296-306: LGTM! Updated publish method signature and type usage.

The method signature now accepts ObjectMessage[] instead of StateMessage[] and correctly uses the ObjectMessage.encode method.


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 _applyObjectMessages instead of _applyStateMessages and comments have been updated to mention object operations.


421-430: LGTM! Updated method name and implementation.

Method has been renamed from _applyStateMessages to _applyObjectMessages and implementation updated to work with ObjectMessage and handle operation fields correctly.


433-458: LGTM! Updated switch statement to use ObjectOperationAction.

Switch statement now uses the renamed enum ObjectOperationAction for case statements and log messages have been updated accordingly.


316-316:

Details

❓ Verification inconclusive

Verify the method name of sendState.

The method name sendState still contains "state" terminology while accepting objectMessages. 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 ts

Length of output: 573


Action Required: Confirm Consistency of Method Naming

The sendState method is defined in both src/plugins/objects/objects.ts and src/common/lib/client/realtimechannel.ts, where it accepts an array of objectMessages and 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 as sendState (perhaps as a legacy reference) or if the method should be renamed (e.g., to sendObjects) 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 StateOperationAction to ObjectOperationAction to align with the new terminology.


22-23: LGTM! Renamed type and updated documentation.

StateValue has been renamed to ObjectValue with updated JSDoc comment.


25-36: LGTM! Renamed interface and updated documentation.

StateData has been renamed to ObjectData with thorough updates to the documentation comments.


38-44: LGTM! Renamed interface and updated documentation.

StateMapOp has been renamed to MapOp with updated property type references.


46-50: LGTM! Renamed interface and updated documentation.

StateCounterOp has been renamed to CounterOp with consistent documentation.


53-65: LGTM! Renamed interface and updated property type.

StateMapEntry has been renamed to MapEntry and the data property type updated to ObjectData.


67-73: LGTM! Renamed interface and updated documentation.

StateMap has been renamed to ObjectMap with updated property types for entries.


75-79: LGTM! Renamed interface and updated documentation.

StateCounter has been renamed to ObjectCounter with consistent documentation.


81-115: LGTM! Renamed interface and updated all property types.

StateOperation has been renamed to ObjectOperation with all property types updated to use the new type names.


117-141: LGTM! Renamed interface and updated all property types.

StateObject has been renamed to ObjectState with all property types and documentation updated accordingly.


146-169: LGTM! Renamed class and updated property types and documentation.

Class has been renamed from StateMessage to ObjectMessage with thorough updates to property types and documentation.


176-197: LGTM! Updated method documentation and implementation.

The encode method's documentation and implementation have been updated to work with ObjectMessage.


203-228: LGTM! Updated method parameter type.

The decode method's parameter type has been updated from StateMessage to ObjectMessage.


230-236: LGTM! Updated static method signatures.

The fromValues static method signatures have been updated to use ObjectMessage type.


238-251: LGTM! Updated static method signatures.

The fromValuesArray static method signatures have been updated to use ObjectMessage type.


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 StateMapEntry to MapEntry.


299-315: LGTM! Renamed method and updated parameter types.

Method has been renamed from _decodeStateData to _decodeObjectData with updated parameter types.


317-341: LGTM! Renamed method and updated implementation.

Method has been renamed from _encodeStateOperation to _encodeObjectOperation with updated implementation details.


343-361: LGTM! Renamed method and updated implementation.

Method has been renamed from _encodeStateObject to _encodeObjectState with updated variable names and method calls.


363-371: LGTM! Renamed method and updated parameter types.

Method has been renamed from _encodeStateData to _encodeObjectData with 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 [ObjectMessage instead 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 fromStateObject to fromObjectState with updated documentation and parameter types.


37-45: Method and docs updated to use object-based terminology.

The method has been correctly renamed from fromStateOperation to fromObjectOperation with 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 overrideWithStateObject to overrideWithObjectState and 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 fromStateObject to fromObjectState with updated documentation and parameter types.


85-97: Method renamed to fromObjectOperation.

The method has been correctly renamed from fromStateOperation to fromObjectOperation with 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 _getResolvedValueFromStateData to _getResolvedValueFromObjectData.


315-315: Method call updated to use new method name.

The method call has been updated from _getResolvedValueFromStateData to _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 overrideWithStateObject to overrideWithObjectState and 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 _getResolvedValueFromStateData to _getResolvedValueFromObjectData and 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.

@VeskeR VeskeR changed the base branch from PUB-1530/update-rest-api to integration/liveobjects April 9, 2025 06:54
@VeskeR VeskeR force-pushed the PUB-1539/rename-internal-state-term-to-objects branch from 06591f2 to 8c825c5 Compare April 9, 2025 07:34
@github-actions github-actions bot temporarily deployed to staging/pull/1992/bundle-report April 9, 2025 07:37 Inactive
@github-actions github-actions bot temporarily deployed to staging/pull/1992/features April 9, 2025 07:37 Inactive
@github-actions github-actions bot temporarily deployed to staging/pull/1992/typedoc April 9, 2025 07:37 Inactive
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🔭 Outside diff range comments (3)
test/realtime/objects.test.js (3)

114-136: 🛠️ Refactor suggestion

Function renamed correctly but contains "state" reference that should be updated

The function has been correctly renamed from waitForStateOperation to waitForObjectOperation, but there's still a reference to message.state[0]?.operation?.action on 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 suggestion

Updated 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 to processObjectOperationMessageOnChannel still 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 like processObjectOperationMessageOnChannel to 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 suggestion

Consistent 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 processObjectOperationMessageOnChannel still use the state: 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)

📥 Commits

Reviewing files that changed from the base of the PR and between 06591f2 and 8c825c5.

📒 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 ObjectMessage from the renamed file objectmessage.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 _queuedMessages property type has been changed from StateMessage[] to ObjectMessage[], 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 queueStateMessage to queueMessage and its parameter type changed from StateMessage to ObjectMessage, consistent with the broader refactoring effort.

test/realtime/objects.test.js (3)

90-91: Name change aligned with terminology update

Changed from stateMessageFromValues to objectMessageFromValues and the implementation now calls ObjectMessage.fromValues instead of StateMessage.fromValues, consistent with the PR objective to replace "state" terminology with "objects".


4504-4725: Successfully transitioned from StateMessage to ObjectMessage

The test suite for message size calculations has been properly migrated from StateMessage to ObjectMessage. 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 model

The 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 clarity

This 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 terminology

The 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 description

The 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 description

The 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 actions

Renamed STATE to OBJECT and STATE_SYNC to OBJECT_SYNC in the protocol message actions, aligning with the new object-based terminology.


53-53: LGTM: Updated flag from HAS_STATE to HAS_OBJECTS

The flag HAS_STATE has been renamed to HAS_OBJECTS, which is consistent with the PR's objective to move away from state-based terminology.


129-137: LGTM: Updated state handling to use ObjectMessage

Updated the type of the state variable from StateMessage[] to ObjectMessage[] and correctly used the new ObjectMessage.fromValues method for message conversion. These changes align with the broader refactoring from state to object-based messaging.


146-147: LGTM: Updated documentation for object messages

The 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 ObjectMessage

Updated the stringify method to reference objectsPlugin.ObjectMessage.fromValuesArray instead of a previous state-related method, ensuring consistency with the new object-based model.


222-222: LGTM: Updated state property type to ObjectMessage

Changed the type of the state property from StateMessage[] to ObjectMessage[], 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 ObjectMessage

Replaced the import of StateMessage, StateOperationAction with ObjectMessage, ObjectOperationAction, which is consistent with the renamed file and types.


52-52: LGTM: Renamed buffered operations to match new terminology

Private member _bufferedStateOperations has been renamed to _bufferedObjectOperations and its initialization updated, maintaining consistency with the object-based terminology.

Also applies to: 65-65


112-116: LGTM: Updated createMap to use ObjectMessage

The createMap method now correctly uses msg and references its operation property, replacing previous state-based variables and method calls.


127-128: LGTM: Updated object creation from ObjectOperation

Changed from LiveMap.fromStateOperation to LiveMap.fromObjectOperation, which aligns with the renamed method in the LiveMap class.


144-159: LGTM: Updated createCounter to use ObjectMessage

Similar 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 methods

Renamed method from handleStateSyncMessages to handleObjectSyncMessages and updated the call to applyObjectSyncMessages, maintaining consistency with the object-based terminology.


235-246: LGTM: Updated object messages handler

Renamed method from handleStateMessages to handleObjectMessages and updated the buffering logic to use _bufferedObjectOperations. Also updated the method call from _applyStateMessages to _applyObjectMessages.


251-257: LGTM: Updated onAttached to use hasObjects flag

Changed parameter from hasState to hasObjects and 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 onAttached

The conditional logic now correctly references the hasObjects flag instead of a previous hasState flag, maintaining consistent terminology throughout the method.


279-283: LGTM: Updated actOnChannelState parameter

Changed parameter type from hasState to hasObjects and updated the method call to pass the renamed parameter, ensuring consistency throughout the codebase.


296-317: LGTM: Updated publish method to use ObjectMessage

Updated method signature from publish(stateMessages: StateMessage[]) to publish(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 terminology

Updated method implementations to reference "object operation" instead of "state operation" and updated variable names from _bufferedStateOperations to _bufferedObjectOperations.


388-389: LGTM: Updated object state handling

Changed method call from overrideWithStateObject to overrideWithObjectState, which aligns with renamed methods in the LiveObject class.


400-405: LGTM: Updated object creation from ObjectState

Changed method calls from LiveCounter.fromStateObject and LiveMap.fromStateObject to fromObjectState, maintaining consistency with renamed methods in the respective classes.


421-461: LGTM: Renamed object message application method

Renamed method from _applyStateMessages to _applyObjectMessages and updated the implementation to use object-based terminology throughout. The switch statement now correctly uses ObjectOperationAction constants.

src/plugins/objects/objectmessage.ts (18)

9-16: LGTM: Renamed operation action enum

Renamed enum from StateOperationAction to ObjectOperationAction, maintaining the same action constants but with updated terminology.


22-36: LGTM: Renamed value and data types

Renamed StateValue to ObjectValue and StateData to ObjectData, with updated documentation to reflect the object-based model.


38-50: LGTM: Renamed operation types

Renamed interfaces from StateMapOp to MapOp and StateCounterOp to CounterOp, simplifying the naming while maintaining the object-based focus.


53-79: LGTM: Renamed map and counter interfaces

Renamed interfaces from StateMapEntry to MapEntry, StateMap to ObjectMap, and StateCounter to ObjectCounter, keeping a consistent naming pattern across related types.


81-115: LGTM: Renamed operation interface

Renamed interface from StateOperation to ObjectOperation and updated property types to reference the newly renamed interfaces, maintaining type consistency.


117-141: LGTM: Renamed state interface to ObjectState

Renamed interface from StateObject to ObjectState and updated property types to reference the newly renamed interfaces, completing the transition to object-based terminology.


146-169: LGTM: Renamed message class and updated documentation

Renamed class from StateMessage to ObjectMessage and updated the property documentation to reference "object" instead of "state", maintaining consistent terminology.


181-197: LGTM: Updated encode method for ObjectMessage

Updated method signature and implementation to reference ObjectMessage and updated encoding logic to use the renamed helper methods.


203-228: LGTM: Updated decode method for ObjectMessage

Updated method signature and implementation to reference ObjectMessage and updated decoding logic to use the renamed helper methods such as _decodeObjectData.


231-251: LGTM: Updated fromValues methods for ObjectMessage

Updated method signatures and implementations to reference ObjectMessage in both the fromValues and fromValuesArray methods.


254-287: LGTM: Updated encodeInitialValue for ObjectOperation

Updated parameter type and implementation to use ObjectMessage and the renamed encoding methods, ensuring consistent object-based terminology.


290-315: LGTM: Renamed decoding methods for object data

Renamed methods from _decodeStateMapEntries to _decodeMapEntries and _decodeStateData to _decodeObjectData, with updated parameter types to match the renamed interfaces.


317-341: LGTM: Renamed encoding method for object operations

Renamed method from _encodeStateOperation to _encodeObjectOperation and updated implementation to use the renamed helper methods and object properties.


343-371: LGTM: Renamed encoding methods for object state and data

Renamed methods from _encodeStateObject to _encodeObjectState and _encodeStateData to _encodeObjectData, with updated implementations to reference the new object-based terminology.


373-407: LGTM: Updated wire protocol encoding for ObjectMessage

Updated method documentation and implementation to reference ObjectMessage and the renamed helper methods, ensuring consistent object-based terminology throughout the encoding process.


417-436: LGTM: Updated toJSON for ObjectMessage

Updated method signature and implementation to reference operation and object properties instead of previous state-related properties, maintaining consistent object-based terminology.


438-457: LGTM: Updated toString for ObjectMessage

Updated 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 methods

Renamed multiple size calculation methods to use object-based terminology instead of state-based terminology, such as _getObjectOperationSize instead 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 in fromObjectState.
The method properly instantiates a LiveCounter and calls overrideWithObjectState, ensuring object state is applied as intended.


37-38: Well-formed JSDoc for fromObjectOperation.
Renaming from a state-based to an object-based approach is consistent with the rest of the refactor.


42-44: fromObjectOperation logic looks sound.
Summarily replicates the same approach as fromObjectState, focusing on object-based creation. No concerns found.


51-70: Creation of COUNTER_INC messages is solid.
The function checks for valid numeric input and constructs an ObjectMessage with COUNTER_INC action. 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 creating COUNTER_CREATE messages.
The logic for encoding the initial value, generating a new objectId, and returning an ObjectMessage is consistent and matches the new object paradigm.


117-117: Helper method for initial value object.
The refactor is straightforward; returning only the counter field is in line with the new ObjectOperation definition.


141-142: Publish call on increment.
These lines ensure that the user’s increment value is published via an ObjectMessage. Implementation correctly delegates to LiveCounter.createCounterIncMessage.


162-220: applyOperation refactored for object-based operations.
The switch correctly handles COUNTER_CREATE, COUNTER_INC, and OBJECT_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 the counter?.count is 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.
Adds op.amount to 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 of ObjectMessage, ObjectOperation, etc.


19-35: New object data interfaces.
ObjectIdObjectData and ValueObjectData correctly replace state-based definitions. Documentation is clear and consistent.


36-47: LiveMapEntry and LiveMapData updates.
Switching from MapEntry to LiveMapEntry and naming the field data: Map<string, LiveMapEntry> is coherent with the object-based approach.


73-82: fromObjectState for LiveMap.
The method calls overrideWithObjectState to sync data from the new object state. Looks consistent and correct.


85-97: fromObjectOperation for MAP_CREATE objects.
Mimics the pattern in LiveCounter, bridging the initial create operation into this live map’s data. Code is sound.


107-133: createMapSetMessage logic.
Checks validity of key-value, builds ObjectMessage with MAP_SET action, and ensures the correct mapOp payload. Implementation is coherent.


142-162: createMapRemoveMessage logic.
Validates key, constructs MAP_REMOVE operation message. Straightforward and consistent.


192-230: Creation of MAP_CREATE messages.
Generates objectId from the initial entries, encodes them, and sets the MAP_CREATE action. Cleanly implemented.


235-255: createInitialValueObject for 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.
The get() 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 retrieve LiveObject or a primitive as needed. No issues here.


343-345: set() method calls createMapSetMessage.
Ensures the MAP_SET operation is published. Implementation is aligned with the new object-based design.


358-359: remove() method calls createMapRemoveMessage.
Similarly, publishes a MAP_REMOVE operation. No concerns identified.


365-433: applyOperation adopting object operations.
The switch statement properly covers MAP_CREATE, MAP_SET, MAP_REMOVE, and OBJECT_DELETE. Good CRDT checks ensure timeserial ordering.


438-507: Override logic with overrideWithObjectState.
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 a Map<string, LiveMapEntry> with appropriate tombstone flags and timeserial references. No issues found.


795-812: Distinguishing primitives vs. object references in _getResolvedValueFromObjectData.
Returns the LiveObject from the pool or the primitive, skipping if tombstoned. Solid resolution logic.


814-831: _isMapEntryTombstoned checks entry and object references.
Appropriately excludes references to tombstoned objects, ensuring the map entry is also treated as tombstoned. Matches the CRDT approach.

VeskeR added 2 commits April 9, 2025 08:52
… 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)
@VeskeR VeskeR force-pushed the PUB-1539/rename-internal-state-term-to-objects branch from 8c825c5 to 8846a8b Compare April 9, 2025 07:52
@VeskeR VeskeR merged commit 44b9f75 into integration/liveobjects Apr 9, 2025
7 of 14 checks passed
@VeskeR VeskeR deleted the PUB-1539/rename-internal-state-term-to-objects branch April 9, 2025 07:56
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 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: ...d synced events 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)

📥 Commits

Reviewing files that changed from the base of the PR and between 8c825c5 and 8846a8b.

📒 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 ObjectMessage from the renamed file objectmessage.ts instead of StateMessage from statemessage.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 _queuedMessages has been properly updated from StateMessage[] to ObjectMessage[] 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 queueStateMessage to queueMessage and its parameter type updated from StateMessage to ObjectMessage to 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 ts

Length of output: 35


Renaming Verified – Please Manually Confirm

The method in src/plugins/objects/batchcontext.ts (lines 88-89) has been updated from queueStateMessage to queueMessage with its parameter type changed from StateMessage to ObjectMessage to match the new terminology. A preliminary search using rg -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 terminology

The function has been successfully renamed from stateMessageFromValues to objectMessageFromValues to align with the new object-based terminology, and it now correctly calls ObjectMessage.fromValues instead of StateMessage.fromValues.


114-114: Function renamed to follow object terminology

The function has been successfully renamed from waitForStateOperation to waitForObjectOperation, maintaining the same functionality but aligned with the new naming convention.


182-183: Updated test description

Test description has been updated to reference "OBJECT ProtocolMessage" instead of "STATE ProtocolMessage" to align with the new terminology.


196-198: Updated comment and method reference

Comment now references "OBJECT message" and the method call has been updated to processObjectOperationMessageOnChannel, both following the new terminology.


214-215: Updated test description

Test 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 reference

Comment now references "OBJECT_SYNC message" and the method call has been updated to processObjectStateMessageOnChannel, both following the new terminology.


276-277: Updated test description

Test 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 description

Test description has been updated to reference "objects" instead of "states" to align with the new terminology.


309-310: Updated test description

Test description has been updated to reference "OBJECT_SYNC" instead of "STATE_SYNC" to align with the new terminology.


327-329: Updated assertion message

Assertion message has been updated to reference "OBJECT_SYNC" instead of "STATE_SYNC" to align with the new terminology.


338-339: Updated test description

Test description has been updated to reference "OBJECT_SYNC sequence" instead of "STATE_SYNC sequence" to align with the new terminology.


364-365: Updated test description

Test description has been updated to reference "OBJECT_SYNC" instead of "STATE_SYNC" to align with the new terminology.


377-379: Updated comment and method reference

Comment now references "OBJECT_SYNC message" and the method call has been updated to processObjectStateMessageOnChannel, both following the new terminology.


395-396: Updated assertion message

Assertion message has been updated to reference "OBJECT_SYNC" instead of "STATE_SYNC" to align with the new terminology.


397-399: Updated comment and method reference

Comment now references "OBJECT_SYNC message" and the method call has been updated to processObjectStateMessageOnChannel, both following the new terminology.


415-417: Updated assertion messages

Assertion messages have been updated to reference "OBJECT_SYNC sequence" instead of "STATE_SYNC sequence" to align with the new terminology.


423-424: Updated test description

Test description has been updated to reference "OBJECT_SYNC sequence" instead of "STATE_SYNC sequence" to align with the new terminology.


442-443: Updated assertion message

Assertion message has been updated to reference "OBJECT_SYNC sequence" instead of "STATE_SYNC sequence" to align with the new terminology.


486-487: Updated test description

Test description has been updated to reference "OBJECT_SYNC sequence" instead of "STATE_SYNC sequence" to align with the new terminology.


519-520: Updated test description

Test description has been updated to reference "OBJECT_SYNC sequence" instead of "STATE_SYNC sequence" to align with the new terminology.


659-660: Updated variable name

Variable name has been updated from stateSyncSequenceScenarios to objectSyncSequenceScenarios to align with the new terminology.


661-662: Updated test description

Test description has been updated to reference "OBJECT_SYNC sequence" instead of "STATE_SYNC sequence" to align with the new terminology.


667-669: Updated method reference

Method call has been updated to processObjectStateMessageOnChannel following the new terminology.


702-710: Updated assertion messages

Assertion messages have been updated to reference "OBJECT_SYNC" instead of "STATE_SYNC" to align with the new terminology.


715-716: Updated test description

Test description has been updated to reference "OBJECT_SYNC sequence" instead of "STATE_SYNC sequence" to align with the new terminology.


727-731: Updated assertion message

Assertion 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 reference

Comment now references "OBJECT_SYNC message" and the method call has been updated to processObjectStateMessageOnChannel, both following the new terminology.


758-762: Updated assertion messages

Assertion messages have been updated to reference "OBJECT_SYNC" instead of "STATE_SYNC" to align with the new terminology.


767-769: Updated test description

Test description has been updated to reference "OBJECT_SYNC sequence" instead of "STATE_SYNC sequence" to align with the new terminology.


785-786: Updated assertion message

Assertion 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 reference

Comment now references "OBJECT_SYNC message" and the method call has been updated to processObjectStateMessageOnChannel, both following the new terminology.


825-826: Updated test description

Test description has been updated to reference "object operation messages" instead of "state operation messages" to align with the new terminology.


889-890: Updated test description

Test description has been updated to reference "object operation messages" instead of "state operation messages" to align with the new terminology.


965-966: Updated test description

Test description has been updated to reference "object operation messages" instead of "state operation messages" to align with the new terminology.


980-981: Updated method reference

Method call has been updated to processObjectOperationMessageOnChannel following the new terminology.


986-987: Updated method reference

Method call has been updated to processObjectOperationMessageOnChannel following the new terminology.


1003-1016: Updated method reference

Method call has been updated to processObjectOperationMessageOnChannel following the new terminology.


1047-1048: Updated test description

Test description has been updated to reference "object operation messages" instead of "state operation messages" to align with the new terminology.


1096-1097: Updated test description

Test description has been updated to reference "object operation messages" instead of "state operation messages" to align with the new terminology.


1154-1155: Updated test description

Test description has been updated to reference "object operation messages" instead of "state operation messages" to align with the new terminology.


1160-1161: Updated method reference

Method call has been updated to processObjectOperationMessageOnChannel following the new terminology.


1178-1179: Updated method reference

Method call has been updated to processObjectOperationMessageOnChannel following the new terminology.


1194-1195: Updated method reference

Method call has been updated to processObjectOperationMessageOnChannel following the new terminology.


1223-1224: Updated test description

Test description has been updated to reference "object operation messages" instead of "state operation messages" to align with the new terminology.


1287-1288: Updated test description

Test description has been updated to reference "object operation messages" instead of "state operation messages" to align with the new terminology.


1292-1293: Updated method reference

Method call has been updated to processObjectOperationMessageOnChannel following the new terminology.


1310-1311: Updated method reference

Method call has been updated to processObjectOperationMessageOnChannel following the new terminology.


1326-1327: Updated method reference

Method call has been updated to processObjectOperationMessageOnChannel following the new terminology.


1358-1359: Updated test description

Test description has been updated to reference "object operation messages" instead of "state operation messages" to align with the new terminology.


1411-1412: Updated test description

Test description has been updated to reference "object operation messages" instead of "state operation messages" to align with the new terminology.


1426-1427: Updated method reference

Method call has been updated to processObjectOperationMessageOnChannel following the new terminology.


1432-1433: Updated method reference

Method call has been updated to processObjectOperationMessageOnChannel following the new terminology.


1449-1450: Updated method reference

Method call has been updated to processObjectOperationMessageOnChannel following the new terminology.


1479-1480: Updated test description

Test description has been updated to reference "object operation messages" instead of "state operation messages" to align with the new terminology.


1543-1544: Updated test description

Test description has been updated to reference "object operation messages" instead of "state operation messages" to align with the new terminology.


1549-1550: Updated method reference

Method call has been updated to processObjectOperationMessageOnChannel following the new terminology.


1555-1556: Updated method reference

Method call has been updated to processObjectOperationMessageOnChannel following the new terminology.


1571-1572: Updated method reference

Method call has been updated to processObjectOperationMessageOnChannel following the new terminology.


1588-1589: Updated test description

Test 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 reference

Method call has been updated to processObjectOperationMessageOnChannel following the new terminology.


1619-1620: Updated method reference

Method call has been updated to processObjectOperationMessageOnChannel following the new terminology.


1638-1639: Updated method reference

Method call has been updated to processObjectOperationMessageOnChannel following the new terminology.


1646-1647: Updated method reference

Method call has been updated to processObjectOperationMessageOnChannel following the new terminology.


1652-1653: Updated method reference

Method call has been updated to processObjectOperationMessageOnChannel following the new terminology.


1665-1666: Updated test description

Test 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 reference

Method call has been updated to processObjectOperationMessageOnChannel following the new terminology.


1686-1687: Updated method reference

Method call has been updated to processObjectOperationMessageOnChannel following the new terminology.


1703-1704: Updated method reference

Method call has been updated to processObjectOperationMessageOnChannel following the new terminology.


1793-1794: Updated method reference

Method call has been updated to processObjectOperationMessageOnChannel following the new terminology.


1799-1800: Updated method reference

Method call has been updated to processObjectOperationMessageOnChannel following the new terminology.


1827-1828: Updated method reference

Method call has been updated to processObjectOperationMessageOnChannel following the new terminology.


1835-1836: Updated method reference

Method call has been updated to processObjectOperationMessageOnChannel following the new terminology.


1848-1849: Updated test description

Test description has been updated to reference "object operation message" instead of "state operation message" to align with the new terminology.


1880-1881: Updated method reference

Method call has been updated to processObjectOperationMessageOnChannel following the new terminology.


1886-1887: Updated method reference

Method call has been updated to processObjectOperationMessageOnChannel following the new terminology.


1892-1893: Updated method reference

Method call has been updated to processObjectOperationMessageOnChannel following the new terminology.


1900-1901: Updated method reference

Method call has been updated to processObjectOperationMessageOnChannel following the new terminology.


1906-1907: Updated method reference

Method call has been updated to processObjectOperationMessageOnChannel following the new terminology.


1912-1913: Updated method reference

Method call has been updated to processObjectOperationMessageOnChannel following the new terminology.


1920-1927: Updated assertion messages

Assertion 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 description

Test 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 reference

Comment 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 reference

Method call has been updated to processObjectOperationMessageOnChannel following the new terminology.


1959-1961: Updated assertion message

Assertion message has been updated to reference "during OBJECT_SYNC" instead of "during STATE_SYNC" to align with the new terminology.


1966-1967: Updated test description

Test 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 reference

Comment 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 reference

Method call has been updated to processObjectOperationMessageOnChannel following the new terminology.


1990-1993: Updated method reference

Method call has been updated to processObjectStateMessageOnChannel following the new terminology.


2002-2008: Updated assertion messages

Assertion 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 description

Test 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 reference

Comment 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 reference

Method call has been updated to processObjectOperationMessageOnChannel following the new terminology.


2038-2042: Updated method reference

Method call has been updated to processObjectStateMessageOnChannel following the new terminology.


2045-2046: Updated method reference

Method call has been updated to processObjectOperationMessageOnChannel following the new terminology.


2053-2056: Updated method reference

Method call has been updated to processObjectStateMessageOnChannel following the new terminology.


2062-2070: Updated assertion messages

Assertion 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 description

Test 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 comments

Method call has been updated to processObjectStateMessageOnChannel and comments have been updated to reference "object state messages" instead of "state state messages" to align with the new terminology.


2166-2168: Updated method reference

Method call has been updated to processObjectStateMessageOnChannel following the new terminology.


2185-2192: Updated assertion messages

Assertion 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 description

Test 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 reference

Method call has been updated to processObjectStateMessageOnChannel following the new terminology.


2211-2217: Updated method reference

Method call has been updated to processObjectOperationMessageOnChannel following the new terminology.


2222-2225: Updated method reference

Method call has been updated to processObjectStateMessageOnChannel following the new terminology.


2240-2258: Updated assertion messages

Assertion 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 description

Test description has been updated to reference "object tree" instead of "state tree" to align with the new terminology.


2705-2706: Updated assertion message

Assertion 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 name

Method reference and variable name have been updated to use objectMessages instead of stateMessages to align with the new terminology.


2737-2738: Updated method reference

Method call has been updated to processObjectOperationMessageOnChannel following the new terminology.


2919-2920: Updated test description

Test description has been updated to reference "object tree" instead of "state tree" to align with the new terminology.


2934-2943: Updated assertion messages

Assertion 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 name

Method reference and variable name have been updated to use objectMessages instead of stateMessages to align with the new terminology.


2973-2974: Updated method reference

Method call has been updated to processObjectOperationMessageOnChannel following the new terminology.


3012-3013: Updated method reference

Method call has been updated to processObjectOperationMessageOnChannel following the new terminology.


3042-3053: Updated error message

Error 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 description

Test description has been updated to reference object-based terminology in the batch API context.


3417-3418: Updated method reference

Method call has been updated to processObjectStateMessageOnChannel following the new terminology.


3475-3476: Updated method reference

Method call has been updated to processObjectStateMessageOnChannel following the new terminology.


4098-4098: Updated method reference

Method call has been updated from waitForStateOperation to waitForObjectOperation following the new terminology.


4110-4111: Updated method reference

Method call has been updated to processObjectOperationMessageOnChannel following the new terminology.


4460-4461: Updated test description

Test description has been updated to reference "object message publish" instead of "state message publish" to align with the new terminology.


4497-4498: Updated error message

Error message has been updated to reference "object messages" instead of "state messages" to align with the new terminology.


4504-4505: Updated describe section title

Describe 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 reference

Method reference has been updated from stateMessageFromValues to objectMessageFromValues to align with the new terminology.


4717-4721: Updated method references

Multiple method references have been updated from StateMessage to ObjectMessage to align with the new terminology.


4729-4730: Updated test description

Test 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, StateOperationAction to ObjectMessage, 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 _bufferedStateOperations to _bufferedObjectOperations to 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 handleStateSyncMessages to handleObjectSyncMessages and its parameter type updated from StateMessage[] to ObjectMessage[], which is consistent with the PR objectives.


235-235: Method renamed to use object-based terminology.

The method has been renamed from handleStateMessages to handleObjectMessages and its parameter type updated from StateMessage[] to ObjectMessage[].


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 hasState to hasObjects to 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 hasObjects instead of hasState, 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 of StateMessage[], 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 ObjectMessage and 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 objectMessages instead of stateMessages.


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 overrideWithStateObject to overrideWithObjectState, and the parameter name has been updated from entry.stateObject to entry.objectState.


400-400: Updated method call to use object-based terminology.

The method call has been changed from LiveCounter.fromStateObject to LiveCounter.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.fromStateObject to LiveMap.fromObjectState, and the parameter name has been updated.


421-423: Method renamed to use object-based terminology.

The method has been renamed from _applyStateMessages to _applyObjectMessages and the parameter type updated from StateMessage[] to ObjectMessage[]. 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 stateOperation to objectOperation and the property access has been updated from stateMessage.stateOperation to objectMessage.operation.


435-442: Updated switch statement to use object-based action types.

The switch statement now uses ObjectOperationAction enum values instead of StateOperationAction enum values.


448-449: Updated object pool access and method call to use object-based terminology.

The code now uses objectOperation.objectId instead of stateOperation.objectId, and passes objectOperation and objectMessage instead of stateOperation and stateMessage to 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 StateOperationAction enum has been renamed to ObjectOperationAction with 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 StateValue type has been renamed to ObjectValue with its comment updated accordingly.


25-26: Renamed interface to use object-based terminology.

The StateData interface has been renamed to ObjectData with its comment updated to reflect the change.


34-35: Updated type reference in interface.

The property type reference has been updated from StateValue to ObjectValue to maintain consistency with the renamed type.


38-44: Renamed interface and updated its properties to use object-based terminology.

The StateMapOp interface has been renamed to MapOp with its comment updated, and its property type reference has been updated from StateData to ObjectData.


46-50: Renamed interface to use object-based terminology.

The StateCounterOp interface has been renamed to CounterOp with its comment updated.


53-65: Renamed interface and updated its properties to use object-based terminology.

The StateMapEntry interface has been renamed to MapEntry, and its property type reference has been updated from StateData to ObjectData.


67-73: Renamed interface and updated its properties to use object-based terminology.

The StateMap interface has been renamed to ObjectMap, and its property type reference has been updated from Record<string, StateMapEntry> to Record<string, MapEntry>.


75-79: Renamed interface to use object-based terminology.

The StateCounter interface has been renamed to ObjectCounter with its comment updated.


81-116: Renamed interface and updated its properties to use object-based terminology.

The StateOperation interface has been renamed to ObjectOperation, with its properties and comments updated to reflect the new terminology. Property names like stateMapOp, stateCounterOp, stateMap, and stateCounter have been renamed to their object-based equivalents.


117-141: Renamed interface and updated its properties to use object-based terminology.

The StateObject interface has been renamed to ObjectState, with its properties and comments updated to reflect the new terminology. The type reference for createOp has been updated from StateOperation to ObjectOperation, and properties like stateMap and stateCounter have been renamed to their object-based equivalents.


146-168: Renamed class and updated its properties to use object-based terminology.

The StateMessage class has been renamed to ObjectMessage, with its properties and comments updated to reflect the new terminology. Properties like stateOperation and stateObject have been renamed to operation and object, and their type references have been updated accordingly.


181-196: Updated method signature and implementation to use object-based terminology.

The encode static method now works with ObjectMessage instead of StateMessage, and the method calls inside have been updated to use the new names like _encodeObjectOperation and _encodeObjectState.


317-341: Renamed method and updated its implementation to use object-based terminology.

The _encodeStateOperation method 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 _encodeStateObject method 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 _encodeStateData method has been renamed to _encodeObjectData, maintaining the same functionality but with updated naming.


379-407: Updated method implementation to use object-based terminology.

The _encodeForWireProtocol method now works with ObjectMessage instead of StateMessage, 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 toJSON method'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 [ObjectMessage instead of [StateMessage], and refers to operation and object properties instead of stateOperation and stateObject.


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, and ObjectState instead of their state-based equivalents.


30-33: Method renamed to use object-based terminology.

The fromStateObject method has been renamed to fromObjectState with its parameter type updated from StateObject to ObjectState. The implementation has been updated to call overrideWithObjectState instead of overrideWithStateObject.


42-45: Method renamed to use object-based terminology.

The fromStateOperation method has been renamed to fromObjectOperation with its parameter type updated from StateOperation to ObjectOperation. The implementation has been updated to use the new parameter name.


51-71: Updated method to return ObjectMessage and use Number.isFinite.

The createCounterIncMessage method now returns ObjectMessage instead of StateMessage, and has been updated to use Number.isFinite instead of isFinite for safer numeric checks. The implementation creates an ObjectMessage with an ObjectOperation containing the COUNTER_INC action.

The change from isFinite to Number.isFinite is important because the global isFinite() attempts type coercion while Number.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 createCounterCreateMessage method now returns Promise<ObjectMessage> instead of Promise<StateMessage>, and has been updated to create an ObjectMessage with an ObjectOperation containing the COUNTER_CREATE action.


117-123: Updated method return type to use object-based terminology.

The createInitialValueObject method now returns Pick<ObjectOperation, 'counter'> instead of Pick<StateOperation, 'stateCounter'>, with the property name updated to match the new terminology.


141-143: Updated method calls to use object-based terminology.

The increment method now calls createCounterIncMessage to create an ObjectMessage instead of a StateMessage.


152-154: Updated numeric validation to use Number.isFinite.

Similar to the change in line 54, the code now uses Number.isFinite instead of isFinite for 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 applyOperation method now accepts ObjectOperation and ObjectMessage instead of StateOperation and StateMessage, and the switch statement now uses ObjectOperationAction enum 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 overrideWithStateObject method has been renamed to overrideWithObjectState with its parameter type updated from StateObject to ObjectState. 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 _mergeInitialDataFromCreateOperation method now accepts objectOperation: ObjectOperation instead of stateOperation: StateOperation, and accesses the counter property as objectOperation.counter?.count instead of stateOperation.stateCounter?.count.


308-314: Method updated to use object-based parameter.

The _throwNoPayloadError method now accepts op: ObjectOperation instead of op: StateOperation.


316-331: Method updated to use object-based parameter.

The _applyCounterCreate method now accepts op: ObjectOperation instead of op: StateOperation.


333-336: Method updated to use object-based parameter.

The _applyCounterInc method now accepts op: CounterOp instead of op: 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

3 participants