Creating Elements
Information
Call functions in d.info to create information.
In practice, you don't always need to explicitly call functions. All nodes accept plain strings as parameters, so only use these functions when you need special annotation
id
Typically represents an aggregate id
const bookId = d.info.id('bookId', 'Book ID note')valueObj
Ordinary values without special meaning
const bookName = d.info.valueObj('name', 'Book Name')document
Experimental Feature
This is an experimental feature. Its business semantic necessity and universality are uncertain. Feedback is welcome.
Represents a document or binary file value
d.info.document('networkPacket', 'Network packet')func
Experimental Feature
This is an experimental feature. Its business semantic necessity and universality are uncertain. Feedback is welcome.
Represents a value that needs to be calculated by a function
const bookValues = {
bookPrice: i.valueObj('price', 'Book price'),
}
const orderValues = {
quantity: i.valueObj('quantity', 'Order quantity'),
}
d.func(
'FinalPrice',
[bookValues.bookPrice, orderValues.quantity],
`Final price = Book price * Order quantity`
),version
Experimental Feature
This is an experimental feature. Its business semantic necessity and universality are uncertain. Feedback is welcome.
Represents a value with business meaning indicating version
d.info.version(
'wikiEntryVersion',
`Wiki entry version number.
Although version numbers might just be optimistic locking fields to technicians, they have concrete business meaning in "wiki entries"`
)Nodes
Each node corresponds to a node in event storming
actor
d.actor('Administrator')facadeCmd
d.facadeCmd(
'CreateUserFacadeCmd',
['userName', 'email', ['gender', 'Gender']],
'Create user facade command'
)Equivalent to
d.command(
'CreateUserFacadeCmd',
[
d.info.valueObj('userName'),
d.info.valueObj('email'),
d.info.valueObj('gender', 'Gender'),
],
'Create user facade command'
)command
d.command(
'CreateUserCmd',
['userName', 'email', ['gender', 'Gender']],
'Create user command'
)Equivalent to
d.command(
'CreateUserCmd',
[
d.info.valueObj('userName'),
d.info.valueObj('email'),
d.info.valueObj('gender', 'Gender'),
],
'Create user command'
)agg
d.agg(
'OrderAgg',
[d.info.id('orderId'), 'orderItems', ['orderStatus', 'Order status']],
'Order aggregate'
)Equivalent to
d.agg(
'OrderAgg',
[
d.info.id('orderId'),
d.info.valueObject('orderItems'),
d.info.valueObject('orderStatus', 'Order status'),
],
'Order aggregate'
)event
d.event(
'OrderPlaced',
[d.info.id('orderSequence', 'Order serial number'), 'orderItems'],
'Order placed'
)Equivalent to
d.event(
'OrderPlaced',
[d.info.id('orderSequence', 'Order serial number'), d.info.valueObject('orderItems')],
'Order placed'
)system
d.system('MailSystem', 'Mail system')service
d.service('PaymentService', 'Payment service')policy
d.policy(
'PaymentPolicy',
`Payment rules
1. xxx
2. xxx
...`
)readModel
d.readModel(
'OrderDetailReadModel',
[d.info.id('orderId'), ['orderTime', 'Order time']],
'Order detail read model'
)Equivalent to
d.readModel(
'OrderDetailReadModel',
[d.info.id('orderId'), d.info.valueObj('orderTime', 'Order time')],
'Order detail read model'
)Notes
Usually the last parameter of a function is an optional note. For less complex requirements, just passing strings is enough. But we can also choose to pass notes containing variable references generated by the note function.
For example:
const i = d.info
// "Authorization system" needs multi-line, clear notes, so use TS template strings
const AuthorizationSystem = d.system(
'AuthorizationSystem',
`Authorization system
Has the following responsibilities:
1. Authentication
2. Authorization
3. Permission granting
...`
)
// "User recharged" doesn't need special notes, so pass a plain string
const UserRecharged = d.event('UserRecharged', [i.id('userId')], 'User recharged')
// "User status" is related to the authorization system, so use the note function
const UserStatus = d.info.valueObject(
'userStatus',
d.note`User status
User status is not maintained by this system but synchronized from ${AuthorizationSystem}`
)