Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor or add typed event payloads #27

Open
sirewix opened this issue Oct 2, 2024 · 1 comment · May be fixed by #31
Open

Refactor or add typed event payloads #27

sirewix opened this issue Oct 2, 2024 · 1 comment · May be fixed by #31
Assignees
Labels
enhancement New feature or request good first issue Good for newcomers tech debt Work on this should be planned according to tech debt policy

Comments

@sirewix
Copy link
Contributor

sirewix commented Oct 2, 2024

Currently events are returned as a generic struct with payload as BTreeMap<String, Value>:

pub struct Event {
/// The sequence number of the event.
pub sequence: u64,
/// Creation date of the event.
pub creation_date: OffsetDateTime,
/// Event type.
pub r#type: String,
/// The object that was modified.
pub aggregate: Option<Aggregate>,
/// The editor that caused the event.
pub editor: Option<Editor>,
/// Payload of the event, hold arbitrary data correspondent to the event
/// type.
pub payload: BTreeMap<String, Value>,
}

Since zitadel events set is fixed, it would be much convenient for dependent crates to get some enum payload directly rather than implementing parsing it themselves:

enum EventPayload {
  UserChanged(UserChanged),
  ...
}

struct UserChanged {
  first_name: String,
  last_name: String,
  display_name: String,
}
@sirewix sirewix added enhancement New feature or request good first issue Good for newcomers labels Oct 2, 2024
@emgrav emgrav added the tech debt Work on this should be planned according to tech debt policy label Oct 4, 2024
@sirewix
Copy link
Contributor Author

sirewix commented Oct 8, 2024

Since there's no documentation on event payload types zitadel/zitadel#8651 and the total number of events is quite high (> 504) I tried semiautomated solution to extract the types from the source code. But due to how zitadel code is structured it's not an easy task

@sirewix sirewix linked a pull request Oct 8, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers tech debt Work on this should be planned according to tech debt policy
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants