@@ -706,7 +706,11 @@ export default class AdminForthRestAPI implements IAdminForthRestAPI {
706706 if ( pr . resourceId === null ) {
707707 return ;
708708 }
709- targetResources [ pr . whenValue ] = this . adminforth . config . resources . find ( ( res ) => res . resourceId == pr . resourceId ) ;
709+ const targetResource = this . adminforth . config . resources . find ( ( res ) => res . resourceId == pr . resourceId ) ;
710+ if ( ! targetResource ) {
711+ return ;
712+ }
713+ targetResources [ pr . whenValue ] = targetResource ;
710714 targetConnectors [ pr . whenValue ] = this . adminforth . connectors [ targetResources [ pr . whenValue ] . dataSource ] ;
711715 targetResourcePkFields [ pr . whenValue ] = targetResources [ pr . whenValue ] . columns . find ( ( col ) => col . primaryKey ) . name ;
712716 const pksUnique = [ ...new Set ( data . data . filter ( ( item ) => item [ col . foreignResource . polymorphicOn ] === pr . whenValue ) . map ( ( item ) => item [ col . name ] ) ) ] ;
@@ -984,7 +988,14 @@ export default class AdminForthRestAPI implements IAdminForthRestAPI {
984988 const targetConnectors = { } ;
985989 const targetResourcePkFields = { } ;
986990 column . foreignResource . polymorphicResources . forEach ( ( pr ) => {
987- targetResources [ pr . whenValue ] = this . adminforth . config . resources . find ( ( res ) => res . resourceId == pr . resourceId ) ;
991+ if ( pr . resourceId === null ) {
992+ return ;
993+ }
994+ const targetResource = this . adminforth . config . resources . find ( ( res ) => res . resourceId == pr . resourceId ) ;
995+ if ( ! targetResource ) {
996+ return ;
997+ }
998+ targetResources [ pr . whenValue ] = targetResource ;
988999 targetConnectors [ pr . whenValue ] = this . adminforth . connectors [ targetResources [ pr . whenValue ] . dataSource ] ;
9891000 targetResourcePkFields [ pr . whenValue ] = targetResources [ pr . whenValue ] . columns . find ( ( col ) => col . primaryKey ) . name ;
9901001 } ) ;
@@ -1072,7 +1083,14 @@ export default class AdminForthRestAPI implements IAdminForthRestAPI {
10721083 const targetConnectors = { } ;
10731084 const targetResourcePkFields = { } ;
10741085 column . foreignResource . polymorphicResources . forEach ( ( pr ) => {
1075- targetResources [ pr . whenValue ] = this . adminforth . config . resources . find ( ( res ) => res . resourceId == pr . resourceId ) ;
1086+ if ( pr . resourceId === null ) {
1087+ return ;
1088+ }
1089+ const targetResource = this . adminforth . config . resources . find ( ( res ) => res . resourceId == pr . resourceId ) ;
1090+ if ( ! targetResource ) {
1091+ return ;
1092+ }
1093+ targetResources [ pr . whenValue ] = targetResource ;
10761094 targetConnectors [ pr . whenValue ] = this . adminforth . connectors [ targetResources [ pr . whenValue ] . dataSource ] ;
10771095 targetResourcePkFields [ pr . whenValue ] = targetResources [ pr . whenValue ] . columns . find ( ( col ) => col . primaryKey ) . name ;
10781096 } ) ;
0 commit comments