@lionweb/delta-protocol-common 0.7.0-beta.23 → 0.7.0-beta.25
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/dist/payload/command-types.d.ts +4 -4
- package/dist/payload/command-types.d.ts.map +1 -1
- package/dist/payload/event-types.d.ts +7 -7
- package/dist/payload/event-types.d.ts.map +1 -1
- package/dist/payload/query-types.d.ts +11 -0
- package/dist/payload/query-types.d.ts.map +1 -1
- package/dist/payload/query-types.js.map +1 -1
- package/dist/translators/delta-to-command.d.ts +9 -1
- package/dist/translators/delta-to-command.d.ts.map +1 -1
- package/dist/translators/delta-to-command.js +275 -271
- package/dist/translators/delta-to-command.js.map +1 -1
- package/dist/translators/delta-to-event.d.ts +16 -1
- package/dist/translators/delta-to-event.d.ts.map +1 -1
- package/dist/translators/delta-to-event.js +36 -29
- package/dist/translators/delta-to-event.js.map +1 -1
- package/dist/translators/event-to-delta.d.ts +3 -2
- package/dist/translators/event-to-delta.d.ts.map +1 -1
- package/dist/translators/event-to-delta.js +6 -6
- package/dist/translators/event-to-delta.js.map +1 -1
- package/dist/translators/index.d.ts +2 -2
- package/dist/translators/index.d.ts.map +1 -1
- package/dist/translators/index.js +2 -2
- package/dist/translators/index.js.map +1 -1
- package/package.json +5 -5
- package/src/payload/command-types.ts +4 -4
- package/src/payload/event-types.ts +7 -7
- package/src/payload/query-types.ts +15 -0
- package/src/translators/delta-to-command.ts +289 -276
- package/src/translators/delta-to-event.ts +352 -315
- package/src/translators/event-to-delta.ts +19 -10
- package/src/translators/index.ts +2 -2
|
@@ -51,7 +51,9 @@ import {
|
|
|
51
51
|
ReferenceDeletedDelta,
|
|
52
52
|
serializeNodeBases
|
|
53
53
|
} from "@lionweb/class-core"
|
|
54
|
-
import {
|
|
54
|
+
import { nodeBaseReader } from "@lionweb/class-core/dist/serializer.js"
|
|
55
|
+
import { builtinPropertyValueSerializer, metaPointerFor, PropertyValueSerializer, serializedRef } from "@lionweb/core"
|
|
56
|
+
import { LionWebId } from "@lionweb/json"
|
|
55
57
|
import {
|
|
56
58
|
AddAnnotationCommand,
|
|
57
59
|
AddChildCommand,
|
|
@@ -88,286 +90,297 @@ import {
|
|
|
88
90
|
} from "../payload/index.js"
|
|
89
91
|
|
|
90
92
|
|
|
93
|
+
/**
|
|
94
|
+
* Type def. for functions that translate {@link IDelta deltas} into {@link Command commands}.
|
|
95
|
+
* A value of `undefined` is returned for a delta that has no command equivalent.
|
|
96
|
+
* If a command is returned, it has the command ID passed.
|
|
97
|
+
*/
|
|
98
|
+
export type DeltaToCommandTranslator = (delta: IDelta, commandId: LionWebId) => Command | undefined
|
|
99
|
+
|
|
91
100
|
/**
|
|
92
101
|
* @return a {@link IDelta delta} as a {@link Command command} with the given `commandId`.
|
|
93
102
|
*/
|
|
94
|
-
export const
|
|
103
|
+
export const deltaToCommandTranslator = (propertyValueSerializer: PropertyValueSerializer = builtinPropertyValueSerializer) => {
|
|
95
104
|
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
+
const translated: DeltaToCommandTranslator = (delta, commandId) => {
|
|
106
|
+
const completed = <CT extends Command>(
|
|
107
|
+
commandName: CT["messageKind"],
|
|
108
|
+
partialCommand: Omit<CT, "messageKind" | "commandId" | "protocolMessages">
|
|
109
|
+
) => ({
|
|
110
|
+
messageKind: commandName,
|
|
111
|
+
commandId,
|
|
112
|
+
...partialCommand,
|
|
113
|
+
protocolMessages: []
|
|
114
|
+
})
|
|
105
115
|
|
|
106
|
-
|
|
116
|
+
// in order of the specification (§ 6.5):
|
|
107
117
|
|
|
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
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
118
|
+
if (delta instanceof PartitionAddedDelta) {
|
|
119
|
+
return completed<AddPartitionCommand>("AddPartition", { // § 6.5.2.1
|
|
120
|
+
newPartition: serializeNodeBases([delta.newPartition])
|
|
121
|
+
})
|
|
122
|
+
}
|
|
123
|
+
if (delta instanceof PartitionDeletedDelta) {
|
|
124
|
+
return completed<DeletePartitionCommand>("DeletePartition", { // § 6.5.2.2
|
|
125
|
+
deletedPartition: delta.deletedPartition.id
|
|
126
|
+
})
|
|
127
|
+
}
|
|
128
|
+
if (delta instanceof PropertyAddedDelta) {
|
|
129
|
+
return completed<AddPropertyCommand>("AddProperty", { // § 6.5.4.1
|
|
130
|
+
node: delta.node.id,
|
|
131
|
+
property: metaPointerFor(delta.property),
|
|
132
|
+
newValue: propertyValueSerializer.serializeValue(delta.value, delta.property)!
|
|
133
|
+
})
|
|
134
|
+
}
|
|
135
|
+
if (delta instanceof PropertyDeletedDelta) {
|
|
136
|
+
return completed<DeletePropertyCommand>("DeleteProperty", { // § 6.5.4.2
|
|
137
|
+
node: delta.node.id,
|
|
138
|
+
property: metaPointerFor(delta.property)
|
|
139
|
+
})
|
|
140
|
+
}
|
|
141
|
+
if (delta instanceof PropertyChangedDelta) {
|
|
142
|
+
return completed<ChangePropertyCommand>("ChangeProperty", { // § 6.5.4.3
|
|
143
|
+
node: delta.node.id,
|
|
144
|
+
property: metaPointerFor(delta.property),
|
|
145
|
+
newValue: propertyValueSerializer.serializeValue(delta.newValue, delta.property)!
|
|
146
|
+
})
|
|
147
|
+
}
|
|
148
|
+
if (delta instanceof ChildAddedDelta) {
|
|
149
|
+
return completed<AddChildCommand>("AddChild", { // § 6.5.5.1
|
|
150
|
+
parent: delta.parent.id,
|
|
151
|
+
newChild: serializeNodeBases([delta.newChild]),
|
|
152
|
+
containment: metaPointerFor(delta.containment),
|
|
153
|
+
index: delta.index
|
|
154
|
+
})
|
|
155
|
+
}
|
|
156
|
+
if (delta instanceof ChildDeletedDelta) {
|
|
157
|
+
return completed<DeleteChildCommand>("DeleteChild", { // § 6.5.5.2
|
|
158
|
+
parent: delta.parent.id,
|
|
159
|
+
containment: metaPointerFor(delta.containment),
|
|
160
|
+
index: delta.index,
|
|
161
|
+
deletedChild: delta.deletedChild.id
|
|
162
|
+
})
|
|
163
|
+
}
|
|
164
|
+
if (delta instanceof ChildReplacedDelta) {
|
|
165
|
+
return completed<ReplaceChildCommand>("ReplaceChild", { // § 6.5.5.3
|
|
166
|
+
newChild: serializeNodeBases([delta.newChild]),
|
|
167
|
+
parent: delta.parent.id,
|
|
168
|
+
containment: metaPointerFor(delta.containment),
|
|
169
|
+
index: delta.index,
|
|
170
|
+
replacedChild: delta.replacedChild.id
|
|
171
|
+
})
|
|
172
|
+
}
|
|
173
|
+
if (delta instanceof ChildMovedFromOtherContainmentDelta) {
|
|
174
|
+
return completed<MoveChildFromOtherContainmentCommand>("MoveChildFromOtherContainment", { // § 6.5.5.4
|
|
175
|
+
newParent: delta.newParent.id,
|
|
176
|
+
newContainment: metaPointerFor(delta.newContainment),
|
|
177
|
+
newIndex: delta.newIndex,
|
|
178
|
+
movedChild: delta.movedChild.id
|
|
179
|
+
})
|
|
180
|
+
}
|
|
181
|
+
if (delta instanceof ChildMovedFromOtherContainmentInSameParentDelta) {
|
|
182
|
+
return completed<MoveChildFromOtherContainmentInSameParentCommand>("MoveChildFromOtherContainmentInSameParent", { // § 6.5.5.5
|
|
183
|
+
newContainment: metaPointerFor(delta.newContainment),
|
|
184
|
+
newIndex: delta.newIndex,
|
|
185
|
+
movedChild: delta.movedChild.id,
|
|
186
|
+
parent: delta.parent.id,
|
|
187
|
+
oldContainment: metaPointerFor(delta.oldContainment),
|
|
188
|
+
oldIndex: delta.oldIndex
|
|
189
|
+
})
|
|
190
|
+
}
|
|
191
|
+
if (delta instanceof ChildMovedInSameContainmentDelta) {
|
|
192
|
+
return completed<MoveChildInSameContainmentCommand>("MoveChildInSameContainment", { // § 6.5.5.6
|
|
193
|
+
newIndex: delta.newIndex,
|
|
194
|
+
movedChild: delta.movedChild.id
|
|
195
|
+
})
|
|
196
|
+
}
|
|
197
|
+
if (delta instanceof ChildMovedAndReplacedFromOtherContainmentDelta) {
|
|
198
|
+
return completed<MoveAndReplaceChildFromOtherContainmentCommand>("MoveAndReplaceChildFromOtherContainment", { // § 6.5.5.7
|
|
199
|
+
newParent: delta.newParent.id,
|
|
200
|
+
newContainment: metaPointerFor(delta.newContainment),
|
|
201
|
+
newIndex: delta.newIndex,
|
|
202
|
+
replacedChild: delta.replacedChild.id,
|
|
203
|
+
movedChild: delta.movedChild.id
|
|
204
|
+
})
|
|
205
|
+
}
|
|
206
|
+
if (delta instanceof ChildMovedAndReplacedFromOtherContainmentInSameParentDelta) {
|
|
207
|
+
return completed<MoveAndReplaceChildFromOtherContainmentInSameParentCommand>("MoveAndReplaceChildFromOtherContainmentInSameParent", { // § 6.5.5.8
|
|
208
|
+
newContainment: metaPointerFor(delta.newContainment),
|
|
209
|
+
newIndex: delta.newIndex,
|
|
210
|
+
replacedChild: delta.replacedChild.id,
|
|
211
|
+
movedChild: delta.movedChild.id
|
|
212
|
+
})
|
|
213
|
+
}
|
|
214
|
+
if (delta instanceof ChildMovedAndReplacedInSameContainmentDelta) {
|
|
215
|
+
return completed<MoveAndReplaceChildInSameContainmentCommand>("MoveAndReplaceChildInSameContainment", { // § 6.5.5.9
|
|
216
|
+
newIndex: delta.newIndex,
|
|
217
|
+
replacedChild: delta.replacedChild.id
|
|
218
|
+
})
|
|
219
|
+
}
|
|
220
|
+
if (delta instanceof AnnotationAddedDelta) {
|
|
221
|
+
return completed<AddAnnotationCommand>("AddAnnotation", { // § 6.5.6.1
|
|
222
|
+
parent: delta.parent.id,
|
|
223
|
+
index: delta.index,
|
|
224
|
+
newAnnotation: serializeNodeBases([delta.newAnnotation])
|
|
225
|
+
})
|
|
226
|
+
}
|
|
227
|
+
if (delta instanceof AnnotationDeletedDelta) {
|
|
228
|
+
return completed<DeleteAnnotationCommand>("DeleteAnnotation", { // § 6.5.6.2
|
|
229
|
+
parent: delta.parent.id,
|
|
230
|
+
deletedAnnotation: delta.deletedAnnotation.id,
|
|
231
|
+
index: delta.index
|
|
232
|
+
})
|
|
233
|
+
}
|
|
234
|
+
if (delta instanceof AnnotationReplacedDelta) {
|
|
235
|
+
return completed<ReplaceAnnotationCommand>("ReplaceAnnotation", { // § 6.5.6.3
|
|
236
|
+
newAnnotation: serializeNodeBases([delta.newAnnotation]),
|
|
237
|
+
parent: delta.parent.id,
|
|
238
|
+
index: delta.index,
|
|
239
|
+
replacedAnnotation: delta.replacedAnnotation.id
|
|
240
|
+
})
|
|
241
|
+
}
|
|
242
|
+
if (delta instanceof AnnotationMovedFromOtherParentDelta) {
|
|
243
|
+
return completed<MoveAnnotationFromOtherParentCommand>("MoveAnnotationFromOtherParent", { // § 6.5.6.4
|
|
244
|
+
newParent: delta.newParent.id,
|
|
245
|
+
newIndex: delta.newIndex,
|
|
246
|
+
movedAnnotation: delta.movedAnnotation.id
|
|
247
|
+
})
|
|
248
|
+
}
|
|
249
|
+
if (delta instanceof AnnotationMovedInSameParentDelta) {
|
|
250
|
+
return completed<MoveAnnotationInSameParentCommand>("MoveAnnotationInSameParent", { // § 6.5.6.5
|
|
251
|
+
newIndex: delta.newIndex,
|
|
252
|
+
movedAnnotation: delta.movedAnnotation.id
|
|
253
|
+
})
|
|
254
|
+
}
|
|
255
|
+
if (delta instanceof AnnotationMovedAndReplacedFromOtherParentDelta) {
|
|
256
|
+
return completed<MoveAndReplaceAnnotationFromOtherParentCommand>("MoveAndReplaceAnnotationFromOtherParent", { // § 6.5.6.6
|
|
257
|
+
newParent: delta.newParent.id,
|
|
258
|
+
newIndex: delta.newIndex,
|
|
259
|
+
replacedAnnotation: delta.replacedAnnotation.id,
|
|
260
|
+
movedAnnotation: delta.movedAnnotation.id
|
|
261
|
+
})
|
|
262
|
+
}
|
|
263
|
+
if (delta instanceof AnnotationMovedAndReplacedInSameParentDelta) {
|
|
264
|
+
return completed<MoveAndReplaceAnnotationInSameParentCommand>("MoveAndReplaceAnnotationInSameParent", { // § 6.5.6.7
|
|
265
|
+
newIndex: delta.newIndex,
|
|
266
|
+
replacedAnnotation: delta.replacedAnnotation.id,
|
|
267
|
+
movedAnnotation: delta.movedAnnotation.id
|
|
268
|
+
})
|
|
269
|
+
}
|
|
270
|
+
if (delta instanceof ReferenceAddedDelta) {
|
|
271
|
+
return completed<AddReferenceCommand>("AddReference", { // § 6.5.7.1
|
|
272
|
+
parent: delta.parent.id,
|
|
273
|
+
reference: metaPointerFor(delta.reference),
|
|
274
|
+
index: delta.index,
|
|
275
|
+
newTarget: serializedRef(delta.newTarget),
|
|
276
|
+
newResolveInfo: nodeBaseReader.resolveInfoFor!(delta.newTarget!)!
|
|
277
|
+
})
|
|
278
|
+
}
|
|
279
|
+
if (delta instanceof ReferenceDeletedDelta) {
|
|
280
|
+
return completed<DeleteReferenceCommand>("DeleteReference", { // § 6.5.7.2
|
|
281
|
+
parent: delta.parent.id,
|
|
282
|
+
reference: metaPointerFor(delta.reference),
|
|
283
|
+
index: delta.index,
|
|
284
|
+
deletedTarget: serializedRef(delta.deletedTarget),
|
|
285
|
+
deletedResolveInfo: nodeBaseReader.resolveInfoFor!(delta.deletedTarget!)!
|
|
286
|
+
})
|
|
287
|
+
}
|
|
288
|
+
if (delta instanceof ReferenceChangedDelta) {
|
|
289
|
+
return completed<ChangeReferenceCommand>("ChangeReference", { // § 6.5.7.3
|
|
290
|
+
parent: delta.parent.id,
|
|
291
|
+
reference: metaPointerFor(delta.reference),
|
|
292
|
+
index: delta.index,
|
|
293
|
+
oldTarget: serializedRef(delta.oldTarget),
|
|
294
|
+
oldResolveInfo: nodeBaseReader.resolveInfoFor!(delta.oldTarget!)!,
|
|
295
|
+
newTarget: serializedRef(delta.newTarget),
|
|
296
|
+
newResolveInfo: nodeBaseReader.resolveInfoFor!(delta.oldTarget!)!
|
|
297
|
+
})
|
|
298
|
+
}
|
|
299
|
+
if (delta instanceof EntryMovedFromOtherReferenceDelta) {
|
|
300
|
+
return completed<MoveEntryFromOtherReferenceCommand>("MoveEntryFromOtherReference", { // § 6.5.7.4
|
|
301
|
+
newParent: delta.newParent.id,
|
|
302
|
+
newReference: metaPointerFor(delta.newReference),
|
|
303
|
+
newIndex: delta.newIndex,
|
|
304
|
+
oldParent: delta.oldParent.id,
|
|
305
|
+
oldReference: metaPointerFor(delta.oldReference),
|
|
306
|
+
oldIndex: delta.oldIndex,
|
|
307
|
+
movedTarget: serializedRef(delta.movedTarget),
|
|
308
|
+
movedResolveInfo: nodeBaseReader.resolveInfoFor!(delta.movedTarget!)!
|
|
309
|
+
})
|
|
310
|
+
}
|
|
311
|
+
if (delta instanceof EntryMovedFromOtherReferenceInSameParentDelta) {
|
|
312
|
+
return completed<MoveEntryFromOtherReferenceInSameParentCommand>("MoveEntryFromOtherReferenceInSameParent", { // § 6.5.7.5
|
|
313
|
+
parent: delta.parent.id,
|
|
314
|
+
newReference: metaPointerFor(delta.newReference),
|
|
315
|
+
newIndex: delta.newIndex,
|
|
316
|
+
oldIndex: delta.oldIndex,
|
|
317
|
+
movedTarget: serializedRef(delta.movedTarget),
|
|
318
|
+
movedResolveInfo: nodeBaseReader.resolveInfoFor!(delta.movedTarget!)!
|
|
319
|
+
})
|
|
320
|
+
}
|
|
321
|
+
if (delta instanceof EntryMovedInSameReferenceDelta) {
|
|
322
|
+
return completed<MoveEntryInSameReferenceCommand>("MoveEntryInSameReference", { // § 6.5.7.6
|
|
323
|
+
parent: delta.parent.id,
|
|
324
|
+
reference: metaPointerFor(delta.reference),
|
|
325
|
+
oldIndex: delta.oldIndex,
|
|
326
|
+
newIndex: delta.newIndex,
|
|
327
|
+
movedTarget: serializedRef(delta.movedTarget),
|
|
328
|
+
movedResolveInfo: nodeBaseReader.resolveInfoFor!(delta.movedTarget!)!
|
|
329
|
+
})
|
|
330
|
+
}
|
|
331
|
+
if (delta instanceof EntryMovedAndReplacedFromOtherReferenceDelta) {
|
|
332
|
+
return completed<MoveAndReplaceEntryFromOtherReferenceCommand>("MoveAndReplaceEntryFromOtherReference", { // § 6.5.7.7
|
|
333
|
+
newParent: delta.newParent.id,
|
|
334
|
+
newReference: metaPointerFor(delta.newReference),
|
|
335
|
+
newIndex: delta.newIndex,
|
|
336
|
+
replacedTarget: serializedRef(delta.replacedTarget),
|
|
337
|
+
replacedResolveInfo: nodeBaseReader.resolveInfoFor!(delta.replacedTarget!)!,
|
|
338
|
+
oldParent: delta.oldParent.id,
|
|
339
|
+
oldReference: metaPointerFor(delta.oldReference),
|
|
340
|
+
oldIndex: delta.oldIndex,
|
|
341
|
+
movedTarget: serializedRef(delta.movedTarget),
|
|
342
|
+
movedResolveInfo: nodeBaseReader.resolveInfoFor!(delta.movedTarget!)!
|
|
343
|
+
})
|
|
344
|
+
}
|
|
345
|
+
if (delta instanceof EntryMovedAndReplacedFromOtherReferenceInSameParentDelta) {
|
|
346
|
+
return completed<MoveAndReplaceEntryFromOtherReferenceInSameParentCommand>("MoveAndReplaceEntryFromOtherReferenceInSameParent", { // § 6.5.7.8
|
|
347
|
+
parent: delta.parent.id,
|
|
348
|
+
newReference: metaPointerFor(delta.newReference),
|
|
349
|
+
newIndex: delta.newIndex,
|
|
350
|
+
replacedTarget: serializedRef(delta.replacedTarget),
|
|
351
|
+
replacedResolveInfo: nodeBaseReader.resolveInfoFor!(delta.replacedTarget!)!,
|
|
352
|
+
oldReference: metaPointerFor(delta.oldReference),
|
|
353
|
+
oldIndex: delta.oldIndex,
|
|
354
|
+
movedTarget: serializedRef(delta.movedTarget),
|
|
355
|
+
movedResolveInfo: nodeBaseReader.resolveInfoFor!(delta.movedTarget!)!
|
|
356
|
+
})
|
|
357
|
+
}
|
|
358
|
+
if (delta instanceof EntryMovedAndReplacedInSameReferenceDelta) {
|
|
359
|
+
return completed<MoveAndReplaceEntryInSameReferenceCommand>("MoveAndReplaceEntryInSameReference", { // § 6.5.7.9
|
|
360
|
+
parent: delta.parent.id,
|
|
361
|
+
reference: metaPointerFor(delta.reference),
|
|
362
|
+
oldIndex: delta.oldIndex,
|
|
363
|
+
movedTarget: serializedRef(delta.movedTarget),
|
|
364
|
+
movedResolveInfo: nodeBaseReader.resolveInfoFor!(delta.movedTarget!)!,
|
|
365
|
+
newIndex: delta.newIndex,
|
|
366
|
+
replacedTarget: serializedRef(delta.replacedTarget),
|
|
367
|
+
replacedResolveInfo: nodeBaseReader.resolveInfoFor!(delta.replacedTarget!)!
|
|
368
|
+
})
|
|
369
|
+
}
|
|
370
|
+
if (delta instanceof CompositeDelta) {
|
|
371
|
+
return completed<CompositeCommand>("CompositeCommand", { // § 6.5.8.1
|
|
372
|
+
parts: delta.parts
|
|
373
|
+
.map((part, index) => translated(part, `${commandId}-${index}`)) // TODO inject proper ID generator!
|
|
374
|
+
.filter((command) => command !== undefined) as Command[]
|
|
375
|
+
})
|
|
376
|
+
}
|
|
377
|
+
if (delta instanceof NoOpDelta) {
|
|
378
|
+
return undefined
|
|
379
|
+
}
|
|
370
380
|
|
|
371
|
-
|
|
372
|
-
}
|
|
381
|
+
throw new Error(`can't handle delta of type ${delta.constructor.name}`)
|
|
382
|
+
}
|
|
383
|
+
|
|
384
|
+
return translated
|
|
385
|
+
}
|
|
373
386
|
|