diff --git a/Sources/AblyLiveObjects/DefaultLiveObjects.swift b/Sources/AblyLiveObjects/DefaultRealtimeObjects.swift similarity index 97% rename from Sources/AblyLiveObjects/DefaultLiveObjects.swift rename to Sources/AblyLiveObjects/DefaultRealtimeObjects.swift index 117ce678..f96cb0e6 100644 --- a/Sources/AblyLiveObjects/DefaultLiveObjects.swift +++ b/Sources/AblyLiveObjects/DefaultRealtimeObjects.swift @@ -2,7 +2,7 @@ import Ably internal import AblyPlugin /// The class that provides the public API for interacting with LiveObjects, via the ``ARTRealtimeChannel/objects`` property. -internal class DefaultLiveObjects: Objects { +internal class DefaultRealtimeObjects: RealtimeObjects { private weak var channel: ARTRealtimeChannel? private let logger: AblyPlugin.Logger private let pluginAPI: AblyPlugin.PluginAPIProtocol @@ -21,7 +21,7 @@ internal class DefaultLiveObjects: Objects { (receivedObjectSyncProtocolMessages, receivedObjectSyncProtocolMessagesContinuation) = AsyncStream.makeStream() } - // MARK: `Objects` protocol + // MARK: `RealtimeObjects` protocol internal func getRoot() async throws(ARTErrorInfo) -> any LiveMap { notYetImplemented() diff --git a/Sources/AblyLiveObjects/Internal/DefaultInternalPlugin.swift b/Sources/AblyLiveObjects/Internal/DefaultInternalPlugin.swift index 21b59fa1..61b316a4 100644 --- a/Sources/AblyLiveObjects/Internal/DefaultInternalPlugin.swift +++ b/Sources/AblyLiveObjects/Internal/DefaultInternalPlugin.swift @@ -20,14 +20,14 @@ internal final class DefaultInternalPlugin: NSObject, AblyPlugin.LiveObjectsInte /// Retrieves the value that should be returned by `ARTRealtimeChannel.objects`. /// /// We expect this value to have been previously set by ``prepare(_:)``. - internal static func objectsProperty(for channel: ARTRealtimeChannel, pluginAPI: AblyPlugin.PluginAPIProtocol) -> DefaultLiveObjects { + internal static func objectsProperty(for channel: ARTRealtimeChannel, pluginAPI: AblyPlugin.PluginAPIProtocol) -> DefaultRealtimeObjects { guard let pluginData = pluginAPI.pluginDataValue(forKey: pluginDataKey, channel: channel) else { // InternalPlugin.prepare was not called fatalError("To access LiveObjects functionality, you must pass the LiveObjects plugin in the client options when creating the ARTRealtime instance: `clientOptions.plugins = [.liveObjects: AblyLiveObjects.Plugin.self]`") } // swiftlint:disable:next force_cast - return pluginData as! DefaultLiveObjects + return pluginData as! DefaultRealtimeObjects } // MARK: - LiveObjectsInternalPluginProtocol @@ -37,12 +37,12 @@ internal final class DefaultInternalPlugin: NSObject, AblyPlugin.LiveObjectsInte let logger = pluginAPI.logger(for: channel) logger.log("LiveObjects.DefaultInternalPlugin received prepare(_:)", level: .debug) - let liveObjects = DefaultLiveObjects(channel: channel, logger: logger, pluginAPI: pluginAPI) + let liveObjects = DefaultRealtimeObjects(channel: channel, logger: logger, pluginAPI: pluginAPI) pluginAPI.setPluginDataValue(liveObjects, forKey: Self.pluginDataKey, channel: channel) } /// Retrieves the internally-typed `objects` property for the channel. - private func objectsProperty(for channel: ARTRealtimeChannel) -> DefaultLiveObjects { + private func objectsProperty(for channel: ARTRealtimeChannel) -> DefaultRealtimeObjects { Self.objectsProperty(for: channel, pluginAPI: pluginAPI) } diff --git a/Sources/AblyLiveObjects/Protocol/ObjectMessage.swift b/Sources/AblyLiveObjects/Protocol/ObjectMessage.swift index a98dc049..a15ea0db 100644 --- a/Sources/AblyLiveObjects/Protocol/ObjectMessage.swift +++ b/Sources/AblyLiveObjects/Protocol/ObjectMessage.swift @@ -32,10 +32,10 @@ internal struct OutboundObjectMessage { internal struct ObjectOperation { internal var action: WireEnum // OOP3a internal var objectId: String // OOP3b - internal var mapOp: MapOp? // OOP3c - internal var counterOp: WireCounterOp? // OOP3d - internal var map: Map? // OOP3e - internal var counter: WireCounter? // OOP3f + internal var mapOp: ObjectsMapOp? // OOP3c + internal var counterOp: WireObjectsCounterOp? // OOP3d + internal var map: ObjectsMap? // OOP3e + internal var counter: WireObjectsCounter? // OOP3f internal var nonce: String? // OOP3g internal var initialValue: Data? // OOP3h internal var initialValueEncoding: String? // OOP3i @@ -56,20 +56,20 @@ internal struct ObjectData { internal var string: StringPropertyContent? // OD2f } -internal struct MapOp { - internal var key: String // MOP2a - internal var data: ObjectData? // MOP2b +internal struct ObjectsMapOp { + internal var key: String // OMO2a + internal var data: ObjectData? // OMO2b } -internal struct MapEntry { - internal var tombstone: Bool? // ME2a - internal var timeserial: String? // ME2b - internal var data: ObjectData // ME2c +internal struct ObjectsMapEntry { + internal var tombstone: Bool? // OME2a + internal var timeserial: String? // OME2b + internal var data: ObjectData // OME2c } -internal struct Map { - internal var semantics: WireEnum // MAP3a - internal var entries: [String: MapEntry]? // MAP3b +internal struct ObjectsMap { + internal var semantics: WireEnum // OMP3a + internal var entries: [String: ObjectsMapEntry]? // OMP3b } internal struct ObjectState { @@ -77,8 +77,8 @@ internal struct ObjectState { internal var siteTimeserials: [String: String] // OST2b internal var tombstone: Bool // OST2c internal var createOp: ObjectOperation? // OST2d - internal var map: Map? // OST2e - internal var counter: WireCounter? // OST2f + internal var map: ObjectsMap? // OST2e + internal var counter: WireObjectsCounter? // OST2f } internal extension InboundObjectMessage { @@ -139,12 +139,12 @@ internal extension ObjectOperation { ) throws(InternalError) { action = wireObjectOperation.action objectId = wireObjectOperation.objectId - mapOp = try wireObjectOperation.mapOp.map { wireMapOp throws(InternalError) in - try .init(wireMapOp: wireMapOp, format: format) + mapOp = try wireObjectOperation.mapOp.map { wireObjectsMapOp throws(InternalError) in + try .init(wireObjectsMapOp: wireObjectsMapOp, format: format) } counterOp = wireObjectOperation.counterOp map = try wireObjectOperation.map.map { wireMap throws(InternalError) in - try .init(wireMap: wireMap, format: format) + try .init(wireObjectsMap: wireMap, format: format) } counter = wireObjectOperation.counter @@ -319,27 +319,27 @@ internal extension ObjectData { } } -internal extension MapOp { - /// Initializes a `MapOp` from a `WireMapOp`, applying the data decoding rules of OD5. +internal extension ObjectsMapOp { + /// Initializes a `ObjectsMapOp` from a `WireObjectsMapOp`, applying the data decoding rules of OD5. /// /// - Parameters: /// - format: The format to use when applying the decoding rules of OD5. /// - Throws: `InternalError` if JSON or Base64 decoding fails. init( - wireMapOp: WireMapOp, + wireObjectsMapOp: WireObjectsMapOp, format: AblyPlugin.EncodingFormat ) throws(InternalError) { - key = wireMapOp.key - data = try wireMapOp.data.map { wireObjectData throws(InternalError) in + key = wireObjectsMapOp.key + data = try wireObjectsMapOp.data.map { wireObjectData throws(InternalError) in try .init(wireObjectData: wireObjectData, format: format) } } - /// Converts this `MapOp` to a `WireMapOp`, applying the data encoding rules of OD4. + /// Converts this `ObjectsMapOp` to a `WireObjectsMapOp`, applying the data encoding rules of OD4. /// /// - Parameters: /// - format: The format to use when applying the encoding rules of OD4. - func toWire(format: AblyPlugin.EncodingFormat) -> WireMapOp { + func toWire(format: AblyPlugin.EncodingFormat) -> WireObjectsMapOp { .init( key: key, data: data?.toWire(format: format), @@ -347,26 +347,26 @@ internal extension MapOp { } } -internal extension MapEntry { - /// Initializes a `MapEntry` from a `WireMapEntry`, applying the data decoding rules of OD5. +internal extension ObjectsMapEntry { + /// Initializes an `ObjectsMapEntry` from a `WireObjectsMapEntry`, applying the data decoding rules of OD5. /// /// - Parameters: /// - format: The format to use when applying the decoding rules of OD5. /// - Throws: `InternalError` if JSON or Base64 decoding fails. init( - wireMapEntry: WireMapEntry, + wireObjectsMapEntry: WireObjectsMapEntry, format: AblyPlugin.EncodingFormat ) throws(InternalError) { - tombstone = wireMapEntry.tombstone - timeserial = wireMapEntry.timeserial - data = try .init(wireObjectData: wireMapEntry.data, format: format) + tombstone = wireObjectsMapEntry.tombstone + timeserial = wireObjectsMapEntry.timeserial + data = try .init(wireObjectData: wireObjectsMapEntry.data, format: format) } - /// Converts this `MapEntry` to a `WireMapEntry`, applying the data encoding rules of OD4. + /// Converts this `ObjectsMapEntry` to a `WireObjectsMapEntry`, applying the data encoding rules of OD4. /// /// - Parameters: /// - format: The format to use when applying the encoding rules of OD4. - func toWire(format: AblyPlugin.EncodingFormat) -> WireMapEntry { + func toWire(format: AblyPlugin.EncodingFormat) -> WireObjectsMapEntry { .init( tombstone: tombstone, timeserial: timeserial, @@ -375,27 +375,27 @@ internal extension MapEntry { } } -internal extension Map { - /// Initializes a `Map` from a `WireMap`, applying the data decoding rules of OD5. +internal extension ObjectsMap { + /// Initializes an `ObjectsMap` from a `WireObjectsMap`, applying the data decoding rules of OD5. /// /// - Parameters: /// - format: The format to use when applying the decoding rules of OD5. /// - Throws: `InternalError` if JSON or Base64 decoding fails. init( - wireMap: WireMap, + wireObjectsMap: WireObjectsMap, format: AblyPlugin.EncodingFormat ) throws(InternalError) { - semantics = wireMap.semantics - entries = try wireMap.entries?.ablyLiveObjects_mapValuesWithTypedThrow { wireMapEntry throws(InternalError) in - try .init(wireMapEntry: wireMapEntry, format: format) + semantics = wireObjectsMap.semantics + entries = try wireObjectsMap.entries?.ablyLiveObjects_mapValuesWithTypedThrow { wireMapEntry throws(InternalError) in + try .init(wireObjectsMapEntry: wireMapEntry, format: format) } } - /// Converts this `Map` to a `WireMap`, applying the data encoding rules of OD4. + /// Converts this `ObjectsMap` to a `WireObjectsMap`, applying the data encoding rules of OD4. /// /// - Parameters: /// - format: The format to use when applying the encoding rules of OD4. - func toWire(format: AblyPlugin.EncodingFormat) -> WireMap { + func toWire(format: AblyPlugin.EncodingFormat) -> WireObjectsMap { .init( semantics: semantics, entries: entries?.mapValues { $0.toWire(format: format) }, @@ -419,8 +419,8 @@ internal extension ObjectState { createOp = try wireObjectState.createOp.map { wireObjectOperation throws(InternalError) in try .init(wireObjectOperation: wireObjectOperation, format: format) } - map = try wireObjectState.map.map { wireMap throws(InternalError) in - try .init(wireMap: wireMap, format: format) + map = try wireObjectState.map.map { wireObjectsMap throws(InternalError) in + try .init(wireObjectsMap: wireObjectsMap, format: format) } counter = wireObjectState.counter } diff --git a/Sources/AblyLiveObjects/Protocol/WireObjectMessage.swift b/Sources/AblyLiveObjects/Protocol/WireObjectMessage.swift index 482c0357..348cc483 100644 --- a/Sources/AblyLiveObjects/Protocol/WireObjectMessage.swift +++ b/Sources/AblyLiveObjects/Protocol/WireObjectMessage.swift @@ -145,18 +145,18 @@ internal enum ObjectOperationAction: Int { case objectDelete = 5 } -// MAP2 -internal enum MapSemantics: Int { +// OMP2 +internal enum ObjectsMapSemantics: Int { case lww = 0 } internal struct WireObjectOperation { internal var action: WireEnum // OOP3a internal var objectId: String // OOP3b - internal var mapOp: WireMapOp? // OOP3c - internal var counterOp: WireCounterOp? // OOP3d - internal var map: WireMap? // OOP3e - internal var counter: WireCounter? // OOP3f + internal var mapOp: WireObjectsMapOp? // OOP3c + internal var counterOp: WireObjectsCounterOp? // OOP3d + internal var map: WireObjectsMap? // OOP3e + internal var counter: WireObjectsCounter? // OOP3f internal var nonce: String? // OOP3g internal var initialValue: StringOrData? // OOP3h internal var initialValueEncoding: String? // OOP3i @@ -228,8 +228,8 @@ internal struct WireObjectState { internal var siteTimeserials: [String: String] // OST2b internal var tombstone: Bool // OST2c internal var createOp: WireObjectOperation? // OST2d - internal var map: WireMap? // OST2e - internal var counter: WireCounter? // OST2f + internal var map: WireObjectsMap? // OST2e + internal var counter: WireObjectsCounter? // OST2f } extension WireObjectState: WireObjectCodable { @@ -277,12 +277,12 @@ extension WireObjectState: WireObjectCodable { } } -internal struct WireMapOp { - internal var key: String // MOP2a - internal var data: WireObjectData? // MOP2b +internal struct WireObjectsMapOp { + internal var key: String // OMO2a + internal var data: WireObjectData? // OMO2b } -extension WireMapOp: WireObjectCodable { +extension WireObjectsMapOp: WireObjectCodable { internal enum WireKey: String { case key case data @@ -306,11 +306,11 @@ extension WireMapOp: WireObjectCodable { } } -internal struct WireCounterOp { - internal var amount: NSNumber // COP2a +internal struct WireObjectsCounterOp { + internal var amount: NSNumber // OCO2a } -extension WireCounterOp: WireObjectCodable { +extension WireObjectsCounterOp: WireObjectCodable { internal enum WireKey: String { case amount } @@ -326,12 +326,12 @@ extension WireCounterOp: WireObjectCodable { } } -internal struct WireMap { - internal var semantics: WireEnum // MAP3a - internal var entries: [String: WireMapEntry]? // MAP3b +internal struct WireObjectsMap { + internal var semantics: WireEnum // OMP3a + internal var entries: [String: WireObjectsMapEntry]? // OMP3b } -extension WireMap: WireObjectCodable { +extension WireObjectsMap: WireObjectCodable { internal enum WireKey: String { case semantics case entries @@ -343,7 +343,7 @@ extension WireMap: WireObjectCodable { guard case let .object(object) = value else { throw WireValueDecodingError.wrongTypeForKey(WireKey.entries.rawValue, actualValue: value).toInternalError() } - return try WireMapEntry(wireObject: object) + return try WireObjectsMapEntry(wireObject: object) } } @@ -360,11 +360,11 @@ extension WireMap: WireObjectCodable { } } -internal struct WireCounter { - internal var count: NSNumber? // CNT2a +internal struct WireObjectsCounter { + internal var count: NSNumber? // OCN2a } -extension WireCounter: WireObjectCodable { +extension WireObjectsCounter: WireObjectCodable { internal enum WireKey: String { case count } @@ -382,13 +382,13 @@ extension WireCounter: WireObjectCodable { } } -internal struct WireMapEntry { - internal var tombstone: Bool? // ME2a - internal var timeserial: String? // ME2b - internal var data: WireObjectData // ME2c +internal struct WireObjectsMapEntry { + internal var tombstone: Bool? // OME2a + internal var timeserial: String? // OME2b + internal var data: WireObjectData // OME2c } -extension WireMapEntry: WireObjectCodable { +extension WireObjectsMapEntry: WireObjectCodable { internal enum WireKey: String { case tombstone case timeserial diff --git a/Sources/AblyLiveObjects/Public/ARTRealtimeChannel+Objects.swift b/Sources/AblyLiveObjects/Public/ARTRealtimeChannel+Objects.swift index 155290e6..2df0f68e 100644 --- a/Sources/AblyLiveObjects/Public/ARTRealtimeChannel+Objects.swift +++ b/Sources/AblyLiveObjects/Public/ARTRealtimeChannel+Objects.swift @@ -2,17 +2,17 @@ import Ably internal import AblyPlugin public extension ARTRealtimeChannel { - /// An ``Objects`` object. - var objects: Objects { + /// A ``RealtimeObjects`` object. + var objects: RealtimeObjects { internallyTypedObjects } - private var internallyTypedObjects: DefaultLiveObjects { + private var internallyTypedObjects: DefaultRealtimeObjects { DefaultInternalPlugin.objectsProperty(for: self, pluginAPI: AblyPlugin.PluginAPI.sharedInstance()) } - /// For tests to access the non-public API of `DefaultLiveObjects`. - internal var testsOnly_internallyTypedObjects: DefaultLiveObjects { + /// For tests to access the non-public API of `DefaultRealtimeObjects`. + internal var testsOnly_internallyTypedObjects: DefaultRealtimeObjects { internallyTypedObjects } } diff --git a/Sources/AblyLiveObjects/Public/PublicTypes.swift b/Sources/AblyLiveObjects/Public/PublicTypes.swift index 74054837..149536b2 100644 --- a/Sources/AblyLiveObjects/Public/PublicTypes.swift +++ b/Sources/AblyLiveObjects/Public/PublicTypes.swift @@ -5,18 +5,18 @@ import Ably /// - Parameter update: The update object describing the changes made to the object. public typealias LiveObjectUpdateCallback = (_ update: T) -> Void -/// The callback used for the events emitted by ``Objects``. +/// The callback used for the events emitted by ``RealtimeObjects``. public typealias ObjectsEventCallback = () -> Void /// The callback used for the lifecycle events emitted by ``LiveObject``. public typealias LiveObjectLifecycleEventCallback = () -> Void -/// A function passed to ``Objects/batch(callback:)`` to group multiple Objects operations into a single channel message. +/// A function passed to ``RealtimeObjects/batch(callback:)`` to group multiple Objects operations into a single channel message. /// /// - Parameter batchContext: A ``BatchContext`` object that allows grouping Objects operations for this batch. public typealias BatchCallback = (_ batchContext: BatchContext) -> Void -/// Describes the events emitted by an ``Objects`` object. +/// Describes the events emitted by an ``RealtimeObjects`` object. public enum ObjectsEvent { /// The local copy of Objects on a channel is currently being synchronized with the Ably service. case syncing @@ -31,7 +31,7 @@ public enum LiveObjectLifecycleEvent { } /// Enables the Objects to be read, modified and subscribed to for a channel. -public protocol Objects { +public protocol RealtimeObjects { /// Retrieves the root ``LiveMap`` object for Objects on a channel. func getRoot() async throws(ARTErrorInfo) -> any LiveMap @@ -91,7 +91,7 @@ public protocol OnObjectsEventResponse { /// Enables grouping multiple Objects operations together by providing `BatchContext*` wrapper objects. public protocol BatchContext { - /// Mirrors the ``Objects/getRoot()`` method and returns a ``BatchContextLiveMap`` wrapper for the root object on a channel. + /// Mirrors the ``RealtimeObjects/getRoot()`` method and returns a ``BatchContextLiveMap`` wrapper for the root object on a channel. /// /// - Returns: A ``BatchContextLiveMap`` object. func getRoot() -> BatchContextLiveMap diff --git a/Tests/AblyLiveObjectsTests/AblyLiveObjectsTests.swift b/Tests/AblyLiveObjectsTests/AblyLiveObjectsTests.swift index c999a22d..6b89d54b 100644 --- a/Tests/AblyLiveObjectsTests/AblyLiveObjectsTests.swift +++ b/Tests/AblyLiveObjectsTests/AblyLiveObjectsTests.swift @@ -20,7 +20,7 @@ struct AblyLiveObjectsTests { // Then // Check that the `channel.objects` property works and gives the internal type we expect - #expect(channel.objects is DefaultLiveObjects) + #expect(channel.objects is DefaultRealtimeObjects) } /// A basic test of the core interactions between this plugin and ably-cocoa. diff --git a/Tests/AblyLiveObjectsTests/WireObjectMessageTests.swift b/Tests/AblyLiveObjectsTests/WireObjectMessageTests.swift index bf208168..4b77924b 100644 --- a/Tests/AblyLiveObjectsTests/WireObjectMessageTests.swift +++ b/Tests/AblyLiveObjectsTests/WireObjectMessageTests.swift @@ -227,13 +227,13 @@ enum WireObjectMessageTests { let op = WireObjectOperation( action: .known(.mapCreate), objectId: "obj1", - mapOp: WireMapOp(key: "key1", data: WireObjectData(string: "value1")), - counterOp: WireCounterOp(amount: 42), - map: WireMap( + mapOp: WireObjectsMapOp(key: "key1", data: WireObjectData(string: "value1")), + counterOp: WireObjectsCounterOp(amount: 42), + map: WireObjectsMap( semantics: .known(.lww), - entries: ["key1": WireMapEntry(tombstone: false, timeserial: nil, data: WireObjectData(string: "value1"))], + entries: ["key1": WireObjectsMapEntry(tombstone: false, timeserial: nil, data: WireObjectData(string: "value1"))], ), - counter: WireCounter(count: 42), + counter: WireObjectsCounter(count: 42), nonce: "nonce1", initialValue: nil, initialValueEncoding: "utf8", @@ -328,11 +328,11 @@ enum WireObjectMessageTests { initialValue: nil, initialValueEncoding: nil, ), - map: WireMap( + map: WireObjectsMap( semantics: .known(.lww), - entries: ["key1": WireMapEntry(tombstone: false, timeserial: nil, data: WireObjectData(string: "value1"))], + entries: ["key1": WireObjectsMapEntry(tombstone: false, timeserial: nil, data: WireObjectData(string: "value1"))], ), - counter: WireCounter(count: 42), + counter: WireObjectsCounter(count: 42), ) let wire = state.toWireObject #expect(wire == [ @@ -436,7 +436,7 @@ enum WireObjectMessageTests { "key": "key1", "data": ["string": "value1"], ] - let op = try WireMapOp(wireObject: json) + let op = try WireObjectsMapOp(wireObject: json) #expect(op.key == "key1") #expect(op.data?.string == "value1") } @@ -444,14 +444,14 @@ enum WireObjectMessageTests { @Test func decodesWithOptionalFieldsAbsent() throws { let json: [String: WireValue] = ["key": "key1"] - let op = try WireMapOp(wireObject: json) + let op = try WireObjectsMapOp(wireObject: json) #expect(op.key == "key1") #expect(op.data == nil) } @Test func encodesAllFields() { - let op = WireMapOp( + let op = WireObjectsMapOp( key: "key1", data: WireObjectData(string: "value1"), ) @@ -464,7 +464,7 @@ enum WireObjectMessageTests { @Test func encodesWithOptionalFieldsNil() { - let op = WireMapOp( + let op = WireObjectsMapOp( key: "key1", data: nil, ) @@ -479,13 +479,13 @@ enum WireObjectMessageTests { @Test func decodesAllFields() throws { let json: [String: WireValue] = ["amount": 42] - let op = try WireCounterOp(wireObject: json) + let op = try WireObjectsCounterOp(wireObject: json) #expect(op.amount == 42) } @Test func encodesAllFields() { - let op = WireCounterOp(amount: 42) + let op = WireObjectsCounterOp(amount: 42) let wire = op.toWireObject #expect(wire == ["amount": 42]) } @@ -501,7 +501,7 @@ enum WireObjectMessageTests { "key2": ["data": ["string": "value2"], "tombstone": true], ], ] - let map = try WireMap(wireObject: json) + let map = try WireObjectsMap(wireObject: json) #expect(map.semantics == .known(.lww)) #expect(map.entries?["key1"]?.data.string == "value1") #expect(map.entries?["key1"]?.tombstone == false) @@ -514,7 +514,7 @@ enum WireObjectMessageTests { @Test func decodesWithOptionalFieldsAbsent() throws { let json: [String: WireValue] = ["semantics": 0] - let map = try WireMap(wireObject: json) + let map = try WireObjectsMap(wireObject: json) #expect(map.semantics == .known(.lww)) #expect(map.entries == nil) } @@ -524,17 +524,17 @@ enum WireObjectMessageTests { let json: [String: WireValue] = [ "semantics": 999, // Unknown MapSemantics ] - let map = try WireMap(wireObject: json) + let map = try WireObjectsMap(wireObject: json) #expect(map.semantics == .unknown(999)) } @Test func encodesAllFields() { - let map = WireMap( + let map = WireObjectsMap( semantics: .known(.lww), entries: [ - "key1": WireMapEntry(tombstone: false, timeserial: "ts1", data: WireObjectData(string: "value1")), - "key2": WireMapEntry(tombstone: true, timeserial: nil, data: WireObjectData(string: "value2")), + "key1": WireObjectsMapEntry(tombstone: false, timeserial: "ts1", data: WireObjectData(string: "value1")), + "key2": WireObjectsMapEntry(tombstone: true, timeserial: nil, data: WireObjectData(string: "value2")), ], ) let wire = map.toWireObject @@ -549,7 +549,7 @@ enum WireObjectMessageTests { @Test func encodesWithOptionalFieldsNil() { - let map = WireMap( + let map = WireObjectsMap( semantics: .known(.lww), entries: nil, ) @@ -564,27 +564,27 @@ enum WireObjectMessageTests { @Test func decodesAllFields() throws { let json: [String: WireValue] = ["count": 42] - let counter = try WireCounter(wireObject: json) + let counter = try WireObjectsCounter(wireObject: json) #expect(counter.count == 42) } @Test func decodesWithOptionalFieldsAbsent() throws { let json: [String: WireValue] = [:] - let counter = try WireCounter(wireObject: json) + let counter = try WireObjectsCounter(wireObject: json) #expect(counter.count == nil) } @Test func encodesAllFields() { - let counter = WireCounter(count: 42) + let counter = WireObjectsCounter(count: 42) let wire = counter.toWireObject #expect(wire == ["count": 42]) } @Test func encodesWithOptionalFieldsNil() { - let counter = WireCounter(count: nil) + let counter = WireObjectsCounter(count: nil) let wire = counter.toWireObject #expect(wire.isEmpty) } @@ -598,7 +598,7 @@ enum WireObjectMessageTests { "tombstone": true, "timeserial": "ts1", ] - let entry = try WireMapEntry(wireObject: json) + let entry = try WireObjectsMapEntry(wireObject: json) #expect(entry.data.string == "value1") #expect(entry.tombstone == true) #expect(entry.timeserial == "ts1") @@ -607,7 +607,7 @@ enum WireObjectMessageTests { @Test func decodesWithOptionalFieldsAbsent() throws { let json: [String: WireValue] = ["data": ["string": "value1"]] - let entry = try WireMapEntry(wireObject: json) + let entry = try WireObjectsMapEntry(wireObject: json) #expect(entry.data.string == "value1") #expect(entry.tombstone == nil) #expect(entry.timeserial == nil) @@ -615,7 +615,7 @@ enum WireObjectMessageTests { @Test func encodesAllFields() { - let entry = WireMapEntry( + let entry = WireObjectsMapEntry( tombstone: true, timeserial: "ts1", data: WireObjectData(string: "value1"), @@ -630,7 +630,7 @@ enum WireObjectMessageTests { @Test func encodesWithOptionalFieldsNil() { - let entry = WireMapEntry( + let entry = WireObjectsMapEntry( tombstone: nil, timeserial: nil, data: WireObjectData(string: "value1"),