MCPcopy Create free account
hub / github.com/hashintel/hash / getHashInstance

Function getHashInstance

libs/@local/hash-backend-utils/src/hash-instance.ts:54–89  ·  view source on GitHub ↗
(
  context: { graphApi: GraphApi },
  authentication: { actorId: ActorEntityUuid },
)

Source from the content-addressed store, hash-verified

52 * Get the hash instance.
53 */
54export 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};

Callers 7

getUserAndSessionFunction · 0.90
createHashInstanceFunction · 0.90
migrateOntologyTypesFunction · 0.90
migrateFunction · 0.90

Calls 2

queryEntitiesFunction · 0.90

Tested by

no test coverage detected