Skip to content

Commit fc8ee48

Browse files
Update ObjectsHelper REST operations to v6 format
Update the integration test helper to use the new v6 named operation keys (mapCreate, mapSet, mapRemove, counterCreate, counterInc) instead of the old "operation" + "data" format, matching the ably-js test helper. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 4f19312 commit fc8ee48

File tree

1 file changed

+20
-13
lines changed

1 file changed

+20
-13
lines changed

Tests/AblyLiveObjectsTests/JS Integration Tests/ObjectsHelper.swift

Lines changed: 20 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -406,14 +406,22 @@ final class ObjectsHelper: Sendable {
406406

407407
/// Creates a map create REST operation
408408
func mapCreateRestOp(objectId: String? = nil, nonce: String? = nil, data: [String: JSONValue]? = nil) -> [String: JSONValue] {
409-
var opBody: [String: JSONValue] = [
410-
"operation": .string(Actions.mapCreate.stringValue),
409+
var mapCreate: [String: JSONValue] = [
410+
"semantics": .number(0),
411411
]
412412

413413
if let data {
414-
opBody["data"] = .object(data)
414+
// Wrap each entry value in { "data": value } to match v6 format
415+
let entries = Dictionary(uniqueKeysWithValues: data.map { key, value in
416+
(key, JSONValue.object(["data": value]))
417+
})
418+
mapCreate["entries"] = .object(entries)
415419
}
416420

421+
var opBody: [String: JSONValue] = [
422+
"mapCreate": .object(mapCreate),
423+
]
424+
417425
if let objectId {
418426
opBody["objectId"] = .string(objectId)
419427
opBody["nonce"] = .string(nonce ?? "")
@@ -425,9 +433,8 @@ final class ObjectsHelper: Sendable {
425433
/// Creates a map set REST operation
426434
func mapSetRestOp(objectId: String, key: String, value: [String: JSONValue]) -> [String: JSONValue] {
427435
[
428-
"operation": .string(Actions.mapSet.stringValue),
429436
"objectId": .string(objectId),
430-
"data": .object([
437+
"mapSet": .object([
431438
"key": .string(key),
432439
"value": .object(value),
433440
]),
@@ -437,24 +444,25 @@ final class ObjectsHelper: Sendable {
437444
/// Creates a map remove REST operation
438445
func mapRemoveRestOp(objectId: String, key: String) -> [String: JSONValue] {
439446
[
440-
"operation": .string(Actions.mapRemove.stringValue),
441447
"objectId": .string(objectId),
442-
"data": .object([
448+
"mapRemove": .object([
443449
"key": .string(key),
444450
]),
445451
]
446452
}
447453

448454
/// Creates a counter create REST operation
449455
func counterCreateRestOp(objectId: String? = nil, nonce: String? = nil, number: Double? = nil) -> [String: JSONValue] {
450-
var opBody: [String: JSONValue] = [
451-
"operation": .string(Actions.counterCreate.stringValue),
452-
]
456+
var counterCreate: [String: JSONValue] = [:]
453457

454458
if let number {
455-
opBody["data"] = .object(["number": .number(number)])
459+
counterCreate["count"] = .number(number)
456460
}
457461

462+
var opBody: [String: JSONValue] = [
463+
"counterCreate": .object(counterCreate),
464+
]
465+
458466
if let objectId {
459467
opBody["objectId"] = .string(objectId)
460468
opBody["nonce"] = .string(nonce ?? "")
@@ -466,9 +474,8 @@ final class ObjectsHelper: Sendable {
466474
/// Creates a counter increment REST operation
467475
func counterIncRestOp(objectId: String, number: Double) -> [String: JSONValue] {
468476
[
469-
"operation": .string(Actions.counterInc.stringValue),
470477
"objectId": .string(objectId),
471-
"data": .object(["number": .number(number)]),
478+
"counterInc": .object(["number": .number(number)]),
472479
]
473480
}
474481

0 commit comments

Comments
 (0)