1
+ import { entries } from '@seedcompany/common' ;
1
2
import { createHash } from 'crypto' ;
2
3
import { node , type Query , relation } from 'cypher-query-builder' ;
3
4
import { type RelationDirection } from 'cypher-query-builder/dist/typings/clauses/relation-pattern' ;
@@ -90,20 +91,20 @@ export function createRelationships<TResourceStatic extends ResourceShape<any>>(
90
91
maybeLabelsToRelationships ?: RelationshipDefinition ,
91
92
) {
92
93
resource = EnhancedResource . of ( resource ) ;
93
- const normalizedArgs =
94
+ const normalizedArgs : AnyDirectionalDefinition =
94
95
typeof directionOrDefinition === 'string'
95
96
? { [ directionOrDefinition ] : maybeLabelsToRelationships }
96
97
: directionOrDefinition ;
97
98
98
- const flattened = Object . entries ( normalizedArgs ) . flatMap (
99
+ const flattened = entries ( normalizedArgs ) . flatMap (
99
100
( [ direction , relationships ] ) =>
100
- Object . entries ( relationships ?? { } ) . flatMap ( ( [ relLabel , varOrTuple ] ) =>
101
+ Object . entries ( relationships ) . flatMap ( ( [ relLabel , varOrTuple ] ) =>
101
102
many ( Array . isArray ( varOrTuple ) ? varOrTuple [ 1 ] ?? [ ] : varOrTuple ) . map (
102
103
( id , i ) => ( {
103
104
nodeLabel : Array . isArray ( varOrTuple ) ? varOrTuple [ 0 ] : undefined , // no labels for variables
104
105
id,
105
- direction : direction as RelationDirection ,
106
- relLabel : relLabel ,
106
+ direction,
107
+ relLabel,
107
108
variable : ! Array . isArray ( varOrTuple )
108
109
? varOrTuple instanceof Variable
109
110
? varOrTuple . value
@@ -123,9 +124,9 @@ export function createRelationships<TResourceStatic extends ResourceShape<any>>(
123
124
return ( query : Query ) => query ;
124
125
}
125
126
126
- // We are creating inside of changeset if there's a changeset relation into the node.
127
+ // We're creating inside a changeset if there is a changeset relation into the node.
127
128
const inChangeset = flattened . some (
128
- ( f ) => f . direction === 'in' && f . relLabel === 'changeset' && f . id ,
129
+ ( f ) => f . direction === 'in' && f . relLabel === 'changeset' ,
129
130
) ;
130
131
131
132
const createdAt = DateTime . local ( ) ;
0 commit comments