CLI
To install the stately
CLI, follow the Getting Started guide. You can upgrade the CLI to the latest version with stately upgrade
.
The CLI has built-in help (run stately help
), but notable commands are also explained here.
Authentication
stately login
allows you to log in to your Stately account. Once you log in, subsequent commands will use this account until you run stately logout
. Note that there is currently no way to run the CLI using the Client ID and Client Secret of a Service Account.
whoami
stately whoami
prints information about the currently logged in user and all of the resources they have available to them. This is a quick way to get ahold of Store IDs or Schema IDs, which are useful in other commands such as updating schema.
schema
The stately schema
subcommands allow you to create and update schema versions, as well as generating language-specific client code.
bind
Stately Support should have created a Schema with your first Store. To find the list of schemas in your organization, you can use stately whoami
. From there, you can call stately schema bind
to bind the Schema to one of your Stores.
init
stately schema init
sets up a NodeJS package containing your schema definition TypeScript files. The only argument is the directory path you want to create. The directory must not exist already.
generate
stately schema generate
will run your schema TypeScript files and then create code in one of our supported SDK languages that contains typed objects corresponding to the types in your schema. See Generating Client Code for more info on how to use this.
put
stately schema put
publishes a new version of your schema. This will also run your schema TypeScript files. For this to run, you need to have NodeJS installed, and have installed the dependencies for your schema package with npm install
.
The first positional argument is the path to your schema’s index file (you can have schema in as many TypeScript files as you want as long as there’s a single file that exports everything).
stately schema put
will fail if you are making a backwards-incompatible change to your schema. You can add the --allow-backwards-incompatible
argument to override this, but realize you’re taking the validity of your stored data into your own hands at that point. Eventually we will remove the --allow-backwards-incompatible
option when Elastic Schema can handle all types of changes—in the meantime, it is sometimes necessary to override the backwards compatibility check when you know it’s safe.
print
/ validate
stately schema print
and stately schema validate
are very similar. Both run your schema TypeScript files. For this to run, you need to have NodeJS installed, and have installed the dependencies for your schema package with npm install
.
validate
will check to make sure your schema is valid. It will exit with a nonzero exit code if the schema is invalid. This command does not require that you specify a store and it does not check for backwards compatibility with an existing schema.
print
is exactly the same as validate
, except it prints the resolved schema out in a sort of concise, readable format.
item
The stately item
subcommands allow for updating or fetching items from the CLI. We strongly recommend using our SDKs instead, since they let you work with typed objects instead of JSON, but sometimes you just have to write a script.
The operations mirror the StatelyDB APIs: get
, put
, delete
, and list
. The API reference has examples of using the CLI to perform each of these.