| 1 | import { schema } from '@ghost/db'; |
| 2 | |
| 3 | import type { Executor |
| 4 | |
| 5 | /** What each event carries. Ids only: a consumer reads the rows as they are when it runs, and skips an event whose rows are gone. Issue events cover pull requests too, since a pull request is an issue. */ |
| 6 | export type EventPayloads |
| 7 | 'issue.opened': |
| 8 | 'issue.closed': |
| 9 | 'issue.reopened': |
| 10 | 'issue.assigned': |
| 11 | 'issue.commented': |
| 12 | 'pull_request.merged': |
| 13 | 'pull_request.reviewed': |
| 14 | 'pull_request.review_commented': |
| 15 | }; |
| 16 | |
| 17 | export type EventType |
| 18 | |
| 19 | export type RepositoryEvent |
| 20 | [Type |
| 21 | type: Type |
| 22 | repositoryId: string |
| 23 | actorId: string |
| 24 | payload: EventPayloads |
| 25 | }; |
| 26 | }[EventType] |
| 27 | |
| 28 | /** Queues `event` for every consumer. Pass the transaction making the change, so the event exists exactly when the change does. */ |
| 29 | export async function publishEvent |
| 30 | await db.insert |
| 31 | } |