#schema #codegen #event-sourcing #cqrs #esdl

esdl

Event-sourcing Schema Definition Language parser and code generator

5 releases (3 breaking)

Uses new Rust 2021

0.4.0 Jan 30, 2022
0.3.0 Jan 28, 2022
0.2.1 Jan 27, 2022
0.2.0 Jan 25, 2022
0.1.0 Jan 24, 2022

#84 in Build Utils

Download history 3/week @ 2022-03-09 24/week @ 2022-03-16 14/week @ 2022-03-23 4/week @ 2022-03-30 10/week @ 2022-04-06 2/week @ 2022-04-13 10/week @ 2022-04-20 27/week @ 2022-04-27 29/week @ 2022-05-04 93/week @ 2022-05-11 27/week @ 2022-05-18 33/week @ 2022-05-25 47/week @ 2022-06-01 14/week @ 2022-06-08 5/week @ 2022-06-15 12/week @ 2022-06-22

79 downloads per month

MIT/Apache

65KB
1.5K SLoC

ESDL

Event-sourcing Schema Definition Language


Schema definition language for defining aggregates, commands, events & custom types.

Heavily inspired by GraphQL syntax, you can describe aggregates which can be used for codegen in different languages.

Code generation

ESDL schemas can be used for code generation.

The Rust crate currently supports code generation for:

Additional languages may be added in the future. Contributions are welcome!

Example

aggregate BankAccount {
  open_account(initial_balance: Float!) OpenedAccount!
  deposit_funds(amount: Float!): ReceivedFunds!
  withdraw_funds(amount: Float!): SentFunds!
  transact(amount: Float!, user: User!) (SentFunds | ReceivedFunds)
}

event OpenedAccount {
  initial_balance: Float!
}

event SentFunds {
  amount: Float!
  user: User
}

event ReceivedFunds {
  amount: Float!
  user: User
}

type User {
  id: String!
  name: String
}

Scalar Types

Scalar Rust Type TypeScript Type
String String string
Int i64 number
Float f64 number
Bool bool boolean
Timestamp DateTime<FixedOffset> Date

Optional & Required

Types can be marked as required by adding the ! suffix.

Type Syntax Example
Optional T String
Required T! String!

Repeating Types

Types can be repeated by wrapping them in [].

Type Syntax Example
Single T String
Array [T] [String]

Remember, we can mark types as required, even in arrays.

Type Syntax Example
Optional Array [T] [String]
Required Array [T]! [String]!
Required Array Items [T!] [String!]
Required Array Items [T!]! [String!]!

Integrates with Thalo to generate Rust code.

Dependencies

~1.4–2.1MB
~42K SLoC