@lionweb/delta-protocol-common 0.7.1 → 0.7.2-beta.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +8 -1
- package/dist/translators/delta-to-command.d.ts +5 -2
- package/dist/translators/delta-to-command.d.ts.map +1 -1
- package/dist/translators/delta-to-command.js +7 -3
- package/dist/translators/delta-to-command.js.map +1 -1
- package/dist/translators/delta-to-event.d.ts +3 -3
- package/dist/translators/delta-to-event.d.ts.map +1 -1
- package/dist/translators/delta-to-event.js +317 -314
- package/dist/translators/delta-to-event.js.map +1 -1
- package/package.json +5 -5
- package/src/translators/delta-to-command.ts +285 -279
- package/src/translators/delta-to-event.ts +8 -6
|
@@ -16,323 +16,326 @@
|
|
|
16
16
|
// SPDX-License-Identifier: Apache-2.0
|
|
17
17
|
import { allNodesFrom, AnnotationAddedDelta, AnnotationDeletedDelta, AnnotationMovedAndReplacedFromOtherParentDelta, AnnotationMovedAndReplacedInSameParentDelta, AnnotationMovedFromOtherParentDelta, AnnotationMovedInSameParentDelta, AnnotationReplacedDelta, ChildAddedDelta, ChildDeletedDelta, ChildMovedAndReplacedFromOtherContainmentDelta, ChildMovedAndReplacedFromOtherContainmentInSameParentDelta, ChildMovedAndReplacedInSameContainmentDelta, ChildMovedFromOtherContainmentDelta, ChildMovedFromOtherContainmentInSameParentDelta, ChildMovedInSameContainmentDelta, ChildReplacedDelta, CompositeDelta, EntryMovedAndReplacedFromOtherReferenceDelta, EntryMovedAndReplacedFromOtherReferenceInSameParentDelta, EntryMovedAndReplacedInSameReferenceDelta, EntryMovedFromOtherReferenceDelta, EntryMovedFromOtherReferenceInSameParentDelta, EntryMovedInSameReferenceDelta, NoOpDelta, PartitionAddedDelta, PartitionDeletedDelta, PropertyAddedDelta, PropertyChangedDelta, PropertyDeletedDelta, ReferenceAddedDelta, ReferenceChangedDelta, ReferenceDeletedDelta, serializeNodeBases } from "@lionweb/class-core";
|
|
18
18
|
import { builtinPropertyValueSerializer, idOf, metaPointerFor, serializedRef } from "@lionweb/core";
|
|
19
|
-
import { nodeBaseReader } from "@lionweb/class-core/dist/serializer.js";
|
|
19
|
+
import { nodeBaseReader, propertyValueSerializerWith } from "@lionweb/class-core/dist/serializer.js";
|
|
20
20
|
const allIdsOfDescendantsFrom = (node) => allNodesFrom(node).slice(1).map(idOf);
|
|
21
21
|
/**
|
|
22
|
-
* @return a {@link DeltaToEventTranslator} instance using the given {@link PropertyValueSerializer}
|
|
23
|
-
*
|
|
22
|
+
* @return a {@link DeltaToEventTranslator} instance using the given {@link PropertyValueSerializer},
|
|
23
|
+
* that's solely used to serialize primitive values, and defaults to the {@link builtinPropertyValueSerializer}.
|
|
24
24
|
*/
|
|
25
|
-
export const deltaToEventTranslator = (
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
.
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
25
|
+
export const deltaToEventTranslator = (primitiveValueSerializer = builtinPropertyValueSerializer) => {
|
|
26
|
+
const propertyValueSerializer = propertyValueSerializerWith({ primitiveValueSerializer });
|
|
27
|
+
return (delta, lastUsedSequenceNumber) => {
|
|
28
|
+
let sequenceNumber = lastUsedSequenceNumber;
|
|
29
|
+
const completed = (technicalName, partialEvent) => ({
|
|
30
|
+
messageKind: technicalName,
|
|
31
|
+
...partialEvent,
|
|
32
|
+
sequenceNumber: ++sequenceNumber,
|
|
33
|
+
originCommands: [],
|
|
34
|
+
protocolMessages: []
|
|
35
|
+
});
|
|
36
|
+
// in order of the specification (§ 6.6):
|
|
37
|
+
const translated = (delta) => {
|
|
38
|
+
if (delta instanceof PartitionAddedDelta) {
|
|
39
|
+
return completed("PartitionAdded", {
|
|
40
|
+
newPartition: serializeNodeBases([delta.newPartition])
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
if (delta instanceof PartitionDeletedDelta) {
|
|
44
|
+
return completed("PartitionDeleted", {
|
|
45
|
+
deletedPartition: delta.deletedPartition.id
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
if (delta instanceof PropertyAddedDelta) {
|
|
49
|
+
return completed("PropertyAdded", {
|
|
50
|
+
node: delta.node.id,
|
|
51
|
+
property: metaPointerFor(delta.property),
|
|
52
|
+
newValue: propertyValueSerializer.serializeValue(delta.value, delta.property)
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
if (delta instanceof PropertyDeletedDelta) {
|
|
56
|
+
return completed("PropertyDeleted", {
|
|
57
|
+
node: delta.node.id,
|
|
58
|
+
property: metaPointerFor(delta.property),
|
|
59
|
+
oldValue: propertyValueSerializer.serializeValue(delta.oldValue, delta.property)
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
if (delta instanceof PropertyChangedDelta) {
|
|
63
|
+
return completed("PropertyChanged", {
|
|
64
|
+
node: delta.node.id,
|
|
65
|
+
property: metaPointerFor(delta.property),
|
|
66
|
+
newValue: propertyValueSerializer.serializeValue(delta.newValue, delta.property),
|
|
67
|
+
oldValue: propertyValueSerializer.serializeValue(delta.oldValue, delta.property)
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
if (delta instanceof ChildAddedDelta) {
|
|
71
|
+
return completed("ChildAdded", {
|
|
72
|
+
parent: delta.parent.id,
|
|
73
|
+
newChild: serializeNodeBases([delta.newChild]),
|
|
74
|
+
containment: metaPointerFor(delta.containment),
|
|
75
|
+
index: delta.index
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
if (delta instanceof ChildDeletedDelta) {
|
|
79
|
+
return completed("ChildDeleted", {
|
|
80
|
+
parent: delta.parent.id,
|
|
81
|
+
containment: metaPointerFor(delta.containment),
|
|
82
|
+
index: delta.index,
|
|
83
|
+
deletedChild: delta.deletedChild.id,
|
|
84
|
+
deletedDescendants: allIdsOfDescendantsFrom(delta.deletedChild)
|
|
85
|
+
});
|
|
86
|
+
}
|
|
87
|
+
if (delta instanceof ChildReplacedDelta) {
|
|
88
|
+
return completed("ChildReplaced", {
|
|
89
|
+
newChild: serializeNodeBases([delta.newChild]),
|
|
90
|
+
parent: delta.parent.id,
|
|
91
|
+
containment: metaPointerFor(delta.containment),
|
|
92
|
+
index: delta.index,
|
|
93
|
+
replacedChild: delta.replacedChild.id,
|
|
94
|
+
replacedDescendants: allIdsOfDescendantsFrom(delta.replacedChild)
|
|
95
|
+
});
|
|
96
|
+
}
|
|
97
|
+
if (delta instanceof ChildMovedFromOtherContainmentDelta) {
|
|
98
|
+
return completed("ChildMovedFromOtherContainment", {
|
|
99
|
+
newParent: delta.newParent.id,
|
|
100
|
+
newContainment: metaPointerFor(delta.newContainment),
|
|
101
|
+
newIndex: delta.newIndex,
|
|
102
|
+
movedChild: delta.movedChild.id,
|
|
103
|
+
oldParent: delta.oldParent.id,
|
|
104
|
+
oldContainment: metaPointerFor(delta.oldContainment),
|
|
105
|
+
oldIndex: delta.oldIndex
|
|
106
|
+
});
|
|
107
|
+
}
|
|
108
|
+
if (delta instanceof ChildMovedFromOtherContainmentInSameParentDelta) {
|
|
109
|
+
return completed("ChildMovedFromOtherContainmentInSameParent", {
|
|
110
|
+
newContainment: metaPointerFor(delta.newContainment),
|
|
111
|
+
newIndex: delta.newIndex,
|
|
112
|
+
movedChild: delta.movedChild.id,
|
|
113
|
+
parent: delta.parent.id,
|
|
114
|
+
oldContainment: metaPointerFor(delta.oldContainment),
|
|
115
|
+
oldIndex: delta.oldIndex
|
|
116
|
+
});
|
|
117
|
+
}
|
|
118
|
+
if (delta instanceof ChildMovedInSameContainmentDelta) {
|
|
119
|
+
return completed("ChildMovedInSameContainment", {
|
|
120
|
+
parent: delta.parent.id,
|
|
121
|
+
containment: metaPointerFor(delta.containment),
|
|
122
|
+
oldIndex: delta.oldIndex,
|
|
123
|
+
newIndex: delta.newIndex,
|
|
124
|
+
movedChild: delta.movedChild.id
|
|
125
|
+
});
|
|
126
|
+
}
|
|
127
|
+
if (delta instanceof ChildMovedAndReplacedFromOtherContainmentDelta) {
|
|
128
|
+
return completed("ChildMovedAndReplacedFromOtherContainment", {
|
|
129
|
+
newParent: delta.newParent.id,
|
|
130
|
+
newContainment: metaPointerFor(delta.newContainment),
|
|
131
|
+
newIndex: delta.newIndex,
|
|
132
|
+
oldParent: delta.oldParent.id,
|
|
133
|
+
oldContainment: metaPointerFor(delta.oldContainment),
|
|
134
|
+
oldIndex: delta.oldIndex,
|
|
135
|
+
movedChild: delta.movedChild.id,
|
|
136
|
+
replacedChild: delta.replacedChild.id,
|
|
137
|
+
replacedDescendants: allIdsOfDescendantsFrom(delta.replacedChild)
|
|
138
|
+
});
|
|
139
|
+
}
|
|
140
|
+
if (delta instanceof ChildMovedAndReplacedFromOtherContainmentInSameParentDelta) {
|
|
141
|
+
return completed("ChildMovedAndReplacedFromOtherContainmentInSameParent", {
|
|
142
|
+
parent: delta.parent.id,
|
|
143
|
+
oldContainment: metaPointerFor(delta.oldContainment),
|
|
144
|
+
oldIndex: delta.oldIndex,
|
|
145
|
+
newContainment: metaPointerFor(delta.newContainment),
|
|
146
|
+
newIndex: delta.newIndex,
|
|
147
|
+
replacedChild: delta.replacedChild.id,
|
|
148
|
+
replacedDescendants: allIdsOfDescendantsFrom(delta.replacedChild),
|
|
149
|
+
movedChild: delta.movedChild.id
|
|
150
|
+
});
|
|
151
|
+
}
|
|
152
|
+
if (delta instanceof ChildMovedAndReplacedInSameContainmentDelta) {
|
|
153
|
+
return completed("ChildMovedAndReplacedInSameContainment", {
|
|
154
|
+
parent: delta.parent.id,
|
|
155
|
+
containment: metaPointerFor(delta.containment),
|
|
156
|
+
oldIndex: delta.oldIndex,
|
|
157
|
+
newIndex: delta.newIndex,
|
|
158
|
+
movedChild: delta.movedChild.id,
|
|
159
|
+
replacedChild: delta.replacedChild.id,
|
|
160
|
+
replacedDescendants: allIdsOfDescendantsFrom(delta.replacedChild)
|
|
161
|
+
});
|
|
162
|
+
}
|
|
163
|
+
if (delta instanceof AnnotationAddedDelta) {
|
|
164
|
+
return completed("AnnotationAdded", {
|
|
165
|
+
parent: delta.parent.id,
|
|
166
|
+
index: delta.index,
|
|
167
|
+
newAnnotation: serializeNodeBases([delta.newAnnotation])
|
|
168
|
+
});
|
|
169
|
+
}
|
|
170
|
+
if (delta instanceof AnnotationDeletedDelta) {
|
|
171
|
+
return completed("AnnotationDeleted", {
|
|
172
|
+
parent: delta.parent.id,
|
|
173
|
+
deletedAnnotation: delta.deletedAnnotation.id,
|
|
174
|
+
index: delta.index,
|
|
175
|
+
deletedDescendants: allIdsOfDescendantsFrom(delta.deletedAnnotation)
|
|
176
|
+
});
|
|
177
|
+
}
|
|
178
|
+
if (delta instanceof AnnotationReplacedDelta) {
|
|
179
|
+
return completed("AnnotationReplaced", {
|
|
180
|
+
newAnnotation: serializeNodeBases([delta.newAnnotation]),
|
|
181
|
+
parent: delta.parent.id,
|
|
182
|
+
index: delta.index,
|
|
183
|
+
replacedAnnotation: delta.replacedAnnotation.id,
|
|
184
|
+
replacedDescendants: allIdsOfDescendantsFrom(delta.replacedAnnotation)
|
|
185
|
+
});
|
|
186
|
+
}
|
|
187
|
+
if (delta instanceof AnnotationMovedFromOtherParentDelta) {
|
|
188
|
+
return completed("AnnotationMovedFromOtherParent", {
|
|
189
|
+
oldParent: delta.oldParent.id,
|
|
190
|
+
oldIndex: delta.oldIndex,
|
|
191
|
+
newParent: delta.newParent.id,
|
|
192
|
+
newIndex: delta.newIndex,
|
|
193
|
+
movedAnnotation: delta.movedAnnotation.id
|
|
194
|
+
});
|
|
195
|
+
}
|
|
196
|
+
if (delta instanceof AnnotationMovedInSameParentDelta) {
|
|
197
|
+
return completed("AnnotationMovedInSameParent", {
|
|
198
|
+
parent: delta.parent.id,
|
|
199
|
+
oldIndex: delta.oldIndex,
|
|
200
|
+
newIndex: delta.newIndex,
|
|
201
|
+
movedAnnotation: delta.movedAnnotation.id
|
|
202
|
+
});
|
|
203
|
+
}
|
|
204
|
+
if (delta instanceof AnnotationMovedAndReplacedFromOtherParentDelta) {
|
|
205
|
+
return completed("AnnotationMovedAndReplacedFromOtherParent", {
|
|
206
|
+
oldParent: delta.oldParent.id,
|
|
207
|
+
oldIndex: delta.oldIndex,
|
|
208
|
+
newParent: delta.newParent.id,
|
|
209
|
+
newIndex: delta.newIndex,
|
|
210
|
+
replacedAnnotation: delta.replacedAnnotation.id,
|
|
211
|
+
replacedDescendants: allIdsOfDescendantsFrom(delta.replacedAnnotation),
|
|
212
|
+
movedAnnotation: delta.movedAnnotation.id
|
|
213
|
+
});
|
|
214
|
+
}
|
|
215
|
+
if (delta instanceof AnnotationMovedAndReplacedInSameParentDelta) {
|
|
216
|
+
return completed("AnnotationMovedAndReplacedInSameParent", {
|
|
217
|
+
parent: delta.parent.id,
|
|
218
|
+
oldIndex: delta.oldIndex,
|
|
219
|
+
newIndex: delta.newIndex,
|
|
220
|
+
replacedAnnotation: delta.replacedAnnotation.id,
|
|
221
|
+
replacedDescendants: allIdsOfDescendantsFrom(delta.replacedAnnotation),
|
|
222
|
+
movedAnnotation: delta.movedAnnotation.id
|
|
223
|
+
});
|
|
224
|
+
}
|
|
225
|
+
if (delta instanceof ReferenceAddedDelta) {
|
|
226
|
+
return completed("ReferenceAdded", {
|
|
227
|
+
parent: delta.parent.id,
|
|
228
|
+
reference: metaPointerFor(delta.reference),
|
|
229
|
+
index: delta.index,
|
|
230
|
+
newTarget: serializedRef(delta.newTarget),
|
|
231
|
+
newResolveInfo: nodeBaseReader.resolveInfoFor(delta.newTarget)
|
|
232
|
+
});
|
|
233
|
+
}
|
|
234
|
+
if (delta instanceof ReferenceDeletedDelta) {
|
|
235
|
+
return completed("ReferenceDeleted", {
|
|
236
|
+
parent: delta.parent.id,
|
|
237
|
+
reference: metaPointerFor(delta.reference),
|
|
238
|
+
index: delta.index,
|
|
239
|
+
deletedTarget: serializedRef(delta.deletedTarget),
|
|
240
|
+
deletedResolveInfo: nodeBaseReader.resolveInfoFor(delta.deletedTarget)
|
|
241
|
+
});
|
|
242
|
+
}
|
|
243
|
+
if (delta instanceof ReferenceChangedDelta) {
|
|
244
|
+
return completed("ReferenceChanged", {
|
|
245
|
+
parent: delta.parent.id,
|
|
246
|
+
reference: metaPointerFor(delta.reference),
|
|
247
|
+
index: delta.index,
|
|
248
|
+
oldTarget: serializedRef(delta.oldTarget),
|
|
249
|
+
oldResolveInfo: nodeBaseReader.resolveInfoFor(delta.oldTarget),
|
|
250
|
+
newTarget: serializedRef(delta.newTarget),
|
|
251
|
+
newResolveInfo: nodeBaseReader.resolveInfoFor(delta.newTarget)
|
|
252
|
+
});
|
|
253
|
+
}
|
|
254
|
+
if (delta instanceof EntryMovedFromOtherReferenceDelta) {
|
|
255
|
+
return completed("EntryMovedFromOtherReference", {
|
|
256
|
+
newParent: delta.newParent.id,
|
|
257
|
+
newReference: metaPointerFor(delta.newReference),
|
|
258
|
+
newIndex: delta.newIndex,
|
|
259
|
+
oldParent: delta.oldParent.id,
|
|
260
|
+
oldReference: metaPointerFor(delta.oldReference),
|
|
261
|
+
oldIndex: delta.oldIndex,
|
|
262
|
+
movedTarget: serializedRef(delta.movedTarget),
|
|
263
|
+
movedResolveInfo: nodeBaseReader.resolveInfoFor(delta.movedTarget)
|
|
264
|
+
});
|
|
265
|
+
}
|
|
266
|
+
if (delta instanceof EntryMovedFromOtherReferenceInSameParentDelta) {
|
|
267
|
+
return completed("EntryMovedFromOtherReferenceInSameParent", {
|
|
268
|
+
parent: delta.parent.id,
|
|
269
|
+
newReference: metaPointerFor(delta.newReference),
|
|
270
|
+
newIndex: delta.newIndex,
|
|
271
|
+
oldReference: metaPointerFor(delta.oldReference),
|
|
272
|
+
oldIndex: delta.oldIndex,
|
|
273
|
+
movedTarget: serializedRef(delta.movedTarget),
|
|
274
|
+
movedResolveInfo: nodeBaseReader.resolveInfoFor(delta.movedTarget)
|
|
275
|
+
});
|
|
276
|
+
}
|
|
277
|
+
if (delta instanceof EntryMovedInSameReferenceDelta) {
|
|
278
|
+
return completed("EntryMovedInSameReference", {
|
|
279
|
+
parent: delta.parent.id,
|
|
280
|
+
reference: metaPointerFor(delta.reference),
|
|
281
|
+
oldIndex: delta.oldIndex,
|
|
282
|
+
newIndex: delta.newIndex,
|
|
283
|
+
movedTarget: serializedRef(delta.movedTarget),
|
|
284
|
+
movedResolveInfo: nodeBaseReader.resolveInfoFor(delta.movedTarget)
|
|
285
|
+
});
|
|
286
|
+
}
|
|
287
|
+
if (delta instanceof EntryMovedAndReplacedFromOtherReferenceDelta) {
|
|
288
|
+
return completed("EntryMovedAndReplacedFromOtherReference", {
|
|
289
|
+
newParent: delta.newParent.id,
|
|
290
|
+
newReference: metaPointerFor(delta.newReference),
|
|
291
|
+
newIndex: delta.newIndex,
|
|
292
|
+
replacedTarget: serializedRef(delta.replacedTarget),
|
|
293
|
+
replacedResolveInfo: nodeBaseReader.resolveInfoFor(delta.replacedTarget),
|
|
294
|
+
oldParent: delta.oldParent.id,
|
|
295
|
+
oldReference: metaPointerFor(delta.oldReference),
|
|
296
|
+
oldIndex: delta.oldIndex,
|
|
297
|
+
movedTarget: serializedRef(delta.movedTarget),
|
|
298
|
+
movedResolveInfo: nodeBaseReader.resolveInfoFor(delta.movedTarget)
|
|
299
|
+
});
|
|
300
|
+
}
|
|
301
|
+
if (delta instanceof EntryMovedAndReplacedFromOtherReferenceInSameParentDelta) {
|
|
302
|
+
return completed("EntryMovedAndReplacedFromOtherReferenceInSameParent", {
|
|
303
|
+
parent: delta.parent.id,
|
|
304
|
+
newReference: metaPointerFor(delta.newReference),
|
|
305
|
+
newIndex: delta.newIndex,
|
|
306
|
+
replacedTarget: serializedRef(delta.replacedTarget),
|
|
307
|
+
replacedResolveInfo: nodeBaseReader.resolveInfoFor(delta.replacedTarget),
|
|
308
|
+
oldReference: metaPointerFor(delta.oldReference),
|
|
309
|
+
oldIndex: delta.oldIndex,
|
|
310
|
+
movedTarget: serializedRef(delta.movedTarget),
|
|
311
|
+
movedResolveInfo: nodeBaseReader.resolveInfoFor(delta.movedTarget)
|
|
312
|
+
});
|
|
313
|
+
}
|
|
314
|
+
if (delta instanceof EntryMovedAndReplacedInSameReferenceDelta) {
|
|
315
|
+
return completed("EntryMovedAndReplacedInSameReference", {
|
|
316
|
+
parent: delta.parent.id,
|
|
317
|
+
reference: metaPointerFor(delta.reference),
|
|
318
|
+
oldIndex: delta.oldIndex,
|
|
319
|
+
movedTarget: serializedRef(delta.movedTarget),
|
|
320
|
+
movedResolveInfo: nodeBaseReader.resolveInfoFor(delta.movedTarget),
|
|
321
|
+
newIndex: delta.newIndex,
|
|
322
|
+
replacedTarget: serializedRef(delta.replacedTarget),
|
|
323
|
+
replacedResolveInfo: nodeBaseReader.resolveInfoFor(delta.replacedTarget)
|
|
324
|
+
});
|
|
325
|
+
}
|
|
326
|
+
if (delta instanceof CompositeDelta) {
|
|
327
|
+
return completed("CompositeEvent", {
|
|
328
|
+
parts: delta.parts
|
|
329
|
+
.map((part) => translated(part))
|
|
330
|
+
.filter((event) => event !== undefined)
|
|
331
|
+
});
|
|
332
|
+
}
|
|
333
|
+
if (delta instanceof NoOpDelta) {
|
|
334
|
+
return completed("NoOp", {});
|
|
335
|
+
}
|
|
336
|
+
throw new Error(`can't handle delta of type ${delta.constructor.name}`);
|
|
337
|
+
};
|
|
338
|
+
return [translated(delta), sequenceNumber];
|
|
335
339
|
};
|
|
336
|
-
return [translated(delta), sequenceNumber];
|
|
337
340
|
};
|
|
338
341
|
//# sourceMappingURL=delta-to-event.js.map
|