From cf49c7f11d59b289291bb6086f4e1447f4ba4712 Mon Sep 17 00:00:00 2001 From: Le Roux Bodenstein Date: Wed, 28 Aug 2024 12:07:25 +0100 Subject: [PATCH] fix(compass-crud): in the bulk update preview, convert array indexes from strings to numbers COMPASS-8218 (#6161) * convert array indexes from strings to numbers * the indexes after the removed one don't need adjusting --- .../change-view/unified-document.ts | 11 +- .../test/before-after-fixtures.ts | 31 + .../all_types_all_types_changed.json | 4 +- .../array_changes_add_array_to_array.json | 6 +- .../array_changes_add_object_to_array.json | 6 +- ...ray_changes_add_simple_value_to_array.json | 4 +- ...hanges_remove_simple_value_from_array.json | 2 +- .../array_changes_simple_array.json | 16 +- ...nges_nested_object_array_array_simple.json | 6 +- ...ct_changes_nested_object_array_simple.json | 4 +- ...ys_add_number_next_to_object_in_array.json | 4 +- .../objects_in_arrays_many_items.json | 1035 +++++++++++++++++ ...in_arrays_object_inside_array_changed.json | 6 +- ...rrays_object_value_nested_in_an_array.json | 6 +- ...remove_number_next_to_object_in_array.json | 2 +- 15 files changed, 1101 insertions(+), 42 deletions(-) create mode 100644 packages/compass-crud/test/fixture-results/objects_in_arrays_many_items.json diff --git a/packages/compass-crud/src/components/change-view/unified-document.ts b/packages/compass-crud/src/components/change-view/unified-document.ts index 3f333139b28..fbef33f0e41 100644 --- a/packages/compass-crud/src/components/change-view/unified-document.ts +++ b/packages/compass-crud/src/components/change-view/unified-document.ts @@ -391,7 +391,7 @@ function itemsWithChanges({ assert(delta._t === 'a', 'delta._t is not a'); const toRemove = Object.keys(delta) .filter((key) => key.startsWith('_') && key !== '_t') - .map((key) => key.slice(1) as unknown as number); + .map((key) => parseInt(key.slice(1), 10)); // Removed indexes refer to the original (left) which is why we remove in a // separate pass before updating/adding @@ -404,13 +404,6 @@ function itemsWithChanges({ } else { assert(false, `item with index "${index}" does not exist`); } - - // adjust the indexes of all items after this one - for (const item of items) { - if (item.index > index) { - item.index = item.index - 1; - } - } } for (const [_index, change] of Object.entries(delta)) { @@ -421,7 +414,7 @@ function itemsWithChanges({ // Non-removed indexes refer to the final (right) array which is why we // update/add in a separate pass after removing - const index = _index as unknown as number; + const index = parseInt(_index, 10); assert(Array.isArray(change), 'unexpected non-array'); assert(change.length !== 3, 'array moves are not supported'); assert(change.length !== 2, 'array changes are not supported'); // always add and remove diff --git a/packages/compass-crud/test/before-after-fixtures.ts b/packages/compass-crud/test/before-after-fixtures.ts index c47803db96c..dbbb63f0b0a 100644 --- a/packages/compass-crud/test/before-after-fixtures.ts +++ b/packages/compass-crud/test/before-after-fixtures.ts @@ -412,6 +412,37 @@ export const fixtureGroups: FixtureGroup[] = [ before: { foo: [0, { bar: 'baz' }] }, after: { foo: [0, { bar: 'bazz' }] }, }, + { + name: 'many items', + before: { + foo: [ + { i: 0 }, + { i: 1 }, + { i: 2 }, + { i: 3 }, + { i: 4 }, + { i: 5 }, + { i: 6 }, + { i: 7 }, + { i: 8 }, + { i: 9 }, + ], + }, + after: { + foo: [ + { i: 0, newField: 1 }, + { i: 1, newField: 1 }, + { i: 2, newField: 1 }, + { i: 3, newField: 1 }, + { i: 4, newField: 1 }, + { i: 5, newField: 1 }, + { i: 6, newField: 1 }, + { i: 7, newField: 1 }, + { i: 8, newField: 1 }, + { i: 9, newField: 1 }, + ], + }, + }, ], }, { diff --git a/packages/compass-crud/test/fixture-results/all_types_all_types_changed.json b/packages/compass-crud/test/fixture-results/all_types_all_types_changed.json index bfa6fe0aec2..7eb18fc466f 100644 --- a/packages/compass-crud/test/fixture-results/all_types_all_types_changed.json +++ b/packages/compass-crud/test/fixture-results/all_types_all_types_changed.json @@ -324,9 +324,9 @@ { "implicitChangeType": "unchanged", "changeType": "added", - "index": "3", + "index": 3, "right": { - "path": ["array", "3"], + "path": ["array", 3], "value": 4 }, "delta": null diff --git a/packages/compass-crud/test/fixture-results/array_changes_add_array_to_array.json b/packages/compass-crud/test/fixture-results/array_changes_add_array_to_array.json index b9b78d307e7..ea65c83944a 100644 --- a/packages/compass-crud/test/fixture-results/array_changes_add_array_to_array.json +++ b/packages/compass-crud/test/fixture-results/array_changes_add_array_to_array.json @@ -70,9 +70,9 @@ { "implicitChangeType": "unchanged", "changeType": "added", - "index": "1", + "index": 1, "right": { - "path": ["foo", "1"], + "path": ["foo", 1], "value": [2] }, "delta": null, @@ -83,7 +83,7 @@ "delta": null, "changeType": "added", "right": { - "path": ["foo", "1", 0], + "path": ["foo", 1, 0], "value": 2 } } diff --git a/packages/compass-crud/test/fixture-results/array_changes_add_object_to_array.json b/packages/compass-crud/test/fixture-results/array_changes_add_object_to_array.json index b766a02d6f6..9f7ad7c33a0 100644 --- a/packages/compass-crud/test/fixture-results/array_changes_add_object_to_array.json +++ b/packages/compass-crud/test/fixture-results/array_changes_add_object_to_array.json @@ -104,9 +104,9 @@ { "implicitChangeType": "unchanged", "changeType": "added", - "index": "1", + "index": 1, "right": { - "path": ["foo", "1"], + "path": ["foo", 1], "value": { "bar": "baz" } @@ -119,7 +119,7 @@ "delta": null, "changeType": "added", "right": { - "path": ["foo", "1", "bar"], + "path": ["foo", 1, "bar"], "value": "baz" } } diff --git a/packages/compass-crud/test/fixture-results/array_changes_add_simple_value_to_array.json b/packages/compass-crud/test/fixture-results/array_changes_add_simple_value_to_array.json index e740fb6603e..6024dd1577d 100644 --- a/packages/compass-crud/test/fixture-results/array_changes_add_simple_value_to_array.json +++ b/packages/compass-crud/test/fixture-results/array_changes_add_simple_value_to_array.json @@ -82,9 +82,9 @@ { "implicitChangeType": "unchanged", "changeType": "added", - "index": "3", + "index": 3, "right": { - "path": ["foo", "3"], + "path": ["foo", 3], "value": 4 }, "delta": null diff --git a/packages/compass-crud/test/fixture-results/array_changes_remove_simple_value_from_array.json b/packages/compass-crud/test/fixture-results/array_changes_remove_simple_value_from_array.json index 41504f74047..cfc162cd23e 100644 --- a/packages/compass-crud/test/fixture-results/array_changes_remove_simple_value_from_array.json +++ b/packages/compass-crud/test/fixture-results/array_changes_remove_simple_value_from_array.json @@ -63,7 +63,7 @@ }, { "implicitChangeType": "unchanged", - "index": 1, + "index": 2, "delta": null, "changeType": "unchanged", "left": { diff --git a/packages/compass-crud/test/fixture-results/array_changes_simple_array.json b/packages/compass-crud/test/fixture-results/array_changes_simple_array.json index 39fc7e02154..ed2fe90d123 100644 --- a/packages/compass-crud/test/fixture-results/array_changes_simple_array.json +++ b/packages/compass-crud/test/fixture-results/array_changes_simple_array.json @@ -50,9 +50,9 @@ { "implicitChangeType": "unchanged", "changeType": "added", - "index": "0", + "index": 0, "right": { - "path": ["foo", "0"], + "path": ["foo", 0], "value": "a" }, "delta": null @@ -60,9 +60,9 @@ { "implicitChangeType": "unchanged", "changeType": "added", - "index": "1", + "index": 1, "right": { - "path": ["foo", "1"], + "path": ["foo", 1], "value": "b" }, "delta": null @@ -70,9 +70,9 @@ { "implicitChangeType": "unchanged", "changeType": "added", - "index": "2", + "index": 2, "right": { - "path": ["foo", "2"], + "path": ["foo", 2], "value": "c" }, "delta": null @@ -89,7 +89,7 @@ }, { "implicitChangeType": "unchanged", - "index": 0, + "index": 1, "delta": null, "changeType": "removed", "left": { @@ -99,7 +99,7 @@ }, { "implicitChangeType": "unchanged", - "index": 1, + "index": 2, "delta": null, "changeType": "removed", "left": { diff --git a/packages/compass-crud/test/fixture-results/nested_object_changes_nested_object_array_array_simple.json b/packages/compass-crud/test/fixture-results/nested_object_changes_nested_object_array_array_simple.json index 13bfabcab35..4ef4bbcd2bd 100644 --- a/packages/compass-crud/test/fixture-results/nested_object_changes_nested_object_array_array_simple.json +++ b/packages/compass-crud/test/fixture-results/nested_object_changes_nested_object_array_array_simple.json @@ -72,9 +72,9 @@ { "implicitChangeType": "unchanged", "changeType": "added", - "index": "0", + "index": 0, "right": { - "path": ["foo", "bar", "0"], + "path": ["foo", "bar", 0], "value": ["a"] }, "delta": null, @@ -85,7 +85,7 @@ "delta": null, "changeType": "added", "right": { - "path": ["foo", "bar", "0", 0], + "path": ["foo", "bar", 0, 0], "value": "a" } } diff --git a/packages/compass-crud/test/fixture-results/nested_object_changes_nested_object_array_simple.json b/packages/compass-crud/test/fixture-results/nested_object_changes_nested_object_array_simple.json index d9b7c23173f..b5ca7829b92 100644 --- a/packages/compass-crud/test/fixture-results/nested_object_changes_nested_object_array_simple.json +++ b/packages/compass-crud/test/fixture-results/nested_object_changes_nested_object_array_simple.json @@ -72,9 +72,9 @@ { "implicitChangeType": "unchanged", "changeType": "added", - "index": "0", + "index": 0, "right": { - "path": ["foo", "bar", "0"], + "path": ["foo", "bar", 0], "value": "a" }, "delta": null diff --git a/packages/compass-crud/test/fixture-results/objects_in_arrays_add_number_next_to_object_in_array.json b/packages/compass-crud/test/fixture-results/objects_in_arrays_add_number_next_to_object_in_array.json index 7802ebfc674..7fd27256a86 100644 --- a/packages/compass-crud/test/fixture-results/objects_in_arrays_add_number_next_to_object_in_array.json +++ b/packages/compass-crud/test/fixture-results/objects_in_arrays_add_number_next_to_object_in_array.json @@ -58,9 +58,9 @@ { "implicitChangeType": "unchanged", "changeType": "added", - "index": "0", + "index": 0, "right": { - "path": ["foo", "0"], + "path": ["foo", 0], "value": 0 }, "delta": null diff --git a/packages/compass-crud/test/fixture-results/objects_in_arrays_many_items.json b/packages/compass-crud/test/fixture-results/objects_in_arrays_many_items.json new file mode 100644 index 00000000000..381c0404d15 --- /dev/null +++ b/packages/compass-crud/test/fixture-results/objects_in_arrays_many_items.json @@ -0,0 +1,1035 @@ +{ + "left": { + "path": [], + "value": { + "foo": [ + { + "i": 0 + }, + { + "i": 1 + }, + { + "i": 2 + }, + { + "i": 3 + }, + { + "i": 4 + }, + { + "i": 5 + }, + { + "i": 6 + }, + { + "i": 7 + }, + { + "i": 8 + }, + { + "i": 9 + } + ] + } + }, + "right": { + "path": [], + "value": { + "foo": [ + { + "i": 0, + "newField": 1 + }, + { + "i": 1, + "newField": 1 + }, + { + "i": 2, + "newField": 1 + }, + { + "i": 3, + "newField": 1 + }, + { + "i": 4, + "newField": 1 + }, + { + "i": 5, + "newField": 1 + }, + { + "i": 6, + "newField": 1 + }, + { + "i": 7, + "newField": 1 + }, + { + "i": 8, + "newField": 1 + }, + { + "i": 9, + "newField": 1 + } + ] + } + }, + "delta": { + "foo": { + "0": [ + { + "i": 0, + "newField": 1 + } + ], + "1": [ + { + "i": 1, + "newField": 1 + } + ], + "2": [ + { + "i": 2, + "newField": 1 + } + ], + "3": [ + { + "i": 3, + "newField": 1 + } + ], + "4": [ + { + "i": 4, + "newField": 1 + } + ], + "5": [ + { + "i": 5, + "newField": 1 + } + ], + "6": [ + { + "i": 6, + "newField": 1 + } + ], + "7": [ + { + "i": 7, + "newField": 1 + } + ], + "8": [ + { + "i": 8, + "newField": 1 + } + ], + "9": [ + { + "i": 9, + "newField": 1 + } + ], + "_t": "a", + "_0": [ + { + "i": 0 + }, + 0, + 0 + ], + "_1": [ + { + "i": 1 + }, + 0, + 0 + ], + "_2": [ + { + "i": 2 + }, + 0, + 0 + ], + "_3": [ + { + "i": 3 + }, + 0, + 0 + ], + "_4": [ + { + "i": 4 + }, + 0, + 0 + ], + "_5": [ + { + "i": 5 + }, + 0, + 0 + ], + "_6": [ + { + "i": 6 + }, + 0, + 0 + ], + "_7": [ + { + "i": 7 + }, + 0, + 0 + ], + "_8": [ + { + "i": 8 + }, + 0, + 0 + ], + "_9": [ + { + "i": 9 + }, + 0, + 0 + ] + } + }, + "implicitChangeType": "unchanged", + "changeType": "unchanged", + "properties": [ + { + "implicitChangeType": "unchanged", + "objectKey": "foo", + "delta": { + "0": [ + { + "i": 0, + "newField": 1 + } + ], + "1": [ + { + "i": 1, + "newField": 1 + } + ], + "2": [ + { + "i": 2, + "newField": 1 + } + ], + "3": [ + { + "i": 3, + "newField": 1 + } + ], + "4": [ + { + "i": 4, + "newField": 1 + } + ], + "5": [ + { + "i": 5, + "newField": 1 + } + ], + "6": [ + { + "i": 6, + "newField": 1 + } + ], + "7": [ + { + "i": 7, + "newField": 1 + } + ], + "8": [ + { + "i": 8, + "newField": 1 + } + ], + "9": [ + { + "i": 9, + "newField": 1 + } + ], + "_t": "a", + "_0": [ + { + "i": 0 + }, + 0, + 0 + ], + "_1": [ + { + "i": 1 + }, + 0, + 0 + ], + "_2": [ + { + "i": 2 + }, + 0, + 0 + ], + "_3": [ + { + "i": 3 + }, + 0, + 0 + ], + "_4": [ + { + "i": 4 + }, + 0, + 0 + ], + "_5": [ + { + "i": 5 + }, + 0, + 0 + ], + "_6": [ + { + "i": 6 + }, + 0, + 0 + ], + "_7": [ + { + "i": 7 + }, + 0, + 0 + ], + "_8": [ + { + "i": 8 + }, + 0, + 0 + ], + "_9": [ + { + "i": 9 + }, + 0, + 0 + ] + }, + "changeType": "unchanged", + "left": { + "path": ["foo"], + "value": [ + { + "i": 0 + }, + { + "i": 1 + }, + { + "i": 2 + }, + { + "i": 3 + }, + { + "i": 4 + }, + { + "i": 5 + }, + { + "i": 6 + }, + { + "i": 7 + }, + { + "i": 8 + }, + { + "i": 9 + } + ] + }, + "right": { + "path": ["foo"], + "value": [ + { + "i": 0, + "newField": 1 + }, + { + "i": 1, + "newField": 1 + }, + { + "i": 2, + "newField": 1 + }, + { + "i": 3, + "newField": 1 + }, + { + "i": 4, + "newField": 1 + }, + { + "i": 5, + "newField": 1 + }, + { + "i": 6, + "newField": 1 + }, + { + "i": 7, + "newField": 1 + }, + { + "i": 8, + "newField": 1 + }, + { + "i": 9, + "newField": 1 + } + ] + }, + "items": [ + { + "implicitChangeType": "unchanged", + "changeType": "added", + "index": 0, + "right": { + "path": ["foo", 0], + "value": { + "i": 0, + "newField": 1 + } + }, + "delta": null, + "properties": [ + { + "implicitChangeType": "added", + "objectKey": "i", + "delta": null, + "changeType": "added", + "right": { + "path": ["foo", 0, "i"], + "value": 0 + } + }, + { + "implicitChangeType": "added", + "objectKey": "newField", + "delta": null, + "changeType": "added", + "right": { + "path": ["foo", 0, "newField"], + "value": 1 + } + } + ] + }, + { + "implicitChangeType": "unchanged", + "changeType": "added", + "index": 1, + "right": { + "path": ["foo", 1], + "value": { + "i": 1, + "newField": 1 + } + }, + "delta": null, + "properties": [ + { + "implicitChangeType": "added", + "objectKey": "i", + "delta": null, + "changeType": "added", + "right": { + "path": ["foo", 1, "i"], + "value": 1 + } + }, + { + "implicitChangeType": "added", + "objectKey": "newField", + "delta": null, + "changeType": "added", + "right": { + "path": ["foo", 1, "newField"], + "value": 1 + } + } + ] + }, + { + "implicitChangeType": "unchanged", + "changeType": "added", + "index": 2, + "right": { + "path": ["foo", 2], + "value": { + "i": 2, + "newField": 1 + } + }, + "delta": null, + "properties": [ + { + "implicitChangeType": "added", + "objectKey": "i", + "delta": null, + "changeType": "added", + "right": { + "path": ["foo", 2, "i"], + "value": 2 + } + }, + { + "implicitChangeType": "added", + "objectKey": "newField", + "delta": null, + "changeType": "added", + "right": { + "path": ["foo", 2, "newField"], + "value": 1 + } + } + ] + }, + { + "implicitChangeType": "unchanged", + "changeType": "added", + "index": 3, + "right": { + "path": ["foo", 3], + "value": { + "i": 3, + "newField": 1 + } + }, + "delta": null, + "properties": [ + { + "implicitChangeType": "added", + "objectKey": "i", + "delta": null, + "changeType": "added", + "right": { + "path": ["foo", 3, "i"], + "value": 3 + } + }, + { + "implicitChangeType": "added", + "objectKey": "newField", + "delta": null, + "changeType": "added", + "right": { + "path": ["foo", 3, "newField"], + "value": 1 + } + } + ] + }, + { + "implicitChangeType": "unchanged", + "changeType": "added", + "index": 4, + "right": { + "path": ["foo", 4], + "value": { + "i": 4, + "newField": 1 + } + }, + "delta": null, + "properties": [ + { + "implicitChangeType": "added", + "objectKey": "i", + "delta": null, + "changeType": "added", + "right": { + "path": ["foo", 4, "i"], + "value": 4 + } + }, + { + "implicitChangeType": "added", + "objectKey": "newField", + "delta": null, + "changeType": "added", + "right": { + "path": ["foo", 4, "newField"], + "value": 1 + } + } + ] + }, + { + "implicitChangeType": "unchanged", + "changeType": "added", + "index": 5, + "right": { + "path": ["foo", 5], + "value": { + "i": 5, + "newField": 1 + } + }, + "delta": null, + "properties": [ + { + "implicitChangeType": "added", + "objectKey": "i", + "delta": null, + "changeType": "added", + "right": { + "path": ["foo", 5, "i"], + "value": 5 + } + }, + { + "implicitChangeType": "added", + "objectKey": "newField", + "delta": null, + "changeType": "added", + "right": { + "path": ["foo", 5, "newField"], + "value": 1 + } + } + ] + }, + { + "implicitChangeType": "unchanged", + "changeType": "added", + "index": 6, + "right": { + "path": ["foo", 6], + "value": { + "i": 6, + "newField": 1 + } + }, + "delta": null, + "properties": [ + { + "implicitChangeType": "added", + "objectKey": "i", + "delta": null, + "changeType": "added", + "right": { + "path": ["foo", 6, "i"], + "value": 6 + } + }, + { + "implicitChangeType": "added", + "objectKey": "newField", + "delta": null, + "changeType": "added", + "right": { + "path": ["foo", 6, "newField"], + "value": 1 + } + } + ] + }, + { + "implicitChangeType": "unchanged", + "changeType": "added", + "index": 7, + "right": { + "path": ["foo", 7], + "value": { + "i": 7, + "newField": 1 + } + }, + "delta": null, + "properties": [ + { + "implicitChangeType": "added", + "objectKey": "i", + "delta": null, + "changeType": "added", + "right": { + "path": ["foo", 7, "i"], + "value": 7 + } + }, + { + "implicitChangeType": "added", + "objectKey": "newField", + "delta": null, + "changeType": "added", + "right": { + "path": ["foo", 7, "newField"], + "value": 1 + } + } + ] + }, + { + "implicitChangeType": "unchanged", + "changeType": "added", + "index": 8, + "right": { + "path": ["foo", 8], + "value": { + "i": 8, + "newField": 1 + } + }, + "delta": null, + "properties": [ + { + "implicitChangeType": "added", + "objectKey": "i", + "delta": null, + "changeType": "added", + "right": { + "path": ["foo", 8, "i"], + "value": 8 + } + }, + { + "implicitChangeType": "added", + "objectKey": "newField", + "delta": null, + "changeType": "added", + "right": { + "path": ["foo", 8, "newField"], + "value": 1 + } + } + ] + }, + { + "implicitChangeType": "unchanged", + "changeType": "added", + "index": 9, + "right": { + "path": ["foo", 9], + "value": { + "i": 9, + "newField": 1 + } + }, + "delta": null, + "properties": [ + { + "implicitChangeType": "added", + "objectKey": "i", + "delta": null, + "changeType": "added", + "right": { + "path": ["foo", 9, "i"], + "value": 9 + } + }, + { + "implicitChangeType": "added", + "objectKey": "newField", + "delta": null, + "changeType": "added", + "right": { + "path": ["foo", 9, "newField"], + "value": 1 + } + } + ] + }, + { + "implicitChangeType": "unchanged", + "index": 0, + "delta": null, + "changeType": "removed", + "left": { + "path": ["foo", 0], + "value": { + "i": 0 + } + }, + "properties": [ + { + "implicitChangeType": "removed", + "objectKey": "i", + "delta": null, + "changeType": "removed", + "left": { + "path": ["foo", 0, "i"], + "value": 0 + } + } + ] + }, + { + "implicitChangeType": "unchanged", + "index": 1, + "delta": null, + "changeType": "removed", + "left": { + "path": ["foo", 1], + "value": { + "i": 1 + } + }, + "properties": [ + { + "implicitChangeType": "removed", + "objectKey": "i", + "delta": null, + "changeType": "removed", + "left": { + "path": ["foo", 1, "i"], + "value": 1 + } + } + ] + }, + { + "implicitChangeType": "unchanged", + "index": 2, + "delta": null, + "changeType": "removed", + "left": { + "path": ["foo", 2], + "value": { + "i": 2 + } + }, + "properties": [ + { + "implicitChangeType": "removed", + "objectKey": "i", + "delta": null, + "changeType": "removed", + "left": { + "path": ["foo", 2, "i"], + "value": 2 + } + } + ] + }, + { + "implicitChangeType": "unchanged", + "index": 3, + "delta": null, + "changeType": "removed", + "left": { + "path": ["foo", 3], + "value": { + "i": 3 + } + }, + "properties": [ + { + "implicitChangeType": "removed", + "objectKey": "i", + "delta": null, + "changeType": "removed", + "left": { + "path": ["foo", 3, "i"], + "value": 3 + } + } + ] + }, + { + "implicitChangeType": "unchanged", + "index": 4, + "delta": null, + "changeType": "removed", + "left": { + "path": ["foo", 4], + "value": { + "i": 4 + } + }, + "properties": [ + { + "implicitChangeType": "removed", + "objectKey": "i", + "delta": null, + "changeType": "removed", + "left": { + "path": ["foo", 4, "i"], + "value": 4 + } + } + ] + }, + { + "implicitChangeType": "unchanged", + "index": 5, + "delta": null, + "changeType": "removed", + "left": { + "path": ["foo", 5], + "value": { + "i": 5 + } + }, + "properties": [ + { + "implicitChangeType": "removed", + "objectKey": "i", + "delta": null, + "changeType": "removed", + "left": { + "path": ["foo", 5, "i"], + "value": 5 + } + } + ] + }, + { + "implicitChangeType": "unchanged", + "index": 6, + "delta": null, + "changeType": "removed", + "left": { + "path": ["foo", 6], + "value": { + "i": 6 + } + }, + "properties": [ + { + "implicitChangeType": "removed", + "objectKey": "i", + "delta": null, + "changeType": "removed", + "left": { + "path": ["foo", 6, "i"], + "value": 6 + } + } + ] + }, + { + "implicitChangeType": "unchanged", + "index": 7, + "delta": null, + "changeType": "removed", + "left": { + "path": ["foo", 7], + "value": { + "i": 7 + } + }, + "properties": [ + { + "implicitChangeType": "removed", + "objectKey": "i", + "delta": null, + "changeType": "removed", + "left": { + "path": ["foo", 7, "i"], + "value": 7 + } + } + ] + }, + { + "implicitChangeType": "unchanged", + "index": 8, + "delta": null, + "changeType": "removed", + "left": { + "path": ["foo", 8], + "value": { + "i": 8 + } + }, + "properties": [ + { + "implicitChangeType": "removed", + "objectKey": "i", + "delta": null, + "changeType": "removed", + "left": { + "path": ["foo", 8, "i"], + "value": 8 + } + } + ] + }, + { + "implicitChangeType": "unchanged", + "index": 9, + "delta": null, + "changeType": "removed", + "left": { + "path": ["foo", 9], + "value": { + "i": 9 + } + }, + "properties": [ + { + "implicitChangeType": "removed", + "objectKey": "i", + "delta": null, + "changeType": "removed", + "left": { + "path": ["foo", 9, "i"], + "value": 9 + } + } + ] + } + ] + } + ] +} diff --git a/packages/compass-crud/test/fixture-results/objects_in_arrays_object_inside_array_changed.json b/packages/compass-crud/test/fixture-results/objects_in_arrays_object_inside_array_changed.json index 589d0666073..fe94283078b 100644 --- a/packages/compass-crud/test/fixture-results/objects_in_arrays_object_inside_array_changed.json +++ b/packages/compass-crud/test/fixture-results/objects_in_arrays_object_inside_array_changed.json @@ -96,9 +96,9 @@ { "implicitChangeType": "unchanged", "changeType": "added", - "index": "1", + "index": 1, "right": { - "path": ["foo", "1"], + "path": ["foo", 1], "value": { "bar": "bazz" } @@ -111,7 +111,7 @@ "delta": null, "changeType": "added", "right": { - "path": ["foo", "1", "bar"], + "path": ["foo", 1, "bar"], "value": "bazz" } } diff --git a/packages/compass-crud/test/fixture-results/objects_in_arrays_object_value_nested_in_an_array.json b/packages/compass-crud/test/fixture-results/objects_in_arrays_object_value_nested_in_an_array.json index 3c0a501cd30..9fbf8f10069 100644 --- a/packages/compass-crud/test/fixture-results/objects_in_arrays_object_value_nested_in_an_array.json +++ b/packages/compass-crud/test/fixture-results/objects_in_arrays_object_value_nested_in_an_array.json @@ -78,9 +78,9 @@ { "implicitChangeType": "unchanged", "changeType": "added", - "index": "0", + "index": 0, "right": { - "path": ["foo", "0"], + "path": ["foo", 0], "value": { "bar": 2 } @@ -93,7 +93,7 @@ "delta": null, "changeType": "added", "right": { - "path": ["foo", "0", "bar"], + "path": ["foo", 0, "bar"], "value": 2 } } diff --git a/packages/compass-crud/test/fixture-results/objects_in_arrays_remove_number_next_to_object_in_array.json b/packages/compass-crud/test/fixture-results/objects_in_arrays_remove_number_next_to_object_in_array.json index ce2a5dce4d5..38b27796a7a 100644 --- a/packages/compass-crud/test/fixture-results/objects_in_arrays_remove_number_next_to_object_in_array.json +++ b/packages/compass-crud/test/fixture-results/objects_in_arrays_remove_number_next_to_object_in_array.json @@ -67,7 +67,7 @@ }, { "implicitChangeType": "unchanged", - "index": 0, + "index": 1, "delta": null, "changeType": "unchanged", "left": {