-
Notifications
You must be signed in to change notification settings - Fork 2
[ECO-5500] Add support for JSON-valued map values and update the wire representation of these values #45
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
WalkthroughThis change introduces support for JSON object and array values in map entries. It updates the public API, wire protocol, and internal representations to distinguish between string and JSON data, adds new enum cases and properties for JSON, and revises related tests and documentation to reflect the new capabilities. Changes
Sequence Diagram(s)sequenceDiagram
participant Client
participant LiveMap
participant WireProtocol
participant InternalValue
Client->>LiveMap: set(key, value: JSON object/array)
LiveMap->>WireProtocol: serialize ObjectData (string/json)
WireProtocol->>LiveMap: deserialize to ObjectData
LiveMap->>InternalValue: convert to InternalLiveMapValue (with jsonArray/jsonObject)
Client->>LiveMap: get(key)
LiveMap->>Client: return LiveMapValue (with jsonArray/jsonObject)
Estimated code review effort🎯 4 (Complex) | ⏱️ ~35 minutes Assessment against linked issues
Assessment against linked issues: Out-of-scope changesNo out-of-scope changes found. Suggested reviewers
Poem
Note ⚡️ Unit Test Generation is now available in beta!Learn more here, or try it out under "Finishing Touches" below. 📜 Recent review detailsConfiguration used: CodeRabbit UI 📒 Files selected for processing (11)
💤 Files with no reviewable changes (1)
✅ Files skipped from review due to trivial changes (2)
🚧 Files skipped from review as they are similar to previous changes (8)
✨ Finishing Touches
🧪 Generate unit tests
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
fa89d36 to
8a91281
Compare
8a91281 to
6fecc91
Compare
|
@coderabbitai review |
✅ Actions performedReview triggered.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Nitpick comments (1)
Sources/AblyLiveObjects/Protocol/ObjectMessage.swift (1)
51-51: Add validation for JSON content.While the JSON parsing logic at lines 221-223 will catch malformed JSON, consider adding validation for:
- Maximum JSON depth to prevent stack overflow attacks
- Maximum JSON string size to prevent memory exhaustion
- Allowed JSON structure constraints (if any) per the specification
// TODO: Needs specification (see https://github.com/ably/ably-cocoa-liveobjects-plugin/issues/46) if let wireJson = wireObjectData.json { + // Add size validation + guard wireJson.count <= 1_000_000 else { // 1MB limit + throw InternalError("JSON string exceeds maximum allowed size") + } let jsonValue = try JSONObjectOrArray(jsonString: wireJson) json = jsonValue } else { json = nil }Also applies to: 220-227
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (11)
Sources/AblyLiveObjects/Internal/InternalDefaultLiveMap.swift(1 hunks)Sources/AblyLiveObjects/Internal/InternalLiveMapValue.swift(1 hunks)Sources/AblyLiveObjects/Protocol/ObjectMessage.swift(4 hunks)Sources/AblyLiveObjects/Protocol/WireObjectMessage.swift(2 hunks)Sources/AblyLiveObjects/Public/PublicTypes.swift(4 hunks)Sources/AblyLiveObjects/Utility/JSONValue.swift(8 hunks)Tests/AblyLiveObjectsTests/Helpers/TestFactories.swift(5 hunks)Tests/AblyLiveObjectsTests/InternalDefaultLiveMapTests.swift(13 hunks)Tests/AblyLiveObjectsTests/ObjectMessageTests.swift(21 hunks)Tests/AblyLiveObjectsTests/ObjectsPoolTests.swift(2 hunks)Tests/AblyLiveObjectsTests/WireObjectMessageTests.swift(0 hunks)
💤 Files with no reviewable changes (1)
- Tests/AblyLiveObjectsTests/WireObjectMessageTests.swift
🧰 Additional context used
🧠 Learnings (11)
📓 Common learnings
Learnt from: CR
PR: ably/ably-cocoa-liveobjects-plugin#0
File: .cursor/rules/swift.mdc:0-0
Timestamp: 2025-07-29T08:07:47.875Z
Learning: Applies to **/*.swift : When writing JSONValue or WireValue types, favour using the literal syntax enabled by their conformance to the `ExpressibleBy*Literal` protocols where possible.
Tests/AblyLiveObjectsTests/ObjectsPoolTests.swift (8)
Learnt from: CR
PR: ably/ably-cocoa-liveobjects-plugin#0
File: .cursor/rules/swift.mdc:0-0
Timestamp: 2025-07-29T08:07:47.875Z
Learning: Applies to AblyLiveObjects/**/!(*Test|*Tests).swift : When importing the Ably module inside the AblyLiveObjects library code (non-test code), use import Ably.
Learnt from: CR
PR: ably/ably-cocoa-liveobjects-plugin#0
File: .cursor/rules/swift.mdc:0-0
Timestamp: 2025-07-29T08:07:47.875Z
Learning: Applies to AblyLiveObjects/**/!(*Test|*Tests).swift : When importing the AblyPlugin module inside the AblyLiveObjects library code (non-test code), use internal import AblyPlugin.
Learnt from: CR
PR: ably/ably-cocoa-liveobjects-plugin#0
File: .cursor/rules/testing.mdc:0-0
Timestamp: 2025-07-29T08:07:58.385Z
Learning: Applies to /Tests//*.swift : When you need to import the following modules in the tests, do so in the following way: Ably: use import Ably; AblyLiveObjects: use @testable import AblyLiveObjects; AblyPlugin: use import AblyPlugin; do not do internal import.
Learnt from: CR
PR: ably/ably-cocoa-liveobjects-plugin#0
File: .cursor/rules/testing.mdc:0-0
Timestamp: 2025-07-29T08:08:00.588Z
Learning: Applies to /Tests//*.swift : When you need to import the following modules in the tests, do so in the following way: Ably: use import Ably; AblyLiveObjects: use @testable import AblyLiveObjects; AblyPlugin: use import AblyPlugin; do not do internal import.
Learnt from: CR
PR: ably/ably-cocoa-liveobjects-plugin#0
File: .cursor/rules/testing.mdc:0-0
Timestamp: 2025-07-29T08:08:00.588Z
Learning: Applies to /Tests//*.swift : Add comments that explain when some piece of test data is not important for the scenario being tested.
Learnt from: CR
PR: ably/ably-cocoa-liveobjects-plugin#0
File: .cursor/rules/testing.mdc:0-0
Timestamp: 2025-07-29T08:07:58.385Z
Learning: Applies to /Tests//*.swift : When writing tests, make sure to add comments that explain when some piece of test data is not important for the scenario being tested.
Learnt from: CR
PR: ably/ably-cocoa-liveobjects-plugin#0
File: .cursor/rules/testing.mdc:0-0
Timestamp: 2025-07-29T08:08:00.588Z
Learning: Applies to /Tests//*.swift : When creating testsOnly_ property declarations, do not write generic comments of the form 'Test-only access to the private createOperationIsMerged property'; the meaning of these properties is already well understood.
Learnt from: CR
PR: ably/ably-cocoa-liveobjects-plugin#0
File: .cursor/rules/testing.mdc:0-0
Timestamp: 2025-07-29T08:07:58.385Z
Learning: Applies to /Tests//*.swift : When creating testsOnly_ property declarations, do not write generic comments of the form 'Test-only access to the private createOperationIsMerged property'; the meaning of these properties is already well understood.
Sources/AblyLiveObjects/Internal/InternalLiveMapValue.swift (2)
Learnt from: CR
PR: ably/ably-cocoa-liveobjects-plugin#0
File: .cursor/rules/swift.mdc:0-0
Timestamp: 2025-07-29T08:07:47.875Z
Learning: Applies to **/*.swift : When writing JSONValue or WireValue types, favour using the literal syntax enabled by their conformance to the ExpressibleBy*Literal protocols where possible.
Learnt from: CR
PR: ably/ably-cocoa-liveobjects-plugin#0
File: .cursor/rules/swift.mdc:0-0
Timestamp: 2025-07-29T08:07:47.875Z
Learning: Applies to AblyLiveObjects/**/!(*Test|*Tests).swift : When importing the AblyPlugin module inside the AblyLiveObjects library code (non-test code), use internal import AblyPlugin.
Tests/AblyLiveObjectsTests/Helpers/TestFactories.swift (9)
Learnt from: CR
PR: ably/ably-cocoa-liveobjects-plugin#0
File: .cursor/rules/swift.mdc:0-0
Timestamp: 2025-07-29T08:07:47.875Z
Learning: Applies to AblyLiveObjects/**/!(*Test|*Tests).swift : When importing the Ably module inside the AblyLiveObjects library code (non-test code), use import Ably.
Learnt from: CR
PR: ably/ably-cocoa-liveobjects-plugin#0
File: .cursor/rules/swift.mdc:0-0
Timestamp: 2025-07-29T08:07:47.875Z
Learning: Applies to **/*.swift : When writing JSONValue or WireValue types, favour using the literal syntax enabled by their conformance to the ExpressibleBy*Literal protocols where possible.
Learnt from: CR
PR: ably/ably-cocoa-liveobjects-plugin#0
File: .cursor/rules/testing.mdc:0-0
Timestamp: 2025-07-29T08:08:00.588Z
Learning: Applies to /Tests//*.swift : When creating testsOnly_ property declarations, do not write generic comments of the form 'Test-only access to the private createOperationIsMerged property'; the meaning of these properties is already well understood.
Learnt from: CR
PR: ably/ably-cocoa-liveobjects-plugin#0
File: .cursor/rules/testing.mdc:0-0
Timestamp: 2025-07-29T08:07:58.385Z
Learning: Applies to /Tests//*.swift : When creating testsOnly_ property declarations, do not write generic comments of the form 'Test-only access to the private createOperationIsMerged property'; the meaning of these properties is already well understood.
Learnt from: CR
PR: ably/ably-cocoa-liveobjects-plugin#0
File: .cursor/rules/swift.mdc:0-0
Timestamp: 2025-07-29T08:07:47.875Z
Learning: Applies to AblyLiveObjects/**/!(*Test|*Tests).swift : When importing the AblyPlugin module inside the AblyLiveObjects library code (non-test code), use internal import AblyPlugin.
Learnt from: CR
PR: ably/ably-cocoa-liveobjects-plugin#0
File: .cursor/rules/testing.mdc:0-0
Timestamp: 2025-07-29T08:08:00.588Z
Learning: Applies to /Tests//*.swift : Add comments that explain when some piece of test data is not important for the scenario being tested.
Learnt from: CR
PR: ably/ably-cocoa-liveobjects-plugin#0
File: .cursor/rules/testing.mdc:0-0
Timestamp: 2025-07-29T08:07:58.385Z
Learning: Applies to /Tests//*.swift : When you need to import the following modules in the tests, do so in the following way: Ably: use import Ably; AblyLiveObjects: use @testable import AblyLiveObjects; AblyPlugin: use import AblyPlugin; do not do internal import.
Learnt from: CR
PR: ably/ably-cocoa-liveobjects-plugin#0
File: .cursor/rules/testing.mdc:0-0
Timestamp: 2025-07-29T08:08:00.588Z
Learning: Applies to /Tests//*.swift : When you need to import the following modules in the tests, do so in the following way: Ably: use import Ably; AblyLiveObjects: use @testable import AblyLiveObjects; AblyPlugin: use import AblyPlugin; do not do internal import.
Learnt from: CR
PR: ably/ably-cocoa-liveobjects-plugin#0
File: .cursor/rules/testing.mdc:0-0
Timestamp: 2025-07-29T08:07:58.385Z
Learning: Applies to /Tests//*.swift : When writing tests, make sure to add comments that explain when some piece of test data is not important for the scenario being tested.
Sources/AblyLiveObjects/Internal/InternalDefaultLiveMap.swift (2)
Learnt from: CR
PR: ably/ably-cocoa-liveobjects-plugin#0
File: .cursor/rules/swift.mdc:0-0
Timestamp: 2025-07-29T08:07:47.875Z
Learning: Applies to **/*.swift : When writing JSONValue or WireValue types, favour using the literal syntax enabled by their conformance to the ExpressibleBy*Literal protocols where possible.
Learnt from: CR
PR: ably/ably-cocoa-liveobjects-plugin#0
File: .cursor/rules/swift.mdc:0-0
Timestamp: 2025-07-29T08:07:47.875Z
Learning: Applies to AblyLiveObjects/**/!(*Test|*Tests).swift : When importing the Ably module inside the AblyLiveObjects library code (non-test code), use import Ably.
Tests/AblyLiveObjectsTests/InternalDefaultLiveMapTests.swift (15)
Learnt from: CR
PR: ably/ably-cocoa-liveobjects-plugin#0
File: .cursor/rules/testing.mdc:0-0
Timestamp: 2025-07-29T08:08:00.588Z
Learning: Applies to /Tests//*.swift : When you need to import the following modules in the tests, do so in the following way: Ably: use import Ably; AblyLiveObjects: use @testable import AblyLiveObjects; AblyPlugin: use import AblyPlugin; do not do internal import.
Learnt from: CR
PR: ably/ably-cocoa-liveobjects-plugin#0
File: .cursor/rules/testing.mdc:0-0
Timestamp: 2025-07-29T08:07:58.385Z
Learning: Applies to /Tests//*.swift : When you need to import the following modules in the tests, do so in the following way: Ably: use import Ably; AblyLiveObjects: use @testable import AblyLiveObjects; AblyPlugin: use import AblyPlugin; do not do internal import.
Learnt from: CR
PR: ably/ably-cocoa-liveobjects-plugin#0
File: .cursor/rules/swift.mdc:0-0
Timestamp: 2025-07-29T08:07:47.875Z
Learning: Applies to AblyLiveObjects/**/!(*Test|*Tests).swift : When importing the Ably module inside the AblyLiveObjects library code (non-test code), use import Ably.
Learnt from: CR
PR: ably/ably-cocoa-liveobjects-plugin#0
File: .cursor/rules/swift.mdc:0-0
Timestamp: 2025-07-29T08:07:47.875Z
Learning: Applies to AblyLiveObjects/**/!(*Test|*Tests).swift : When importing the AblyPlugin module inside the AblyLiveObjects library code (non-test code), use internal import AblyPlugin.
Learnt from: CR
PR: ably/ably-cocoa-liveobjects-plugin#0
File: .cursor/rules/testing.mdc:0-0
Timestamp: 2025-07-29T08:07:58.385Z
Learning: Applies to /Tests//*.swift : When writing tests, make sure to add comments that explain when some piece of test data is not important for the scenario being tested.
Learnt from: CR
PR: ably/ably-cocoa-liveobjects-plugin#0
File: .cursor/rules/testing.mdc:0-0
Timestamp: 2025-07-29T08:08:00.588Z
Learning: Applies to /Tests//*.swift : Add comments that explain when some piece of test data is not important for the scenario being tested.
Learnt from: CR
PR: ably/ably-cocoa-liveobjects-plugin#0
File: .cursor/rules/testing.mdc:0-0
Timestamp: 2025-07-29T08:07:58.385Z
Learning: Applies to /Tests//*.swift : When creating testsOnly_ property declarations, do not write generic comments of the form 'Test-only access to the private createOperationIsMerged property'; the meaning of these properties is already well understood.
Learnt from: CR
PR: ably/ably-cocoa-liveobjects-plugin#0
File: .cursor/rules/testing.mdc:0-0
Timestamp: 2025-07-29T08:08:00.588Z
Learning: Applies to /Tests//*.swift : When creating testsOnly_ property declarations, do not write generic comments of the form 'Test-only access to the private createOperationIsMerged property'; the meaning of these properties is already well understood.
Learnt from: CR
PR: ably/ably-cocoa-liveobjects-plugin#0
File: .cursor/rules/testing.mdc:0-0
Timestamp: 2025-07-29T08:08:00.588Z
Learning: Applies to /Tests//*.swift : Follow the guidelines given under 'Attributing tests to a spec point' in the file CONTRIBUTING.md in order to tag the unit tests with the relevant specification points. Make sure to follow the exact format of the comments as described in that file. Pay particular attention to the difference between the meaning of @spec and @specPartial and be sure not to write @spec multiple times for the same specification point.
Learnt from: CR
PR: ably/ably-cocoa-liveobjects-plugin#0
File: .cursor/rules/testing.mdc:0-0
Timestamp: 2025-07-29T08:08:00.588Z
Learning: Applies to /Tests//*.swift : Only add labels to test cases or suites when the label is different to the name of the suite struct or test method.
Learnt from: CR
PR: ably/ably-cocoa-liveobjects-plugin#0
File: .cursor/rules/testing.mdc:0-0
Timestamp: 2025-07-29T08:07:58.385Z
Learning: Applies to /Tests//*.swift : When you need to pass a logger to internal components in the tests, pass TestLogger().
Learnt from: CR
PR: ably/ably-cocoa-liveobjects-plugin#0
File: .cursor/rules/testing.mdc:0-0
Timestamp: 2025-07-29T08:08:00.588Z
Learning: Applies to /Tests//*.swift : When you need to pass a logger to internal components in the tests, pass TestLogger().
Learnt from: CR
PR: ably/ably-cocoa-liveobjects-plugin#0
File: .cursor/rules/testing.mdc:0-0
Timestamp: 2025-07-29T08:08:00.588Z
Learning: Applies to /Tests//*.swift : When you need to unwrap an optional value in the tests, favour using #require instead of guard let.
Learnt from: CR
PR: ably/ably-cocoa-liveobjects-plugin#0
File: .cursor/rules/testing.mdc:0-0
Timestamp: 2025-07-29T08:07:58.385Z
Learning: Applies to /Tests//*.swift : When you need to unwrap an optional value in the tests, favour using #require instead of guard let.
Learnt from: CR
PR: ably/ably-cocoa-liveobjects-plugin#0
File: .cursor/rules/swift.mdc:0-0
Timestamp: 2025-07-29T08:07:47.875Z
Learning: Applies to **/*.swift : When writing JSONValue or WireValue types, favour using the literal syntax enabled by their conformance to the ExpressibleBy*Literal protocols where possible.
Sources/AblyLiveObjects/Public/PublicTypes.swift (1)
Learnt from: CR
PR: ably/ably-cocoa-liveobjects-plugin#0
File: .cursor/rules/swift.mdc:0-0
Timestamp: 2025-07-29T08:07:47.875Z
Learning: Applies to **/*.swift : When writing JSONValue or WireValue types, favour using the literal syntax enabled by their conformance to the ExpressibleBy*Literal protocols where possible.
Sources/AblyLiveObjects/Utility/JSONValue.swift (9)
Learnt from: CR
PR: ably/ably-cocoa-liveobjects-plugin#0
File: .cursor/rules/swift.mdc:0-0
Timestamp: 2025-07-29T08:07:47.875Z
Learning: Applies to **/*.swift : When writing JSONValue or WireValue types, favour using the literal syntax enabled by their conformance to the ExpressibleBy*Literal protocols where possible.
Learnt from: CR
PR: ably/ably-cocoa-liveobjects-plugin#0
File: .cursor/rules/swift.mdc:0-0
Timestamp: 2025-07-29T08:07:47.875Z
Learning: Applies to AblyLiveObjects/**/!(*Test|*Tests).swift : When importing the AblyPlugin module inside the AblyLiveObjects library code (non-test code), use internal import AblyPlugin.
Learnt from: CR
PR: ably/ably-cocoa-liveobjects-plugin#0
File: .cursor/rules/testing.mdc:0-0
Timestamp: 2025-07-29T08:07:58.385Z
Learning: Applies to /Tests//*.swift : When you need to import the following modules in the tests, do so in the following way: Ably: use import Ably; AblyLiveObjects: use @testable import AblyLiveObjects; AblyPlugin: use import AblyPlugin; do not do internal import.
Learnt from: CR
PR: ably/ably-cocoa-liveobjects-plugin#0
File: .cursor/rules/testing.mdc:0-0
Timestamp: 2025-07-29T08:08:00.588Z
Learning: Applies to /Tests//*.swift : When you need to import the following modules in the tests, do so in the following way: Ably: use import Ably; AblyLiveObjects: use @testable import AblyLiveObjects; AblyPlugin: use import AblyPlugin; do not do internal import.
Learnt from: CR
PR: ably/ably-cocoa-liveobjects-plugin#0
File: .cursor/rules/swift.mdc:0-0
Timestamp: 2025-07-29T08:07:47.875Z
Learning: Applies to AblyLiveObjects/**/!(*Test|*Tests).swift : When importing the Ably module inside the AblyLiveObjects library code (non-test code), use import Ably.
Learnt from: CR
PR: ably/ably-cocoa-liveobjects-plugin#0
File: .cursor/rules/swift.mdc:0-0
Timestamp: 2025-07-29T08:07:47.875Z
Learning: Applies to **/!(*Test|*Tests).swift : Satisfy SwiftLint's explicit_acl rule: all declarations should specify Access Control Level keywords explicitly.
Learnt from: CR
PR: ably/ably-cocoa-liveobjects-plugin#0
File: .cursor/rules/swift.mdc:0-0
Timestamp: 2025-07-29T08:07:47.875Z
Learning: Applies to **/*.swift : When writing enum value expressions, when the type that is being initialized can be inferred, favour using the implicit .caseName form instead of explicitly writing the type name.
Learnt from: CR
PR: ably/ably-cocoa-liveobjects-plugin#0
File: .cursor/rules/swift.mdc:0-0
Timestamp: 2025-07-29T08:07:47.875Z
Learning: Applies to **/*.swift : When writing an array literal that starts with an initializer expression, start the initializer expression on the line after the opening square bracket of the array literal.
Learnt from: CR
PR: ably/ably-cocoa-liveobjects-plugin#0
File: .cursor/rules/swift.mdc:0-0
Timestamp: 2025-07-29T08:07:47.875Z
Learning: Applies to **/*.swift : When writing initializer expressions, when the type that is being initialized can be inferred, favour using the implicit .init(…) form instead of explicitly writing the type name.
Sources/AblyLiveObjects/Protocol/WireObjectMessage.swift (3)
Learnt from: CR
PR: ably/ably-cocoa-liveobjects-plugin#0
File: .cursor/rules/swift.mdc:0-0
Timestamp: 2025-07-29T08:07:47.875Z
Learning: Applies to **/*.swift : When writing JSONValue or WireValue types, favour using the literal syntax enabled by their conformance to the ExpressibleBy*Literal protocols where possible.
Learnt from: CR
PR: ably/ably-cocoa-liveobjects-plugin#0
File: .cursor/rules/swift.mdc:0-0
Timestamp: 2025-07-29T08:07:47.875Z
Learning: Applies to AblyLiveObjects/**/!(*Test|*Tests).swift : When importing the Ably module inside the AblyLiveObjects library code (non-test code), use import Ably.
Learnt from: CR
PR: ably/ably-cocoa-liveobjects-plugin#0
File: .cursor/rules/swift.mdc:0-0
Timestamp: 2025-07-29T08:07:47.875Z
Learning: Applies to AblyLiveObjects/**/!(*Test|*Tests).swift : When importing the AblyPlugin module inside the AblyLiveObjects library code (non-test code), use internal import AblyPlugin.
Sources/AblyLiveObjects/Protocol/ObjectMessage.swift (3)
Learnt from: CR
PR: ably/ably-cocoa-liveobjects-plugin#0
File: .cursor/rules/swift.mdc:0-0
Timestamp: 2025-07-29T08:07:47.875Z
Learning: Applies to **/*.swift : When writing JSONValue or WireValue types, favour using the literal syntax enabled by their conformance to the ExpressibleBy*Literal protocols where possible.
Learnt from: CR
PR: ably/ably-cocoa-liveobjects-plugin#0
File: .cursor/rules/swift.mdc:0-0
Timestamp: 2025-07-29T08:07:47.875Z
Learning: Applies to AblyLiveObjects/**/!(*Test|*Tests).swift : When importing the Ably module inside the AblyLiveObjects library code (non-test code), use import Ably.
Learnt from: CR
PR: ably/ably-cocoa-liveobjects-plugin#0
File: .cursor/rules/specification.mdc:0-0
Timestamp: 2025-07-29T08:07:37.861Z
Learning: The LiveObjects functionality is referred to in the Specification simply as 'Objects'.
Tests/AblyLiveObjectsTests/ObjectMessageTests.swift (15)
Learnt from: CR
PR: ably/ably-cocoa-liveobjects-plugin#0
File: .cursor/rules/swift.mdc:0-0
Timestamp: 2025-07-29T08:07:47.875Z
Learning: Applies to AblyLiveObjects/**/!(*Test|*Tests).swift : When importing the Ably module inside the AblyLiveObjects library code (non-test code), use import Ably.
Learnt from: CR
PR: ably/ably-cocoa-liveobjects-plugin#0
File: .cursor/rules/testing.mdc:0-0
Timestamp: 2025-07-29T08:07:58.385Z
Learning: Applies to /Tests//*.swift : When writing tests, make sure to add comments that explain when some piece of test data is not important for the scenario being tested.
Learnt from: CR
PR: ably/ably-cocoa-liveobjects-plugin#0
File: .cursor/rules/swift.mdc:0-0
Timestamp: 2025-07-29T08:07:47.875Z
Learning: Applies to AblyLiveObjects/**/!(*Test|*Tests).swift : When importing the AblyPlugin module inside the AblyLiveObjects library code (non-test code), use internal import AblyPlugin.
Learnt from: CR
PR: ably/ably-cocoa-liveobjects-plugin#0
File: .cursor/rules/testing.mdc:0-0
Timestamp: 2025-07-29T08:08:00.588Z
Learning: Applies to /Tests//*.swift : When creating testsOnly_ property declarations, do not write generic comments of the form 'Test-only access to the private createOperationIsMerged property'; the meaning of these properties is already well understood.
Learnt from: CR
PR: ably/ably-cocoa-liveobjects-plugin#0
File: .cursor/rules/testing.mdc:0-0
Timestamp: 2025-07-29T08:07:58.385Z
Learning: Applies to /Tests//*.swift : When creating testsOnly_ property declarations, do not write generic comments of the form 'Test-only access to the private createOperationIsMerged property'; the meaning of these properties is already well understood.
Learnt from: CR
PR: ably/ably-cocoa-liveobjects-plugin#0
File: .cursor/rules/testing.mdc:0-0
Timestamp: 2025-07-29T08:08:00.588Z
Learning: Applies to /Tests//*.swift : When you need to import the following modules in the tests, do so in the following way: Ably: use import Ably; AblyLiveObjects: use @testable import AblyLiveObjects; AblyPlugin: use import AblyPlugin; do not do internal import.
Learnt from: CR
PR: ably/ably-cocoa-liveobjects-plugin#0
File: .cursor/rules/testing.mdc:0-0
Timestamp: 2025-07-29T08:07:58.385Z
Learning: Applies to /Tests//*.swift : When you need to import the following modules in the tests, do so in the following way: Ably: use import Ably; AblyLiveObjects: use @testable import AblyLiveObjects; AblyPlugin: use import AblyPlugin; do not do internal import.
Learnt from: CR
PR: ably/ably-cocoa-liveobjects-plugin#0
File: .cursor/rules/testing.mdc:0-0
Timestamp: 2025-07-29T08:08:00.588Z
Learning: Applies to /Tests//*.swift : Add comments that explain when some piece of test data is not important for the scenario being tested.
Learnt from: CR
PR: ably/ably-cocoa-liveobjects-plugin#0
File: .cursor/rules/testing.mdc:0-0
Timestamp: 2025-07-29T08:08:00.588Z
Learning: Applies to /Tests//*.swift : Follow the guidelines given under 'Attributing tests to a spec point' in the file CONTRIBUTING.md in order to tag the unit tests with the relevant specification points. Make sure to follow the exact format of the comments as described in that file. Pay particular attention to the difference between the meaning of @spec and @specPartial and be sure not to write @spec multiple times for the same specification point.
Learnt from: CR
PR: ably/ably-cocoa-liveobjects-plugin#0
File: .cursor/rules/swift.mdc:0-0
Timestamp: 2025-07-29T08:07:47.875Z
Learning: Applies to **/*.swift : When writing JSONValue or WireValue types, favour using the literal syntax enabled by their conformance to the ExpressibleBy*Literal protocols where possible.
Learnt from: CR
PR: ably/ably-cocoa-liveobjects-plugin#0
File: .cursor/rules/testing.mdc:0-0
Timestamp: 2025-07-29T08:07:58.385Z
Learning: Applies to /Tests//*.swift : Do not use fatalError in response to a test expectation failure. Favour the usage of Swift Testing's #require macro.
Learnt from: CR
PR: ably/ably-cocoa-liveobjects-plugin#0
File: .cursor/rules/testing.mdc:0-0
Timestamp: 2025-07-29T08:08:00.588Z
Learning: Applies to /Tests//*.swift : Do not use fatalError in response to a test expectation failure. Favour the usage of Swift Testing's #require macro.
Learnt from: CR
PR: ably/ably-cocoa-liveobjects-plugin#0
File: .cursor/rules/testing.mdc:0-0
Timestamp: 2025-07-29T08:07:58.385Z
Learning: Applies to /Tests//*.swift : When writing tests, follow the guidelines given under 'Attributing tests to a spec point' in the file CONTRIBUTING.md in order to tag the unit tests with the relevant specification points. Make sure to follow the exact format of the comments as described in that file. Pay particular attention to the difference between the meaning of @spec and @specPartial and be sure not to write @spec multiple times for the same specification point.
Learnt from: CR
PR: ably/ably-cocoa-liveobjects-plugin#0
File: .cursor/rules/testing.mdc:0-0
Timestamp: 2025-07-29T08:08:00.588Z
Learning: Applies to /Tests//*.swift : When you need to unwrap an optional value in the tests, favour using #require instead of guard let.
Learnt from: CR
PR: ably/ably-cocoa-liveobjects-plugin#0
File: .cursor/rules/testing.mdc:0-0
Timestamp: 2025-07-29T08:07:58.385Z
Learning: Applies to /Tests//*.swift : When you need to unwrap an optional value in the tests, favour using #require instead of guard let.
🧬 Code Graph Analysis (4)
Tests/AblyLiveObjectsTests/ObjectsPoolTests.swift (2)
Tests/AblyLiveObjectsTests/Helpers/TestFactories.swift (1)
mapEntry(393-403)Tests/AblyLiveObjectsTests/ObjectMessageTests.swift (4)
string(65-77)string(148-160)string(244-256)string(341-353)
Tests/AblyLiveObjectsTests/Helpers/TestFactories.swift (1)
Tests/AblyLiveObjectsTests/ObjectMessageTests.swift (4)
string(65-77)string(148-160)string(244-256)string(341-353)
Sources/AblyLiveObjects/Internal/InternalDefaultLiveMap.swift (1)
Tests/AblyLiveObjectsTests/ObjectMessageTests.swift (6)
string(65-77)string(148-160)string(244-256)string(341-353)json(259-271)json(384-395)
Sources/AblyLiveObjects/Protocol/ObjectMessage.swift (1)
Tests/AblyLiveObjectsTests/ObjectMessageTests.swift (6)
string(65-77)string(148-160)string(244-256)string(341-353)json(259-271)json(384-395)
🔇 Additional comments (27)
Tests/AblyLiveObjectsTests/ObjectsPoolTests.swift (2)
303-303: LGTM! Correct API usage after ObjectData simplification.The change from
ObjectData(string: .string("updated"))toObjectData(string: "updated")correctly reflects the API simplification where thestringparameter now expects a plainStringvalue instead of an enum-wrapped value.
316-316: LGTM! Consistent with ObjectData API simplification.This change maintains consistency with the updated
ObjectDataconstructor pattern, removing the unnecessary.stringenum wrapping.Sources/AblyLiveObjects/Internal/InternalLiveMapValue.swift (1)
55-63: LGTM! Well-designed JSON value accessors.The new
jsonArrayValueandjsonObjectValuecomputed properties follow the established pattern of other primitive value accessors in this enum. They correctly delegate to the underlyingprimitiveValueand maintain consistency with the existing API design.Sources/AblyLiveObjects/Internal/InternalDefaultLiveMap.swift (2)
716-717: LGTM! Correct string handling simplification.The removal of enum case distinction for string values correctly reflects the API simplification. The direct handling of
entry.data.stringand return of.primitive(.string(string))aligns with the broader refactor across the codebase.
719-727: LGTM! Well-implemented JSON value support.The new JSON handling correctly switches on array and object cases, returning the appropriate primitive types. The TODO comment appropriately references the related specification issue, indicating this is part of ongoing work to formalize JSON support.
Tests/AblyLiveObjectsTests/Helpers/TestFactories.swift (1)
432-432: LGTM! Consistent ObjectData API simplification across test factories.All changes correctly remove the redundant
.stringenum wrapping fromObjectDataconstructor calls throughout the test factory methods. The simplifiedObjectData(string: value)pattern is consistent with the API changes and maintains semantic equivalence while reducing complexity.Also applies to: 451-451, 542-542, 570-570, 679-679
Tests/AblyLiveObjectsTests/InternalDefaultLiveMapTests.swift (7)
88-88: LGTM - Simplified ObjectData initializationThe removal of redundant
.stringenum wrapping simplifies the code while maintaining the same functionality.
95-117: LGTM - Well-structured JSON array testThe new test correctly follows the established pattern and properly tests JSON array value retrieval. The use of literal syntax for the JSONValue aligns with best practices.
The TODO comment appropriately indicates the need for specification work.
107-117: LGTM - Consistent JSON object test implementationThe JSON object test follows the same well-established pattern as the JSON array test and correctly verifies the functionality using appropriate literal syntax.
321-325: LGTM - Consistent string initialization simplificationThe ObjectData string initializations follow the same simplified pattern throughout the file, maintaining consistency and reducing boilerplate.
367-369: LGTM - Continued consistent simplificationThese changes maintain the consistent pattern of simplified ObjectData string initialization across all tests.
415-417: LGTM - Comprehensive test coverage for JSON typesThe
entriesHandlesAllValueTypestest has been properly updated to include JSON array and object support:
- Correctly adds the new JSON entries using appropriate literal syntax
- Updates the expected counts from 6 to 8 entries
- Adds proper verification assertions for the new JSON value types
- Maintains consistency with existing test patterns
This provides comprehensive coverage for all supported value types.
Also applies to: 432-435, 442-443, 451-452
470-470: LGTM - Consistent simplification across all test methodsAll remaining ObjectData string initializations have been consistently simplified, removing redundant enum wrapping throughout the test suite. This creates a uniform, cleaner codebase while maintaining identical functionality.
Also applies to: 510-510, 682-682, 708-708, 833-833, 844-844
Sources/AblyLiveObjects/Public/PublicTypes.swift (4)
178-178: LGTM - Accurate documentation updateThe documentation correctly includes JSON-serializable objects and arrays as supported primitive types, maintaining consistency with the existing documentation style.
229-229: LGTM - Consistent API documentation updatesThe LiveMap protocol documentation has been consistently updated to include JSON-serializable objects and arrays, maintaining uniformity across the public API documentation.
Also applies to: 236-236
294-295: LGTM - Well-designed enum extensionsThe new
jsonArrayandjsonObjectcases follow the established enum pattern and use appropriateJSONValuetypes. The naming is consistent with existing cases.
331-345: LGTM - Perfectly consistent computed propertiesThe new
jsonArrayValueandjsonObjectValuecomputed properties follow the exact same pattern as all existing value accessors in the enum:
- Consistent naming convention with "Value" suffix
- Identical implementation pattern with case matching and optional returns
- Appropriate return types matching the enum case associated values
This maintains excellent API consistency across all primitive value types.
Sources/AblyLiveObjects/Protocol/WireObjectMessage.swift (1)
432-432: Consider the implications of using an unspecified wire format.The
jsonproperty is marked with a TODO indicating it needs specification. Using an unspecified wire format in production could lead to compatibility issues if the specification changes later.Have you coordinated with the specification team to ensure this wire format will remain stable? Consider adding more detailed documentation about the expected format and any constraints on the JSON string content.
Sources/AblyLiveObjects/Utility/JSONValue.swift (1)
28-28: LGTM!The visibility changes to make
JSONValuepublic are appropriate and necessary for exposing JSON support in the public API. The implementation maintains type safety through theExpressibleBy*Literalprotocols.Tests/AblyLiveObjectsTests/ObjectMessageTests.swift (8)
23-23: LGTM! Proper assertion of json property isolation.The added assertions correctly verify that the
jsonproperty remains nil when encoding other data types, ensuring proper data type isolation in ObjectData.Also applies to: 43-43, 61-61, 76-76, 93-93, 109-109, 129-129, 144-144, 159-159, 176-176
68-68: LGTM! Correct usage of simplified ObjectData API.The constructors now properly use the direct property constructors (
string:andjson:) instead of the previous nested enum approach, aligning with the API simplification.Also applies to: 86-86, 151-151, 169-169
92-94: LGTM! Correct JSON encoding test expectations.The assertions properly verify that JSON data is stored in the dedicated
jsonproperty as a string, while thestringproperty remains nil, reflecting the correct behavior of the new API.Also applies to: 175-177
79-79: LGTM! Appropriate documentation of unspecified behavior.The TODO comments correctly identify areas needing specification (issue #46), and the updated spec attributions maintain proper test-to-specification traceability. The comments about implementation choices for error handling provide valuable context.
Also applies to: 162-162, 258-258, 265-265, 273-274, 286-287, 311-311, 340-340, 383-383, 397-398, 410-411
194-194: LGTM! Proper decoding test assertions for data type isolation.The assertions correctly verify that the
jsonproperty remains nil when decoding other data types, ensuring proper data type isolation during the decoding process.Also applies to: 209-209, 225-225, 240-240, 255-255, 322-322, 337-337, 352-352, 368-368
270-270: LGTM! Correct JSON decoding test expectations.The assertions properly verify that JSON strings are decoded into the expected
JSONObjectOrArrayvalues, testing the core JSON decoding functionality correctly.Also applies to: 394-394
262-262: LGTM! Correct usage of updated WireObjectData API.The constructors properly use the new
json:parameter instead of the previous encoding-based approach, correctly reflecting the wire protocol API changes.Also applies to: 278-278, 301-301, 387-387, 402-402, 425-425
447-449: LGTM! Comprehensive round-trip testing for JSON functionality.The updated test data includes JSON objects and arrays, and the comparison logic properly tests both
stringandjsonproperties separately. This ensures comprehensive validation of JSON data through both encoding formats.Also applies to: 465-469
6fecc91 to
59783b1
Compare
ec5e928 to
bbf8229
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM - happy for you to merge once the conflict has been resolved. Feel free to let me know if you'd like me to take another look
Public API based on [1] at 6d43429. [1] ably/ably-js#2052
This implements the change described in [1]. It has not yet been specified — have created #46 for adding specification point references later. (We need to implement it now because Realtime has removed support for the previous wire representation.) Resolves #44. [1] https://ably.atlassian.net/wiki/spaces/LOB/pages/4203380843/LODR-040+ObjectData+JSON+encoding+of+object+and+array+values
59783b1 to
4034382
Compare
Note: This PR is based on top of #42; please review that one first.
Resolves #44. See commit messages for more details.
Summary by CodeRabbit
New Features
Bug Fixes
Documentation
Refactor
Tests