1
- import type { INodeJS } from "./INodeJS.js" ;
2
-
3
1
export type NodeId = string
4
2
5
3
export interface IModelServerConnection {
@@ -32,18 +30,18 @@ export class ModelService {
32
30
this . versionHash = data . versionHash
33
31
if ( data . root !== undefined ) this . loadNode ( data . root )
34
32
if ( data . nodes !== undefined ) {
35
- for ( let node of data . nodes ) {
33
+ for ( const node of data . nodes ) {
36
34
this . loadNode ( node )
37
35
}
38
36
}
39
37
}
40
38
41
39
private loadNode ( nodeData : NodeData ) : NodeId {
42
40
this . nodes . set ( nodeData . nodeId , nodeData )
43
- for ( let childRole of Object . entries ( nodeData . children ) ) {
44
- let children : Array < NodeId | NodeData > = childRole [ 1 ] as any
41
+ for ( const childRole of Object . entries ( nodeData . children ) ) {
42
+ const children : Array < NodeId | NodeData > = childRole [ 1 ] as Array < NodeId | NodeData >
45
43
for ( let i = 0 ; i < children . length ; i ++ ) {
46
- let child = children [ i ] ;
44
+ const child = children [ i ] ;
47
45
if ( typeof child === "object" ) {
48
46
children [ i ] = this . loadNode ( child )
49
47
}
@@ -53,7 +51,7 @@ export class ModelService {
53
51
}
54
52
55
53
public addNewNode ( parent : NodeId , role : string , index : number , concept : string ) {
56
- let body = [ < NodeUpdateData > {
54
+ const body = [ < NodeUpdateData > {
57
55
nodeId : this . idGenerator . generate ( ) ,
58
56
parent : parent ,
59
57
role : role ,
@@ -64,7 +62,7 @@ export class ModelService {
64
62
}
65
63
66
64
public getChildren ( parentId : NodeId , role : string ) : NodeId [ ] {
67
- let parentData = this . nodes . get ( parentId )
65
+ const parentData = this . nodes . get ( parentId )
68
66
if ( parentData === undefined ) return [ ]
69
67
return parentData . children [ role ]
70
68
}
@@ -75,18 +73,18 @@ export class ModelService {
75
73
76
74
public getProperty ( nodeId : NodeId , role : string ) : string | undefined {
77
75
console . log ( "getProperty(" + nodeId + ", " + role + ")" )
78
- let node = this . nodes . get ( nodeId ) ;
76
+ const node = this . nodes . get ( nodeId ) ;
79
77
if ( node === undefined ) return undefined ;
80
78
return node . properties [ role ] ;
81
79
}
82
80
83
81
public setProperty ( nodeId : NodeId , role : string , value : string | null | undefined ) {
84
82
console . log ( `setProperty(${ nodeId } , ${ role } , ${ value } )` )
85
- let node = this . nodes . get ( nodeId ) ;
83
+ const node = this . nodes . get ( nodeId ) ;
86
84
if ( node === undefined ) return
87
85
if ( node . properties [ role ] === value ) return
88
86
89
- let body = [ < NodeUpdateData > {
87
+ const body = [ < NodeUpdateData > {
90
88
nodeId : nodeId ,
91
89
properties : {
92
90
[ role ] : value === undefined ? null : value
@@ -181,8 +179,11 @@ interface VersionData {
181
179
182
180
interface NodeData {
183
181
nodeId : NodeId ,
182
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any,@typescript-eslint/no-unused-vars -- Keep for backward compatibility
184
183
references : any ,
184
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any,@typescript-eslint/no-unused-vars -- Keep for backward compatibility
185
185
properties : any ,
186
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any,@typescript-eslint/no-unused-vars -- Keep for backward compatibility
186
187
children : any
187
188
}
188
189
@@ -192,8 +193,11 @@ interface NodeUpdateData {
192
193
role : string | undefined ,
193
194
index : number | undefined ,
194
195
concept : string | undefined ,
196
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any,@typescript-eslint/no-unused-vars -- Keep for backward compatibility
195
197
references : any ,
198
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any,@typescript-eslint/no-unused-vars -- Keep for backward compatibility
196
199
properties : any ,
200
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any,@typescript-eslint/no-unused-vars -- Keep for backward compatibility
197
201
children : any
198
202
}
199
203
@@ -208,7 +212,7 @@ class IdGenerator {
208
212
}
209
213
210
214
public generate ( ) : NodeId {
211
- let id = this . next ++ ;
215
+ const id = this . next ++ ;
212
216
if ( id > this . last ) throw Error ( "Out of IDs" )
213
217
// TODO get new IDs from the server
214
218
return id . toString ( )
0 commit comments