MCPcopy Index your code
hub / github.com/codemix/graph / handleAsyncTransaction

Function handleAsyncTransaction

packages/graph/src/AsyncGraph.ts:203–257  ·  view source on GitHub ↗
(
  graph: Graph<TSchema>,
  command: AsyncTransaction,
)

Source from the content-addressed store, hash-verified

201}
202
203function* handleAsyncTransaction<TSchema extends GraphSchema>(
204 graph: Graph<TSchema>,
205 command: AsyncTransaction,
206): Iterable<AsyncTransactionOperationResult> {
207 for (const operation of command.operations) {
208 try {
209 switch (operation["@type"]) {
210 case "AddVertexOperation": {
211 graph.storage.addVertex(operation.vertex);
212 yield {
213 "@type": "AsyncOperationSuccess",
214 };
215 break;
216 }
217 case "AddEdgeOperation": {
218 graph.storage.addEdge(operation.edge);
219 yield {
220 "@type": "AsyncOperationSuccess",
221 };
222 break;
223 }
224 case "DeleteVertexOperation": {
225 graph.storage.deleteVertex(operation.id);
226 yield {
227 "@type": "AsyncOperationSuccess",
228 };
229 break;
230 }
231 case "DeleteEdgeOperation": {
232 graph.storage.deleteEdge(operation.id);
233 yield {
234 "@type": "AsyncOperationSuccess",
235 };
236 break;
237 }
238 case "UpdatePropertyOperation": {
239 graph.storage.updateProperty(operation.id, operation.key, operation.value);
240 yield {
241 "@type": "AsyncOperationSuccess",
242 };
243 break;
244 }
245 default: {
246 throw new Error(`Unknown operation type: ${operation["@type"]}`);
247 }
248 }
249 } catch (error) {
250 yield {
251 "@type": "AsyncOperationFailure",
252 operation: operation,
253 error: error instanceof Error ? error.message : String(error),
254 };
255 }
256 }
257}

Callers 1

handleAsyncCommandFunction · 0.85

Calls 5

addVertexMethod · 0.65
addEdgeMethod · 0.65
deleteVertexMethod · 0.65
deleteEdgeMethod · 0.65
updatePropertyMethod · 0.65

Tested by

no test coverage detected