MCPcopy Create free account
hub / github.com/adcontextprotocol/adcp / writeEvent

Method writeEvent

server/src/db/catalog-events-db.ts:51–63  ·  view source on GitHub ↗

* Write a single event with a generated UUID v7 event_id. * Call this inside an existing transaction by passing the client directly, * or let it run against the pool for standalone writes.

(input: WriteEventInput, client?: { query: (text: string, params?: unknown[]) => Promise<unknown> })

Source from the content-addressed store, hash-verified

49 * or let it run against the pool for standalone writes.
50 */
51 async writeEvent(input: WriteEventInput, client?: { query: (text: string, params?: unknown[]) => Promise<unknown> }): Promise<string> {
52 const eventId = uuidv7();
53 const sql = `INSERT INTO catalog_events (event_id, event_type, entity_type, entity_id, payload, actor)
54 VALUES ($1, $2, $3, $4, $5, $6)`;
55 const params = [eventId, input.event_type, input.entity_type, input.entity_id, JSON.stringify(input.payload ?? {}), input.actor];
56
57 if (client) {
58 await client.query(sql, params);
59 } else {
60 await query(sql, params);
61 }
62 return eventId;
63 }
64
65 /**
66 * Write multiple events in a single transaction.

Callers 6

writeEventsMethod · 0.95
crawlSingleDomainMethod · 0.80
notifyComplianceChangeFunction · 0.80

Calls 3

uuidv7Function · 0.85
queryFunction · 0.85
queryMethod · 0.80

Tested by

no test coverage detected