(params: {
subgraph: Subgraph<EntityRootType<HashEntity>>;
orgEntity: Entity<Organization>;
})
| 170 | * - hasRightEntity: { incoming: 1 } |
| 171 | */ |
| 172 | export const constructOrg = (params: { |
| 173 | subgraph: Subgraph<EntityRootType<HashEntity>>; |
| 174 | orgEntity: Entity<Organization>; |
| 175 | }): Org => { |
| 176 | const { subgraph, orgEntity } = params; |
| 177 | |
| 178 | const minimalOrg = constructMinimalOrg({ |
| 179 | orgEntity, |
| 180 | }); |
| 181 | |
| 182 | let hasAvatar: Org["hasAvatar"]; |
| 183 | let hasBio: Org["hasBio"]; |
| 184 | const memberships: Org["memberships"] = []; |
| 185 | const invitations: Org["invitations"] = []; |
| 186 | const outgoingLinkAndEntities = getOutgoingLinkAndTargetEntities< |
| 187 | LinkEntityAndRightEntity<HashEntity, HashLinkEntity>[] |
| 188 | >(subgraph, orgEntity.metadata.recordId.entityId); |
| 189 | |
| 190 | for (const { linkEntity, rightEntity } of outgoingLinkAndEntities) { |
| 191 | const linkEntityRevision = linkEntity[0]; |
| 192 | |
| 193 | if (!linkEntityRevision) { |
| 194 | continue; |
| 195 | } |
| 196 | |
| 197 | const rightEntityRevision = rightEntity[0]; |
| 198 | |
| 199 | if (!rightEntityRevision) { |
| 200 | continue; |
| 201 | } |
| 202 | |
| 203 | if ( |
| 204 | linkEntityRevision.metadata.entityTypeIds.includes( |
| 205 | systemLinkEntityTypes.hasAvatar.linkEntityTypeId, |
| 206 | ) |
| 207 | ) { |
| 208 | hasAvatar = { |
| 209 | linkEntity: linkEntityRevision, |
| 210 | imageEntity: rightEntityRevision as HashEntity<ImageFile>, |
| 211 | }; |
| 212 | continue; |
| 213 | } |
| 214 | |
| 215 | if ( |
| 216 | linkEntityRevision.metadata.entityTypeIds.includes( |
| 217 | systemLinkEntityTypes.hasBio.linkEntityTypeId, |
| 218 | ) |
| 219 | ) { |
| 220 | hasBio = { |
| 221 | linkEntity: linkEntityRevision, |
| 222 | profileBioEntity: rightEntityRevision as HashEntity<ProfileBio>, |
| 223 | }; |
| 224 | continue; |
| 225 | } |
| 226 | |
| 227 | if ( |
| 228 | linkEntityRevision.metadata.entityTypeIds.includes( |
| 229 | systemLinkEntityTypes.hasIssuedInvitation.linkEntityTypeId, |
no test coverage detected