famedly / zitadel-rust-client

GNU Affero General Public License v3.0
0 stars 1 forks source link

Refactor or add typed event payloads #27

Open sirewix opened 1 month ago

sirewix commented 1 month ago

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

https://github.com/famedly/zitadel-rust-client/blob/e333bd42a4c3d6f5897819c061569818e4caf2f7/src/v1/types.rs#L14-L28

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 commented 1 month ago

Since there's no documentation on event payload types https://github.com/zitadel/zitadel/discussions/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