@@ -127,7 +127,7 @@ export const discourseRelationTripleSchemaToLocalConcept = ({
127127 accountLocalId : string ;
128128 nodeTypesById : Record < string , DiscourseNode > ;
129129 relationTypesById : Record < string , DiscourseRelationType > ;
130- } ) : LocalConceptDataInput => {
130+ } ) : LocalConceptDataInput | null => {
131131 const {
132132 id,
133133 relationshipTypeId,
@@ -140,8 +140,7 @@ export const discourseRelationTripleSchemaToLocalConcept = ({
140140 const sourceName = nodeTypesById [ sourceId ] ?. name ?? sourceId ;
141141 const destinationName = nodeTypesById [ destinationId ] ?. name ?? destinationId ;
142142 const relationType = relationTypesById [ relationshipTypeId ] ;
143- if ( ! relationType )
144- throw new Error ( `missing relation type ${ relationshipTypeId } ` ) ;
143+ if ( ! relationType ) return null ;
145144 const { label, complement } = relationType ;
146145 // eslint-disable-next-line @typescript-eslint/naming-convention
147146 const literal_content : Record < string , Json > = {
@@ -227,9 +226,14 @@ export const relationInstanceToLocalConcept = ({
227226 }
228227 const sourceNode = allNodesById [ source ] ;
229228 const destinationNode = allNodesById [ destination ] ;
229+ if ( sourceNode === undefined || destinationNode === undefined ) {
230+ console . error ( "Cannot find the nodes" ) ;
231+ return null ;
232+ }
233+
230234 if (
231- sourceNode ? .frontmatter . importedFromRid ||
232- destinationNode ? .frontmatter . importedFromRid
235+ sourceNode . frontmatter . importedFromRid ||
236+ destinationNode . frontmatter . importedFromRid
233237 )
234238 return null ; // punt relation to imported nodes for now.
235239 // otherwise put the importedFromRid in source, dest.
@@ -239,7 +243,7 @@ export const relationInstanceToLocalConcept = ({
239243 if ( importedFromRid ) literal_content . importedFromRid = importedFromRid ;
240244 return {
241245 space_id : context . spaceId ,
242- name : `[[${ sourceNode ? sourceNode . file . basename : source } ]] -${ relationType . label } -> [[${ destinationNode ? destinationNode . file . basename : destination } ]]` ,
246+ name : `[[${ sourceNode . file . basename } ]] -${ relationType . label } -> [[${ destinationNode . file . basename } ]]` ,
243247 source_local_id : relationInstanceData . id ,
244248 author_local_id : relationInstanceData . author ,
245249 schema_represented_by_local_id : type ,
0 commit comments