@@ -9,7 +9,8 @@ export type OperationType =
99 | 'batch-add-blocks'
1010 | 'batch-remove-blocks'
1111 | 'add-edge'
12- | 'remove-edge'
12+ | 'batch-add-edges'
13+ | 'batch-remove-edges'
1314 | 'batch-move-blocks'
1415 | 'update-parent'
1516
@@ -71,11 +72,19 @@ export interface AddEdgeOperation extends BaseOperation {
7172}
7273
7374/**
74- * Remove edge operation data.
75+ * Batch add edges operation data.
7576 */
76- export interface RemoveEdgeOperation extends BaseOperation {
77- type : 'remove-edge'
78- data : { edgeId : string ; edgeSnapshot : any }
77+ export interface BatchAddEdgesOperation extends BaseOperation {
78+ type : 'batch-add-edges'
79+ data : { edgeSnapshots : any [ ] }
80+ }
81+
82+ /**
83+ * Batch remove edges operation data.
84+ */
85+ export interface BatchRemoveEdgesOperation extends BaseOperation {
86+ type : 'batch-remove-edges'
87+ data : { edgeSnapshots : any [ ] }
7988}
8089
8190/**
@@ -96,7 +105,8 @@ export type Operation =
96105 | BatchAddBlocksOperation
97106 | BatchRemoveBlocksOperation
98107 | AddEdgeOperation
99- | RemoveEdgeOperation
108+ | BatchAddEdgesOperation
109+ | BatchRemoveEdgesOperation
100110 | BatchMoveBlocksOperation
101111 | UpdateParentOperation
102112
@@ -212,10 +222,16 @@ export function createRemoveBlockEntry(
212222/**
213223 * Creates a mock add-edge operation entry.
214224 */
215- export function createAddEdgeEntry ( edgeId : string , options : OperationEntryOptions = { } ) : any {
225+ export function createAddEdgeEntry (
226+ edgeId : string ,
227+ edgeSnapshot : any = null ,
228+ options : OperationEntryOptions = { }
229+ ) : any {
216230 const { id = nanoid ( 8 ) , workflowId = 'wf-1' , userId = 'user-1' , createdAt = Date . now ( ) } = options
217231 const timestamp = Date . now ( )
218232
233+ const snapshot = edgeSnapshot || { id : edgeId , source : 'block-1' , target : 'block-2' }
234+
219235 return {
220236 id,
221237 createdAt,
@@ -229,21 +245,20 @@ export function createAddEdgeEntry(edgeId: string, options: OperationEntryOption
229245 } ,
230246 inverse : {
231247 id : nanoid ( 8 ) ,
232- type : 'remove-edge ' ,
248+ type : 'batch- remove-edges ' ,
233249 timestamp,
234250 workflowId,
235251 userId,
236- data : { edgeId , edgeSnapshot : null } ,
252+ data : { edgeSnapshots : [ snapshot ] } ,
237253 } ,
238254 }
239255}
240256
241257/**
242- * Creates a mock remove-edge operation entry.
258+ * Creates a mock batch- remove-edges operation entry.
243259 */
244- export function createRemoveEdgeEntry (
245- edgeId : string ,
246- edgeSnapshot : any = null ,
260+ export function createBatchRemoveEdgesEntry (
261+ edgeSnapshots : any [ ] ,
247262 options : OperationEntryOptions = { }
248263) : any {
249264 const { id = nanoid ( 8 ) , workflowId = 'wf-1' , userId = 'user-1' , createdAt = Date . now ( ) } = options
@@ -254,19 +269,19 @@ export function createRemoveEdgeEntry(
254269 createdAt,
255270 operation : {
256271 id : nanoid ( 8 ) ,
257- type : 'remove-edge ' ,
272+ type : 'batch- remove-edges ' ,
258273 timestamp,
259274 workflowId,
260275 userId,
261- data : { edgeId , edgeSnapshot } ,
276+ data : { edgeSnapshots } ,
262277 } ,
263278 inverse : {
264279 id : nanoid ( 8 ) ,
265- type : 'add-edge ' ,
280+ type : 'batch- add-edges ' ,
266281 timestamp,
267282 workflowId,
268283 userId,
269- data : { edgeId } ,
284+ data : { edgeSnapshots } ,
270285 } ,
271286 }
272287}
0 commit comments