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.
| Events service in Rust, with RFC 3339 times and accurate push events | 1 | //! Events published on the bus, and the events service that carries them. |
| 2 | //! Mirrors `packages/contracts/src/events.ts`. | |
| Rust repos service with shipping; pull requests kept in the model | 3 | |
| 4 | use serde::Serialize; | |
| 5 | ||
| 6 | /// What a publisher supplies; the bus fills in the id and time. | |
| 7 | #[derive(Debug, Serialize)] | |
| 8 | #[serde(rename_all = "camelCase")] | |
| 9 | pub struct NewEvent<T: Serialize> { | |
| 10 | #[serde(rename = "type")] | |
| 11 | pub kind: &'static str, | |
| 12 | /// The service that published it. | |
| 13 | pub source: &'static str, | |
| 14 | /// The repo the event concerns. | |
| 15 | pub repo_id: Option<String>, | |
| 16 | /// The user or agent that caused it, if any. | |
| 17 | pub actor: Option<String>, | |
| 18 | pub data: T, | |
| 19 | } | |
| 20 | ||
| 21 | #[derive(Debug, Serialize)] | |
| 22 | #[serde(rename_all = "camelCase")] | |
| 23 | pub struct RepoCreated { | |
| 24 | pub repo_id: String, | |
| 25 | pub namespace: String, | |
| 26 | pub name: String, | |
| 27 | pub is_private: bool, | |
| 28 | } | |
| 29 | ||
| 30 | #[derive(Debug, Serialize)] | |
| 31 | #[serde(rename_all = "camelCase")] | |
| 32 | pub struct RepoForked { | |
| 33 | pub repo_id: String, | |
| 34 | pub source_repo_id: String, | |
| Issues and pull requests replace intents and attempts | 35 | pub pull_id: String, |
| Rust repos service with shipping; pull requests kept in the model | 36 | } |
| 37 | ||
| Events service in Rust, with RFC 3339 times and accurate push events | 38 | /// One branch moved by a push. `after` is the commit it points to now. |
| Rust repos service with shipping; pull requests kept in the model | 39 | #[derive(Debug, Serialize)] |
| 40 | #[serde(rename_all = "camelCase")] | |
| 41 | pub struct GitPush { | |
| 42 | pub repo_id: String, | |
| Events service in Rust, with RFC 3339 times and accurate push events | 43 | /// The full ref, such as `refs/heads/main`. |
| Rust repos service with shipping; pull requests kept in the model | 44 | #[serde(rename = "ref")] |
| 45 | pub git_ref: String, | |
| 46 | pub after: String, | |
| Events service in Rust, with RFC 3339 times and accurate push events | 47 | /// Whether the ref is the repository's default branch. |
| 48 | pub default_branch: bool, | |
| Rust repos service with shipping; pull requests kept in the model | 49 | } |
| Work service in Rust, with RFC 3339 timestamps | 50 | |
| Issues and pull requests replace intents and attempts | 51 | /// The payload of `issue.opened`, `issue.updated`, `issue.closed` and |
| 52 | /// `issue.reopened`; each uses the fields that apply to it. | |
| 53 | #[derive(Debug, Default, Serialize)] | |
| Work service in Rust, with RFC 3339 timestamps | 54 | #[serde(rename_all = "camelCase")] |
| Issues and pull requests replace intents and attempts | 55 | pub struct IssueEvent { |
| 56 | pub issue_id: String, | |
| Work service in Rust, with RFC 3339 timestamps | 57 | pub repo_id: String, |
| 58 | pub number: u32, | |
| Issues and pull requests replace intents and attempts | 59 | #[serde(skip_serializing_if = "Option::is_none")] |
| 60 | pub title: Option<String>, | |
| 61 | /// On close: `completed` or `not_planned`. | |
| 62 | #[serde(skip_serializing_if = "Option::is_none")] | |
| 63 | pub reason: Option<&'static str>, | |
| 64 | /// On close: the number of the pull request whose merge closed it. | |
| 65 | #[serde(skip_serializing_if = "Option::is_none")] | |
| 66 | pub resolved_by: Option<u32>, | |
| Work service in Rust, with RFC 3339 timestamps | 67 | } |
| 68 | ||
| Acceptance checks in sandboxes, line comments and review verdicts | 69 | /// The payload of `pull.opened`, `pull.ready`, `pull.updated` (its head |
| 70 | /// moved), `pull.closed` and `pull.merged`; each uses the fields that apply to it. | |
| Work service in Rust, with RFC 3339 timestamps | 71 | #[derive(Debug, Default, Serialize)] |
| 72 | #[serde(rename_all = "camelCase")] | |
| Issues and pull requests replace intents and attempts | 73 | pub struct PullEvent { |
| 74 | pub pull_id: String, | |
| Work service in Rust, with RFC 3339 timestamps | 75 | pub repo_id: String, |
| Issues and pull requests replace intents and attempts | 76 | pub number: u32, |
| 77 | /// The number of the issue it is for. | |
| 78 | #[serde(skip_serializing_if = "Option::is_none")] | |
| 79 | pub issue: Option<u32>, | |
| Work service in Rust, with RFC 3339 timestamps | 80 | #[serde(skip_serializing_if = "Option::is_none")] |
| 81 | pub agent: Option<String>, | |
| Issues and pull requests replace intents and attempts | 82 | /// On merge: the commit the branch now points to. |
| Work service in Rust, with RFC 3339 timestamps | 83 | #[serde(skip_serializing_if = "Option::is_none")] |
| Issues and pull requests replace intents and attempts | 84 | pub commit: Option<String>, |
| 85 | /// On close: the pull request that was merged instead. | |
| Work service in Rust, with RFC 3339 timestamps | 86 | #[serde(skip_serializing_if = "Option::is_none")] |
| Issues and pull requests replace intents and attempts | 87 | pub superseded_by: Option<u32>, |
| Work service in Rust, with RFC 3339 timestamps | 88 | } |
| 89 | ||
| Acceptance checks in sandboxes, line comments and review verdicts | 90 | /// `checks.completed`: a run of an issue's acceptance checks against a pull |
| 91 | /// request finished. | |
| 92 | #[derive(Debug, Serialize)] | |
| 93 | #[serde(rename_all = "camelCase")] | |
| 94 | pub struct ChecksEvent { | |
| 95 | pub pull_id: String, | |
| 96 | pub repo_id: String, | |
| 97 | pub number: u32, | |
| 98 | /// `passed`, `failed` or `errored`. | |
| 99 | pub status: &'static str, | |
| 100 | /// The commit that was checked. | |
| 101 | pub commit: String, | |
| 102 | } | |
| 103 | ||
| Issues and pull requests replace intents and attempts | 104 | /// `comment.created`. `number` is the issue or pull request commented on. |
| Work service in Rust, with RFC 3339 timestamps | 105 | #[derive(Debug, Serialize)] |
| 106 | #[serde(rename_all = "camelCase")] | |
| Issues and pull requests replace intents and attempts | 107 | pub struct CommentCreated { |
| 108 | pub comment_id: String, | |
| 109 | pub repo_id: String, | |
| 110 | pub number: u32, | |
| 111 | } | |
| 112 | ||
| 113 | #[derive(Debug, Serialize)] | |
| 114 | #[serde(rename_all = "camelCase")] | |
| Work service in Rust, with RFC 3339 timestamps | 115 | pub struct SessionAppended { |
| Issues and pull requests replace intents and attempts | 116 | pub pull_id: String, |
| 117 | pub repo_id: String, | |
| 118 | pub number: u32, | |
| Work service in Rust, with RFC 3339 timestamps | 119 | pub count: u32, |
| 120 | } | |
| 121 | ||
| Events service in Rust, with RFC 3339 times and accurate push events | 122 | /// An event as stored in the log and delivered to subscribers. `data` is |
| 123 | /// left as JSON; each reader decodes the types it cares about. | |
| 124 | #[derive(Clone, Debug, Serialize, serde::Deserialize)] | |
| 125 | #[serde(rename_all = "camelCase")] | |
| 126 | pub struct Event { | |
| 127 | /// Sorts by the time the event was published. | |
| 128 | pub id: String, | |
| 129 | #[serde(rename = "type")] | |
| 130 | pub kind: String, | |
| 131 | /// The service that published it. | |
| 132 | pub source: String, | |
| 133 | /// RFC 3339. | |
| 134 | pub time: String, | |
| 135 | /// The repo the event concerns. | |
| 136 | pub repo_id: Option<String>, | |
| 137 | /// The user or agent that caused it, if any. | |
| 138 | pub actor: Option<String>, | |
| 139 | pub data: serde_json::Value, | |
| 140 | } | |
| 141 | ||
| 142 | /// `publish`, as a publisher sends it. Returns nothing. | |
| 143 | #[derive(Debug, Serialize)] | |
| 144 | pub struct Publish<T: Serialize> { | |
| 145 | pub events: Vec<NewEvent<T>>, | |
| 146 | } | |
| 147 | ||
| 148 | /// `publish`, as the events service reads it. | |
| 149 | #[derive(Debug, serde::Deserialize)] | |
| 150 | pub struct PublishArgs { | |
| 151 | pub events: Vec<Published>, | |
| 152 | } | |
| 153 | ||
| 154 | /// A [`NewEvent`] of any type, as received. | |
| Work service in Rust, with RFC 3339 timestamps | 155 | #[derive(Debug, serde::Deserialize)] |
| 156 | #[serde(rename_all = "camelCase")] | |
| Events service in Rust, with RFC 3339 times and accurate push events | 157 | pub struct Published { |
| Work service in Rust, with RFC 3339 timestamps | 158 | #[serde(rename = "type")] |
| 159 | pub kind: String, | |
| Events service in Rust, with RFC 3339 times and accurate push events | 160 | pub source: String, |
| 161 | #[serde(default)] | |
| Work service in Rust, with RFC 3339 timestamps | 162 | pub repo_id: Option<String>, |
| Events service in Rust, with RFC 3339 times and accurate push events | 163 | #[serde(default)] |
| 164 | pub actor: Option<String>, | |
| Work service in Rust, with RFC 3339 timestamps | 165 | pub data: serde_json::Value, |
| 166 | } | |
| Events service in Rust, with RFC 3339 times and accurate push events | 167 | |
| 168 | /// `list`: events from the log, newest first. Returns `Vec<Event>`. | |
| 169 | #[derive(Debug, Default, Serialize, serde::Deserialize)] | |
| 170 | #[serde(rename_all = "camelCase")] | |
| 171 | pub struct ListArgs { | |
| 172 | #[serde(default)] | |
| 173 | pub repo_id: Option<String>, | |
| 174 | /// Only these types; all types when empty. | |
| 175 | #[serde(default)] | |
| 176 | pub types: Vec<String>, | |
| 177 | /// Only events older than this event id. | |
| 178 | #[serde(default)] | |
| 179 | pub before: Option<String>, | |
| 180 | #[serde(default)] | |
| 181 | pub limit: Option<u32>, | |
| 182 | } |