Inspect with the CLI
The CLI can read everything the management UI shows and push events, so you can look at a running system without writing code. Every command takes -o json for scripts.
Point it at a server once:
export IWENTSOURCING_HOST=http://localhost:3333 # default is https://api.iwentsourcing.com
export IWENTSOURCING_TENANT=dev # default is iwentsourcingTwo kinds of login
There are two kinds of accounts, and the CLI needs the right one for the job.
| Login | Created with | Used for |
|---|---|---|
| Developer (the platform's directory) | aion register iwentsourcing | tenant, realm, upload, and listing instances. Works for every tenant. |
| A user of your realm | aion login <provider> --realm <realm> | Reading the events and state of a stream, and pushing events. Each realm issues its own tokens. |
A stream's events and state belong to its users, so the developer login can list that a stream exists but not read inside it. Sign in to the realm to do that. In the quickstart that is:
npx aion login custom --realm todo --username ada --password lovelace-secretaion whoami --realm todo shows which login is stored for a realm.
Tenants and realms
aion tenant list
aion tenant create acme
aion realm list
aion realm show todorealm show lists the stream and aggregation patterns of a realm with their versions, and the auth providers it accepts.
Stream instances
aion stream list --realm todoEach row is one instance: the realm, the pattern, its name (for personal-$(auth.sub) that is personal- plus the user) and the version of the definition that serves it. The next commands take <realm> <pattern> <name> from that row.
# the events, oldest first
aion stream events todo 'personal-$(auth.sub)' personal-ada
# the states a stream declares, then the rows of one
aion stream state todo 'personal-$(auth.sub)' personal-ada
aion stream state todo 'personal-$(auth.sub)' personal-ada todos
# push an event
aion stream push todo 'personal-$(auth.sub)' personal-ada create-todo --data '{"title":"Walk the dog"}'stream events takes --since <date> and -n <count>. stream push waits until the event is handled and fails with the handler's error when it is rejected, so a typo in the payload shows up right there. Pass --id to make a push idempotent: pushing the same id twice stores one event.
Aggregations
aion aggregation list
aion aggregation state <realm> <pattern> <name> [state]Scripts
-o json prints one JSON document and nothing else on stdout:
aion stream state todo 'personal-$(auth.sub)' personal-ada todos -o json | jq '.[].title'Every command that lists is paged: --take is the number of rows (50 by default, 1000 at most) and --skip how many to leave out. The table says when more rows follow and which --skip continues. In JSON a page is a plain array, so a script keeps asking with --skip increased by --take until it gets fewer rows than it asked for.
The full list of options is in the CLI reference.