@@ -156,7 +156,7 @@ export class NeoVis {
156
156
( config as NeovisConfig ) = {
157
157
...config as NeovisConfig ,
158
158
relationships : {
159
- ...config . labels as Record < string , RelationshipConfig > ,
159
+ ...config . relationships as Record < string , RelationshipConfig > ,
160
160
[ key ] : {
161
161
...deepmerge ( defaultRelationshipConfig as RelationshipConfig , config . relationships ?. [ key ] as RelationshipConfig ) ,
162
162
[ NEOVIS_ADVANCED_CONFIG ] : deepmerge ( ( defaultRelationshipConfig as RelationshipConfig ) [ NEOVIS_ADVANCED_CONFIG ] ?? { } , ( config . relationships ?. [ key ] as RelationshipConfig ) [ NEOVIS_ADVANCED_CONFIG ] ?? { } ) ,
@@ -244,33 +244,35 @@ export class NeoVis {
244
244
}
245
245
}
246
246
247
- async #buildCypherObject< VIS_TYPE > ( cypherConfig : RecursiveMapTo < VIS_TYPE , Cypher > , object : VIS_TYPE , id : number ) : Promise < void > {
247
+ * #buildCypherObject< VIS_TYPE > ( cypherConfig : RecursiveMapTo < VIS_TYPE , Cypher > , object : VIS_TYPE , id : number ) : Generator < Promise < void > > {
248
248
if ( cypherConfig && typeof cypherConfig === 'object' ) {
249
249
for ( const prop of Object . keys ( cypherConfig ) as ( keyof VIS_TYPE ) [ ] ) {
250
250
const value = cypherConfig [ prop ] ;
251
251
if ( value && typeof value === 'object' ) {
252
252
if ( ! object [ prop ] ) {
253
253
object [ prop as string ] = { } ;
254
254
}
255
- await this . #buildCypherObject( value as RecursiveMapTo < VIS_TYPE [ keyof VIS_TYPE ] , Cypher > , object [ prop ] , id ) ;
255
+ yield * this . #buildCypherObject( value as RecursiveMapTo < VIS_TYPE [ keyof VIS_TYPE ] , Cypher > , object [ prop ] , id ) ;
256
256
} else {
257
- object [ prop ] = await this . #runCypher( value as string , id ) as VIS_TYPE [ keyof VIS_TYPE ] ;
257
+ const promise = this . #runCypher( value as string , id ) as Promise < VIS_TYPE [ keyof VIS_TYPE ] > ;
258
+ yield Promise . resolve ( promise ) . then ( value => { object [ prop ] = value ; } ) as Promise < void > ;
258
259
}
259
260
}
260
261
}
261
262
}
262
263
263
- async #buildFunctionObject< VIS_TYPE , NEO_TYPE > ( functionConfig : RecursiveMapToFunction < VIS_TYPE , NEO_TYPE > , object : VIS_TYPE , neo4jObj : NEO_TYPE ) : Promise < void > {
264
+ * #buildFunctionObject< VIS_TYPE , NEO_TYPE > ( functionConfig : RecursiveMapToFunction < VIS_TYPE , NEO_TYPE > , object : VIS_TYPE , neo4jObj : NEO_TYPE ) : Generator < Promise < void > > {
264
265
if ( functionConfig && typeof functionConfig === 'object' ) {
265
266
for ( const prop of Object . keys ( functionConfig ) as ( keyof VIS_TYPE ) [ ] ) {
266
267
const func = functionConfig [ prop ] ;
267
268
if ( func && typeof func === 'object' ) {
268
269
if ( ! object [ prop ] ) {
269
270
object [ prop as string ] = { } ;
270
271
}
271
- await this . #buildFunctionObject( func as RecursiveMapToFunction < VIS_TYPE [ keyof VIS_TYPE ] , NEO_TYPE > , object [ prop ] , neo4jObj ) ;
272
+ yield * this . #buildFunctionObject( func as RecursiveMapToFunction < VIS_TYPE [ keyof VIS_TYPE ] , NEO_TYPE > , object [ prop ] , neo4jObj ) ;
272
273
} else {
273
- object [ prop ] = await this . #runFunction( func as ( neo : NEO_TYPE ) => VIS_TYPE [ keyof VIS_TYPE ] , neo4jObj ) ;
274
+ const promise = this . #runFunction( func as ( neo : NEO_TYPE ) => VIS_TYPE [ keyof VIS_TYPE ] , neo4jObj ) ;
275
+ yield Promise . resolve ( promise ) . then ( value => { object [ prop ] = value ; } ) as Promise < void > ;
274
276
}
275
277
}
276
278
}
@@ -309,8 +311,8 @@ export class NeoVis {
309
311
}
310
312
this . #buildPropertyNameObject( propertyConfig , baseObject , neo4jObject ) ;
311
313
this . #buildStaticObject( staticConfig , baseObject ) ;
312
- await this . #buildCypherObject( cypherConfig , baseObject , id ) ;
313
- await this . #buildFunctionObject( functionConfig , baseObject , neo4jObject ) ;
314
+ await Promise . all ( this . #buildCypherObject( cypherConfig , baseObject , id ) ) ;
315
+ await Promise . all ( this . #buildFunctionObject( functionConfig , baseObject , neo4jObject ) ) ;
314
316
}
315
317
316
318
/**
@@ -378,19 +380,19 @@ export class NeoVis {
378
380
const dataPromises = record . map ( async ( v : object ) => {
379
381
this . #consoleLog( 'Constructor:' ) ;
380
382
this . #consoleLog( v ?. constructor . name ) ;
381
- if ( ( isNode as unknown as ( obj : object ) => obj is Neo4jCore . Node ) ( v ) ) {
383
+ if ( isNode ( v ) ) {
382
384
const node = await this . #buildNodeVisObject( v ) ;
383
385
try {
384
386
this . #data. nodes . update ( node ) ;
385
387
} catch ( e ) {
386
388
this . #consoleLog( e , 'error' ) ;
387
389
}
388
390
389
- } else if ( ( isRelationship as unknown as ( obj : object ) => obj is Neo4jCore . Relationship ) ( v ) ) {
391
+ } else if ( isRelationship ( v ) ) {
390
392
const edge = await this . #buildEdgeVisObject( v ) ;
391
393
this . #data. edges . update ( edge ) ;
392
394
393
- } else if ( ( isPath as unknown as ( obj : object ) => obj is Neo4jCore . Path ) ( v ) ) {
395
+ } else if ( isPath ( v ) ) {
394
396
this . #consoleLog( 'PATH' ) ;
395
397
this . #consoleLog( v ) ;
396
398
const startNode = await this . #buildNodeVisObject( v . start ) ;
@@ -409,11 +411,11 @@ export class NeoVis {
409
411
for ( const obj of v ) {
410
412
this . #consoleLog( 'Array element constructor:' ) ;
411
413
this . #consoleLog( obj ?. constructor . name ) ;
412
- if ( ( isNode as unknown as ( obj : object ) => obj is Neo4jCore . Node ) ( obj ) ) {
414
+ if ( isNode ( obj ) ) {
413
415
const node = await this . #buildNodeVisObject( obj ) ;
414
416
this . #data. nodes . update ( node ) ;
415
417
416
- } else if ( ( isRelationship as unknown as ( obj : object ) => obj is Neo4jCore . Relationship ) ( obj ) ) {
418
+ } else if ( isRelationship ( obj ) ) {
417
419
const edge = await this . #buildEdgeVisObject( obj ) ;
418
420
419
421
this . #data. edges . update ( edge ) ;
@@ -448,7 +450,7 @@ export class NeoVis {
448
450
449
451
// eslint-disable-next-line @typescript-eslint/no-this-alias
450
452
const neoVis = this ;
451
- this . #network. on ( 'click' , function ( this : VisNetwork . Network , params : { nodes : Node [ ] , edges : Edge [ ] , pointer : { DOM : VisNetwork . Position } } ) {
453
+ this . #network. on ( 'click' , function ( this : VisNetwork . Network , params : { nodes : Node [ ] , edges : Edge [ ] , pointer : { DOM : VisNetwork . Position } } ) {
452
454
if ( params . nodes . length > 0 ) {
453
455
const nodeId = this . getNodeAt ( params . pointer . DOM ) as number ;
454
456
neoVis . #events. generateEvent ( NeoVisEvents . ClickNodeEvent , {
0 commit comments