g1t/crates/contracts/src/events.rs

116 lines3,562 bytesCodeBlame

Pick any line to see why it is the way it is: the commit, the pull request and issue it came from, and what the agent was thinking.

Rust repos service with shipping; pull requests kept in the model1//! Events published on the bus. Mirrors `packages/contracts/src/events.ts`.
2
3use serde::Serialize;
4
5/// What a publisher supplies; the bus fills in the id and time.
6#[derive(Debug, Serialize)]
7#[serde(rename_all = "camelCase")]
8pub struct NewEvent<T: Serialize> {
9 #[serde(rename = "type")]
10 pub kind: &'static str,
11 /// The service that published it.
12 pub source: &'static str,
13 /// The repo the event concerns.
14 pub repo_id: Option<String>,
15 /// The user or agent that caused it, if any.
16 pub actor: Option<String>,
17 pub data: T,
18}
19
20#[derive(Debug, Serialize)]
21#[serde(rename_all = "camelCase")]
22pub struct RepoCreated {
23 pub repo_id: String,
24 pub namespace: String,
25 pub name: String,
26 pub is_private: bool,
27}
28
29#[derive(Debug, Serialize)]
30#[serde(rename_all = "camelCase")]
31pub struct RepoForked {
32 pub repo_id: String,
33 pub source_repo_id: String,
Issues and pull requests replace intents and attempts34 pub pull_id: String,
Rust repos service with shipping; pull requests kept in the model35}
36
37/// `after` is the commit the ref points to once the push has landed.
38#[derive(Debug, Serialize)]
39#[serde(rename_all = "camelCase")]
40pub struct GitPush {
41 pub repo_id: String,
42 #[serde(rename = "ref")]
43 pub git_ref: String,
44 pub after: String,
45}
Work service in Rust, with RFC 3339 timestamps46
Issues and pull requests replace intents and attempts47/// The payload of `issue.opened`, `issue.updated`, `issue.closed` and
48/// `issue.reopened`; each uses the fields that apply to it.
49#[derive(Debug, Default, Serialize)]
Work service in Rust, with RFC 3339 timestamps50#[serde(rename_all = "camelCase")]
Issues and pull requests replace intents and attempts51pub struct IssueEvent {
52 pub issue_id: String,
Work service in Rust, with RFC 3339 timestamps53 pub repo_id: String,
54 pub number: u32,
Issues and pull requests replace intents and attempts55 #[serde(skip_serializing_if = "Option::is_none")]
56 pub title: Option<String>,
57 /// On close: `completed` or `not_planned`.
58 #[serde(skip_serializing_if = "Option::is_none")]
59 pub reason: Option<&'static str>,
60 /// On close: the number of the pull request whose merge closed it.
61 #[serde(skip_serializing_if = "Option::is_none")]
62 pub resolved_by: Option<u32>,
Work service in Rust, with RFC 3339 timestamps63}
64
Issues and pull requests replace intents and attempts65/// The payload of `pull.opened`, `pull.ready`, `pull.closed` and
66/// `pull.merged`; each uses the fields that apply to it.
Work service in Rust, with RFC 3339 timestamps67#[derive(Debug, Default, Serialize)]
68#[serde(rename_all = "camelCase")]
Issues and pull requests replace intents and attempts69pub struct PullEvent {
70 pub pull_id: String,
Work service in Rust, with RFC 3339 timestamps71 pub repo_id: String,
Issues and pull requests replace intents and attempts72 pub number: u32,
73 /// The number of the issue it is for.
74 #[serde(skip_serializing_if = "Option::is_none")]
75 pub issue: Option<u32>,
Work service in Rust, with RFC 3339 timestamps76 #[serde(skip_serializing_if = "Option::is_none")]
77 pub agent: Option<String>,
Issues and pull requests replace intents and attempts78 /// On merge: the commit the branch now points to.
Work service in Rust, with RFC 3339 timestamps79 #[serde(skip_serializing_if = "Option::is_none")]
Issues and pull requests replace intents and attempts80 pub commit: Option<String>,
81 /// On close: the pull request that was merged instead.
Work service in Rust, with RFC 3339 timestamps82 #[serde(skip_serializing_if = "Option::is_none")]
Issues and pull requests replace intents and attempts83 pub superseded_by: Option<u32>,
Work service in Rust, with RFC 3339 timestamps84}
85
Issues and pull requests replace intents and attempts86/// `comment.created`. `number` is the issue or pull request commented on.
Work service in Rust, with RFC 3339 timestamps87#[derive(Debug, Serialize)]
88#[serde(rename_all = "camelCase")]
Issues and pull requests replace intents and attempts89pub struct CommentCreated {
90 pub comment_id: String,
91 pub repo_id: String,
92 pub number: u32,
93}
94
95#[derive(Debug, Serialize)]
96#[serde(rename_all = "camelCase")]
Work service in Rust, with RFC 3339 timestamps97pub struct SessionAppended {
Issues and pull requests replace intents and attempts98 pub pull_id: String,
99 pub repo_id: String,
100 pub number: u32,
Work service in Rust, with RFC 3339 timestamps101 pub count: u32,
102}
103
104/// An event as delivered to subscribers. `data` is left as JSON; each
105/// subscriber decodes the types it cares about.
106#[derive(Debug, serde::Deserialize)]
107#[serde(rename_all = "camelCase")]
108pub struct Delivered {
109 pub id: String,
110 #[serde(rename = "type")]
111 pub kind: String,
112 /// Milliseconds since the epoch, until the bus itself moves to RFC 3339.
113 pub time: serde_json::Value,
114 pub repo_id: Option<String>,
115 pub data: serde_json::Value,
116}