@lionweb/delta-protocol-repository-ws 0.7.0-beta.21

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.
@@ -0,0 +1,544 @@
1
+ // Copyright 2025 TRUMPF Laser SE and other contributors
2
+ //
3
+ // Licensed under the Apache License, Version 2.0 (the "License")
4
+ // you may not use this file except in compliance with the License.
5
+ // You may obtain a copy of the License at
6
+ //
7
+ // http://www.apache.org/licenses/LICENSE-2.0
8
+ //
9
+ // Unless required by applicable law or agreed to in writing, software
10
+ // distributed under the License is distributed on an "AS IS" BASIS,
11
+ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ // See the License for the specific language governing permissions and
13
+ // limitations under the License.
14
+ //
15
+ // SPDX-FileCopyrightText: 2025 TRUMPF Laser SE and other contributors
16
+ // SPDX-License-Identifier: Apache-2.0
17
+
18
+ import {
19
+ AddAnnotationCommand,
20
+ AddChildCommand,
21
+ AddPartitionCommand,
22
+ AddPropertyCommand,
23
+ AddReferenceCommand,
24
+ AddReferenceResolveInfoCommand,
25
+ AddReferenceTargetCommand,
26
+ AnnotationAddedEvent,
27
+ AnnotationDeletedEvent,
28
+ AnnotationMovedAndReplacedFromOtherParentEvent,
29
+ AnnotationMovedAndReplacedInSameParentEvent,
30
+ AnnotationMovedFromOtherParentEvent,
31
+ AnnotationMovedInSameParentEvent,
32
+ AnnotationReplacedEvent,
33
+ ChangeClassifierCommand,
34
+ ChangePropertyCommand,
35
+ ChangeReferenceCommand,
36
+ ChangeReferenceResolveInfoCommand,
37
+ ChangeReferenceTargetCommand,
38
+ ChildAddedEvent,
39
+ ChildDeletedEvent,
40
+ ChildMovedAndReplacedFromOtherContainmentEvent,
41
+ ChildMovedAndReplacedFromOtherContainmentInSameParentEvent,
42
+ ChildMovedAndReplacedInSameContainmentEvent,
43
+ ChildMovedFromOtherContainmentEvent,
44
+ ChildMovedFromOtherContainmentInSameParentEvent,
45
+ ChildMovedInSameContainmentEvent,
46
+ ChildReplacedEvent,
47
+ ClassifierChangedEvent,
48
+ Command,
49
+ CompositeCommand,
50
+ CompositeEvent,
51
+ DeleteAnnotationCommand,
52
+ DeleteChildCommand,
53
+ DeletePartitionCommand,
54
+ DeletePropertyCommand,
55
+ DeleteReferenceCommand,
56
+ DeleteReferenceResolveInfoCommand,
57
+ DeleteReferenceTargetCommand,
58
+ EntryMovedAndReplacedFromOtherReferenceEvent,
59
+ EntryMovedAndReplacedFromOtherReferenceInSameParentEvent,
60
+ EntryMovedAndReplacedInSameReferenceEvent,
61
+ EntryMovedFromOtherReferenceEvent,
62
+ EntryMovedFromOtherReferenceInSameParentEvent,
63
+ EntryMovedInSameReferenceEvent,
64
+ Event,
65
+ MoveAndReplaceAnnotationFromOtherParentCommand,
66
+ MoveAndReplaceAnnotationInSameParentCommand,
67
+ MoveAndReplaceChildFromOtherContainmentCommand,
68
+ MoveAndReplaceChildFromOtherContainmentInSameParentCommand,
69
+ MoveAndReplaceChildInSameContainmentCommand,
70
+ MoveAndReplaceEntryFromOtherReferenceCommand,
71
+ MoveAndReplaceEntryFromOtherReferenceInSameParentCommand,
72
+ MoveAndReplaceEntryInSameReferenceCommand,
73
+ MoveAnnotationFromOtherParentCommand,
74
+ MoveAnnotationInSameParentCommand,
75
+ MoveChildFromOtherContainmentCommand,
76
+ MoveChildFromOtherContainmentInSameParentCommand,
77
+ MoveChildInSameContainmentCommand,
78
+ MoveEntryFromOtherReferenceCommand,
79
+ MoveEntryFromOtherReferenceInSameParentCommand,
80
+ MoveEntryInSameReferenceCommand,
81
+ PartitionAddedEvent,
82
+ PartitionDeletedEvent,
83
+ PropertyAddedEvent,
84
+ PropertyChangedEvent,
85
+ PropertyDeletedEvent,
86
+ ReferenceAddedEvent,
87
+ ReferenceChangedEvent,
88
+ ReferenceDeletedEvent,
89
+ ReferenceResolveInfoAddedEvent,
90
+ ReferenceResolveInfoChangedEvent,
91
+ ReferenceResolveInfoDeletedEvent,
92
+ ReferenceTargetAddedEvent,
93
+ ReferenceTargetChangedEvent,
94
+ ReferenceTargetDeletedEvent,
95
+ ReplaceAnnotationCommand,
96
+ ReplaceChildCommand
97
+ } from "@lionweb/delta-protocol-common"
98
+
99
+ /**
100
+ * @return the {@link Command command}, as issued by a client with the given `participationId`, as an {@link Event event}.
101
+ */
102
+ export const commandAsEvent = (command: Command, participationId: string): Event => {
103
+
104
+ // TODO make dependent on which participationId the event is sent _to_
105
+ const participation2nextSequenceNumber: { [participationId: string]: number } = {}
106
+ const nextSequenceNumber = () => {
107
+ if (!(participationId in participation2nextSequenceNumber)) {
108
+ participation2nextSequenceNumber[participationId] = -1
109
+ }
110
+ return ++participation2nextSequenceNumber[participationId]
111
+ }
112
+
113
+ const completed = <ET extends Event>(
114
+ eventName: ET["messageKind"],
115
+ partialEvent: Omit<ET, "messageKind" | "originCommands" | "sequenceNumber" | "protocolMessages">
116
+ ): Event => ({
117
+ messageKind: eventName,
118
+ ...partialEvent,
119
+ originCommands: [
120
+ {
121
+ participationId,
122
+ commandId: command.commandId
123
+ }
124
+ ],
125
+ sequenceNumber: nextSequenceNumber(),
126
+ protocolMessages: command.protocolMessages
127
+ })
128
+
129
+ const commandAsEvent_ = (command: Command): Event => {
130
+ switch (command.messageKind) {
131
+
132
+ // in order of the specification (§ 6.5):
133
+
134
+ case "AddPartition": {
135
+ const {newPartition} = command as AddPartitionCommand // § 6.5.2.1
136
+ return completed<PartitionAddedEvent>("PartitionAdded", { // § 6.6.1.1
137
+ newPartition
138
+ })
139
+ }
140
+ case "DeletePartition": {
141
+ const {deletedPartition} = command as DeletePartitionCommand // § 6.5.2.2
142
+ return completed<PartitionDeletedEvent>("PartitionDeleted", { // § 6.6.1.2
143
+ deletedPartition
144
+ })
145
+ }
146
+ case "ChangeClassifier": {
147
+ const {node, newClassifier} = command as ChangeClassifierCommand // § 6.5.3.1
148
+ return completed<ClassifierChangedEvent>("ClassifierChanged", { // § 6.6.2.1
149
+ node,
150
+ newClassifier,
151
+ oldClassifier: { language: "???", version: "???", key: "???" }, // TODO get from own model
152
+ })
153
+ }
154
+ case "AddProperty": {
155
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
156
+ const {node, property, newValue} = command as AddPropertyCommand<any> // § 6.5.4.1
157
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
158
+ return completed<PropertyAddedEvent<any>>("PropertyAdded", { // § 6.6.3.1
159
+ node,
160
+ property,
161
+ newValue
162
+ })
163
+ }
164
+ case "DeleteProperty": {
165
+ const {node, property} = command as DeletePropertyCommand // § 6.5.4.2
166
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
167
+ return completed<PropertyDeletedEvent<any>>("PropertyDeleted", { // § 6.6.3.2
168
+ node,
169
+ property,
170
+ oldValue: "???" // TODO get from own model
171
+ })
172
+ }
173
+ case "ChangeProperty": {
174
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
175
+ const {node, property, newValue} = command as ChangePropertyCommand<any> // § 6.5.4.3
176
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
177
+ return completed<PropertyChangedEvent<any>>("PropertyChanged", { // § 6.6.3.3
178
+ node,
179
+ property,
180
+ newValue,
181
+ oldValue: "???", // TODO get from own model
182
+ })
183
+ }
184
+ case "AddChild": {
185
+ const {parent, newChild, containment, index} = command as AddChildCommand // § 6.5.5.1
186
+ return completed<ChildAddedEvent>("ChildAdded", { // § 6.6.4.1
187
+ parent,
188
+ newChild,
189
+ containment,
190
+ index
191
+ })
192
+ }
193
+ case "DeleteChild": {
194
+ const {parent, containment, index, deletedChild} = command as DeleteChildCommand // § 6.5.5.2
195
+ return completed<ChildDeletedEvent>("ChildDeleted", { // § 6.6.4.2
196
+ parent,
197
+ containment,
198
+ index,
199
+ deletedChild,
200
+ deletedDescendants: [] // TODO get from own model
201
+ })
202
+ }
203
+ case "ReplaceChild": {
204
+ const {newChild, parent, containment, index, replacedChild} = command as ReplaceChildCommand // § 6.5.5.3
205
+ return completed<ChildReplacedEvent>("ChildReplaced", { // § 6.6.4.3
206
+ newChild,
207
+ replacedChild,
208
+ replacedDescendants: [], // TODO get from own model
209
+ parent,
210
+ containment,
211
+ index
212
+ })
213
+ }
214
+ case "MoveChildFromOtherContainment": {
215
+ const {newParent, newContainment, newIndex, movedChild} = command as MoveChildFromOtherContainmentCommand // § 6.5.5.4
216
+ return completed<ChildMovedFromOtherContainmentEvent>("ChildMovedFromOtherContainment", { // § 6.6.4.4
217
+ newParent,
218
+ newContainment,
219
+ newIndex,
220
+ movedChild,
221
+ oldParent: "???", // TODO get from own model
222
+ oldContainment: newContainment, // TODO get from own model
223
+ oldIndex: -1 // TODO get from own model
224
+ })
225
+ }
226
+ case "MoveChildFromOtherContainmentInSameParent": {
227
+ const {parent, oldContainment, oldIndex, newContainment, newIndex, movedChild} = command as MoveChildFromOtherContainmentInSameParentCommand // § 6.5.5.5
228
+ return completed<ChildMovedFromOtherContainmentInSameParentEvent>("ChildMovedFromOtherContainmentInSameParent", { // § 6.6.4.5
229
+ parent,
230
+ oldContainment,
231
+ oldIndex,
232
+ newContainment,
233
+ newIndex,
234
+ movedChild
235
+ })
236
+ }
237
+ case "MoveChildInSameContainment": {
238
+ const {newIndex, movedChild} = command as MoveChildInSameContainmentCommand // § 6.5.5.6
239
+ return completed<ChildMovedInSameContainmentEvent>("ChildMovedInSameContainment", { // § 6.6.4.6
240
+ newIndex,
241
+ movedChild,
242
+ parent: "???", // TODO get from own model
243
+ containment: { language: "???", version: "???", key: "???" }, // TODO get from own model
244
+ oldIndex: -1 // TODO get from own model
245
+ })
246
+ }
247
+ case "MoveAndReplaceChildFromOtherContainment": {
248
+ const {newParent, newContainment, newIndex, replacedChild, movedChild} = command as MoveAndReplaceChildFromOtherContainmentCommand // § 6.5.5.7
249
+ return completed<ChildMovedAndReplacedFromOtherContainmentEvent>("ChildMovedAndReplacedFromOtherContainment", { // § 6.6.4.7
250
+ newParent,
251
+ newContainment,
252
+ newIndex,
253
+ movedChild,
254
+ oldParent: newParent, // TODO get from own model
255
+ oldContainment: newContainment, // TODO get from own model
256
+ oldIndex: -1, // TODO get from own model
257
+ replacedChild,
258
+ replacedDescendants: [] // TODO get from own model
259
+ })
260
+ }
261
+ case "MoveAndReplaceChildFromOtherContainmentInSameParent": {
262
+ const {newContainment, newIndex, replacedChild, movedChild} = command as MoveAndReplaceChildFromOtherContainmentInSameParentCommand // § 6.5.5.8
263
+ return completed<ChildMovedAndReplacedFromOtherContainmentInSameParentEvent>("ChildMovedAndReplacedFromOtherContainmentInSameParent", { // § 6.6.4.8
264
+ newContainment,
265
+ newIndex,
266
+ movedChild,
267
+ parent: "???", // TODO get from own model
268
+ oldContainment: newContainment, // TODO get from own model
269
+ oldIndex: -1, // TODO get from own model
270
+ replacedChild: replacedChild,
271
+ replacedDescendants: [] // TODO get from own model
272
+ })
273
+ }
274
+ case "MoveAndReplaceChildInSameContainment": {
275
+ const {newIndex, replacedChild} = command as MoveAndReplaceChildInSameContainmentCommand // § 6.5.5.9
276
+ return completed<ChildMovedAndReplacedInSameContainmentEvent>("ChildMovedAndReplacedInSameContainment", { // § 6.6.4.9
277
+ newIndex,
278
+ movedChild: "???", // TODO get from own model
279
+ parent: "???", // TODO get from own model
280
+ containment: { language: "???", version: "???", key: "???" }, // TODO get from own model
281
+ oldIndex: -1, // TODO get from own model
282
+ replacedChild,
283
+ replacedDescendants: [] // TODO get from own model
284
+ })
285
+ }
286
+ case "AddAnnotation": {
287
+ const {parent, newAnnotation, index} = command as AddAnnotationCommand // § 6.5.6.1
288
+ return completed<AnnotationAddedEvent>("AnnotationAdded", { // § 6.6.5.1
289
+ parent,
290
+ newAnnotation,
291
+ index
292
+ })
293
+ }
294
+ case "DeleteAnnotation": {
295
+ const {deletedAnnotation, parent, index} = command as DeleteAnnotationCommand // § 6.5.6.2
296
+ return completed<AnnotationDeletedEvent>("AnnotationDeleted", { // § 6.6.5.2
297
+ deletedAnnotation,
298
+ deletedDescendants: [], // TODO get from own model
299
+ parent,
300
+ index
301
+ })
302
+ }
303
+ case "ReplaceAnnotation": {
304
+ const {newAnnotation, replacedAnnotation, parent, index} = command as ReplaceAnnotationCommand // § 6.5.6.3
305
+ return completed<AnnotationReplacedEvent>("AnnotationReplaced", { // § 6.6.5.3
306
+ newAnnotation,
307
+ replacedAnnotation,
308
+ replacedDescendants: [], // TODO get from own model
309
+ parent,
310
+ index
311
+ })
312
+ }
313
+ case "MoveAnnotationFromOtherParent": {
314
+ const {newParent, newIndex, movedAnnotation} = command as MoveAnnotationFromOtherParentCommand // § 6.5.6.4
315
+ return completed<AnnotationMovedFromOtherParentEvent>("AnnotationMovedFromOtherParent", { // § 6.6.5.4
316
+ newParent,
317
+ newIndex,
318
+ movedAnnotation,
319
+ oldParent: "???", // TODO get from own model
320
+ oldIndex: -1 // TODO get from own model
321
+ })
322
+ }
323
+ case "MoveAnnotationInSameParent": {
324
+ const {newIndex, movedAnnotation} = command as MoveAnnotationInSameParentCommand // § 6.5.6.5
325
+ return completed<AnnotationMovedInSameParentEvent>("AnnotationMovedInSameParent", { // § 6.6.5.5
326
+ newIndex,
327
+ movedAnnotation,
328
+ parent: "???", // TODO get from own model
329
+ oldIndex: -1 // TODO get from own model
330
+ })
331
+ }
332
+ case "MoveAndReplaceAnnotationFromOtherParent": {
333
+ const {newParent, newIndex, movedAnnotation, replacedAnnotation} = command as MoveAndReplaceAnnotationFromOtherParentCommand // § 6.5.6.6
334
+ return completed<AnnotationMovedAndReplacedFromOtherParentEvent>("AnnotationMovedAndReplacedFromOtherParent", { // § 6.6.5.6
335
+ newParent,
336
+ newIndex,
337
+ movedAnnotation,
338
+ oldParent: "???", // TODO get from own model
339
+ oldIndex: -1, // TODO get from own model
340
+ replacedAnnotation,
341
+ replacedDescendants: [] // TODO get from own model
342
+ })
343
+ }
344
+ case "MoveAndReplaceAnnotationInSameParent": {
345
+ const {newIndex, movedAnnotation, replacedAnnotation} = command as MoveAndReplaceAnnotationInSameParentCommand // § 6.5.6.7
346
+ return completed<AnnotationMovedAndReplacedInSameParentEvent>("AnnotationMovedAndReplacedInSameParent", { // § 6.6.5.7
347
+ newIndex,
348
+ movedAnnotation,
349
+ parent: "???", // TODO get from own model
350
+ oldIndex: -1, // TODO get from own model
351
+ replacedAnnotation,
352
+ replacedDescendants: [] // TODO get from own model
353
+ })
354
+ }
355
+ case "AddReference": {
356
+ const {parent, reference, index, newTarget, newResolveInfo} = command as AddReferenceCommand // § 6.5.7.1
357
+ return completed<ReferenceAddedEvent>("ReferenceAdded", { // § 6.6.6.1
358
+ parent,
359
+ reference,
360
+ index,
361
+ newTarget,
362
+ newResolveInfo
363
+ })
364
+ }
365
+ case "DeleteReference": {
366
+ const {parent, reference, index, deletedTarget, deletedResolveInfo} = command as DeleteReferenceCommand // § 6.5.7.2
367
+ return completed<ReferenceDeletedEvent>("ReferenceDeleted", { // § 6.6.6.2
368
+ parent,
369
+ reference,
370
+ index,
371
+ deletedTarget,
372
+ deletedResolveInfo
373
+ })
374
+ }
375
+ case "ChangeReference": {
376
+ const {parent, reference, index, newTarget, newResolveInfo, oldTarget, oldResolveInfo} = command as ChangeReferenceCommand // § 6.5.7.3
377
+ return completed<ReferenceChangedEvent>("ReferenceChanged", { // § 6.6.6.3
378
+ parent,
379
+ reference,
380
+ index,
381
+ newTarget,
382
+ newResolveInfo,
383
+ oldTarget,
384
+ oldResolveInfo
385
+ })
386
+ }
387
+ case "MoveEntryFromOtherReference": {
388
+ const {newParent, newReference, newIndex, movedTarget} = command as MoveEntryFromOtherReferenceCommand // § 6.5.7.4
389
+ return completed<EntryMovedFromOtherReferenceEvent>("EntryMovedFromOtherReference", { // 6.6.6.4
390
+ newParent,
391
+ newReference,
392
+ newIndex,
393
+ oldParent: "???", // TODO get from own model
394
+ oldReference: { language: "???", version: "???", key: "???" }, // TODO get from own model
395
+ oldIndex: -1, // TODO get from own model
396
+ movedTarget,
397
+ movedResolveInfo: null // TODO get from own model
398
+ })
399
+ }
400
+ case "MoveEntryFromOtherReferenceInSameParent": {
401
+ const {parent, newReference, newIndex, movedTarget} = command as MoveEntryFromOtherReferenceInSameParentCommand // § 6.5.7.5
402
+ return completed<EntryMovedFromOtherReferenceInSameParentEvent>("EntryMovedFromOtherReferenceInSameParent", { // § 6.6.6.5
403
+ parent,
404
+ newReference,
405
+ newIndex,
406
+ oldReference: { language: "???", version: "???", key: "???" }, // TODO get from own model
407
+ oldIndex: -1, // TODO get from own model
408
+ movedTarget,
409
+ movedResolveInfo: null
410
+ })
411
+ }
412
+ case "MoveEntryInSameReference": {
413
+ const {parent, reference, newIndex, movedTarget} = command as MoveEntryInSameReferenceCommand // § 6.5.7.6
414
+ return completed<EntryMovedInSameReferenceEvent>("EntryMovedInSameReference", { // § 6.6.6.6
415
+ parent,
416
+ reference,
417
+ oldIndex: -1,
418
+ newIndex,
419
+ movedTarget,
420
+ movedResolveInfo: null
421
+ })
422
+ }
423
+ case "MoveAndReplaceEntryFromOtherReference": {
424
+ const {newParent, newReference, newIndex, movedTarget, replacedTarget} = command as MoveAndReplaceEntryFromOtherReferenceCommand // § 6.5.7.7
425
+ return completed<EntryMovedAndReplacedFromOtherReferenceEvent>("EntryMovedAndReplacedFromOtherReference", { // § 6.6.6.7
426
+ newParent,
427
+ newReference,
428
+ newIndex,
429
+ movedTarget,
430
+ movedResolveInfo: null,
431
+ oldParent: "???", // TODO get from own model
432
+ oldReference: { language: "???", version: "???", key: "???" }, // TODO get from own model
433
+ oldIndex: -1, // TODO get from own model
434
+ replacedTarget,
435
+ replacedResolveInfo: null
436
+ })
437
+ }
438
+ case "MoveAndReplaceEntryFromOtherReferenceInSameParent": {
439
+ const {parent, newReference, newIndex, movedTarget} = command as MoveAndReplaceEntryFromOtherReferenceInSameParentCommand // § 6.5.7.8
440
+ return completed<EntryMovedAndReplacedFromOtherReferenceInSameParentEvent>("EntryMovedAndReplacedFromOtherReferenceInSameParent", { // § 6.6.6.8
441
+ parent,
442
+ newReference,
443
+ newIndex,
444
+ movedTarget,
445
+ movedResolveInfo: null,
446
+ oldReference: { language: "???", version: "???", key: "???" }, // TODO get from own model
447
+ oldIndex: -1, // TODO get from own model
448
+ replacedTarget: "???", // TODO get from own model
449
+ replacedResolveInfo: null
450
+ })
451
+ }
452
+ case "MoveAndReplaceEntryInSameReference": {
453
+ const {parent, reference, newIndex, movedTarget, oldIndex, replacedTarget} = command as MoveAndReplaceEntryInSameReferenceCommand // § 6.5.7.9
454
+ return completed<EntryMovedAndReplacedInSameReferenceEvent>("EntryMovedAndReplacedInSameReference", { // § 6.6.6.9
455
+ parent,
456
+ reference,
457
+ newIndex,
458
+ movedTarget,
459
+ movedResolveInfo: null,
460
+ oldIndex,
461
+ replacedTarget,
462
+ replacedResolveInfo: null
463
+ })
464
+ }
465
+ case "AddReferenceResolveInfo": {
466
+ const {parent, reference, index, newResolveInfo} = command as AddReferenceResolveInfoCommand // § 6.5.7.10
467
+ return completed<ReferenceResolveInfoAddedEvent>("ReferenceResolveInfoAdded", { // § 6.6.6.10
468
+ parent,
469
+ reference,
470
+ index,
471
+ newResolveInfo,
472
+ target: "???" // TODO get from own model
473
+ })
474
+ }
475
+ case "DeleteReferenceResolveInfo": {
476
+ const {parent, reference, index, deletedResolveInfo} = command as DeleteReferenceResolveInfoCommand // § 6.5.7.11
477
+ return completed<ReferenceResolveInfoDeletedEvent>("ReferenceResolveInfoDeleted", { // § 6.6.6.11
478
+ parent,
479
+ reference,
480
+ index,
481
+ deletedResolveInfo,
482
+ target: "???" // TODO get from own model
483
+ })
484
+ }
485
+ case "ChangeReferenceResolveInfo": {
486
+ const {parent, reference, index, oldResolveInfo, newResolveInfo} = command as ChangeReferenceResolveInfoCommand // § 6.5.7.12
487
+ return completed<ReferenceResolveInfoChangedEvent>("ReferenceResolveInfoChanged", { // § 6.6.6.12
488
+ parent,
489
+ reference,
490
+ index,
491
+ newResolveInfo,
492
+ oldResolveInfo,
493
+ target: "???" // TODO get from own model
494
+ })
495
+ }
496
+ case "AddReferenceTarget": {
497
+ const {parent, reference, index, newTarget} = command as AddReferenceTargetCommand // § 6.5.7.13
498
+ return completed<ReferenceTargetAddedEvent>("ReferenceTargetAdded", { // § 6.6.6.13
499
+ parent,
500
+ reference,
501
+ index,
502
+ newTarget,
503
+ resolveInfo: "???" // TODO get from own model
504
+ })
505
+ }
506
+ case "DeleteReferenceTarget": {
507
+ const {parent, reference, index, deletedTarget} = command as DeleteReferenceTargetCommand // § 6.5.7.14
508
+ return completed<ReferenceTargetDeletedEvent>("ReferenceTargetDeleted", { // § 6.6.6.14
509
+ parent,
510
+ reference,
511
+ index,
512
+ resolveInfo: "???", // TODO get from own model
513
+ deletedTarget
514
+ })
515
+ }
516
+ case "ChangeReferenceTarget": {
517
+ const {parent, reference, index, newTarget} = command as ChangeReferenceTargetCommand // § 6.5.7.15
518
+ return completed<ReferenceTargetChangedEvent>("ReferenceTargetChanged", { // § 6.6.6.15
519
+ parent,
520
+ reference,
521
+ index,
522
+ newTarget,
523
+ resolveInfo: "???", // TODO get from own model
524
+ replacedTarget: "???" // TODO get from own model
525
+ })
526
+ }
527
+ case "CompositeCommand": {
528
+ const {parts} = command as CompositeCommand // § 6.5.8.1
529
+ return completed<CompositeEvent>("CompositeEvent", { // § 6.6.7.1
530
+ parts: parts.map(commandAsEvent_)
531
+ })
532
+ }
533
+ // Note: no command translates into a NoOpEvent, and ErrorEvent-s correspond to faults.
534
+
535
+ default:
536
+ throw new Error(`can't handle command of kind ${command.messageKind}`)
537
+ }
538
+
539
+ }
540
+
541
+ return commandAsEvent_(command)
542
+
543
+ }
544
+
package/src/index.ts ADDED
@@ -0,0 +1,22 @@
1
+ // Copyright 2025 TRUMPF Laser SE and other contributors
2
+ //
3
+ // Licensed under the Apache License, Version 2.0 (the "License")
4
+ // you may not use this file except in compliance with the License.
5
+ // You may obtain a copy of the License at
6
+ //
7
+ // http://www.apache.org/licenses/LICENSE-2.0
8
+ //
9
+ // Unless required by applicable law or agreed to in writing, software
10
+ // distributed under the License is distributed on an "AS IS" BASIS,
11
+ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ // See the License for the specific language governing permissions and
13
+ // limitations under the License.
14
+ //
15
+ // SPDX-FileCopyrightText: 2025 TRUMPF Laser SE and other contributors
16
+ // SPDX-License-Identifier: Apache-2.0
17
+
18
+ export { commandAsEvent } from "./command-to-event.js"
19
+ export { LionWebRepository } from "./repository-impl.js"
20
+ export type { LionWebRepositoryParameters } from "./repository-impl.js"
21
+ export { createWebSocketServer, wsLocalhostUrl } from "./server.js"
22
+