(
context: { graphApi: GraphApi },
authentication: { actorId: ActorEntityUuid },
)
| 52 | * Get the hash instance. |
| 53 | */ |
| 54 | export const getHashInstance = async ( |
| 55 | context: { graphApi: GraphApi }, |
| 56 | authentication: { actorId: ActorEntityUuid }, |
| 57 | ): Promise<HashInstance> => { |
| 58 | const { entities } = await backOff( |
| 59 | () => |
| 60 | queryEntities<HASHInstanceEntity>(context, authentication, { |
| 61 | filter: { |
| 62 | equal: [ |
| 63 | { path: ["type", "baseUrl"] }, |
| 64 | { parameter: systemEntityTypes.hashInstance.entityTypeBaseUrl }, |
| 65 | ], |
| 66 | }, |
| 67 | temporalAxes: currentTimeInstantTemporalAxes, |
| 68 | includeDrafts: false, |
| 69 | includePermissions: false, |
| 70 | }), |
| 71 | { |
| 72 | numOfAttempts: 3, |
| 73 | startingDelay: 1_000, |
| 74 | jitter: "full", |
| 75 | }, |
| 76 | ); |
| 77 | |
| 78 | if (entities.length > 1) { |
| 79 | throw new Error("More than one hash instance entity found in the graph."); |
| 80 | } |
| 81 | |
| 82 | const entity = entities[0]; |
| 83 | |
| 84 | if (!entity) { |
| 85 | throw new NotFoundError("Could not find hash instance entity."); |
| 86 | } |
| 87 | |
| 88 | return getHashInstanceFromEntity({ entity }); |
| 89 | }; |
no test coverage detected