Skip to main content

Services CLI Commands

Manage services in your EventCatalog from the command line.

getService​

Returns a service from EventCatalog by its ID

Arguments:

NameTypeRequiredDescription
idstringYesThe ID of the service to retrieve
versionstringNoSpecific version to retrieve

Examples:

# Get the latest service
npx @eventcatalog/sdk getService "OrderService"

# Get a specific version
npx @eventcatalog/sdk getService "OrderService" "1.0.0"

getServices​

Returns all services from EventCatalog

Arguments:

NameTypeRequiredDescription
optionsjsonNoOptions: {latestOnly?}

Examples:

# Get all services
npx @eventcatalog/sdk getServices

writeService​

Writes a service to EventCatalog

Arguments:

NameTypeRequiredDescription
servicejsonYesService object with id, name, version, and markdown
optionsjsonNoOptions: {path?, override?, versionExistingContent?}

writeServiceToDomain​

Writes a service to a specific domain

Arguments:

NameTypeRequiredDescription
servicejsonYesService object
domainjsonYesDomain reference: {id, version?}
optionsjsonNoOptions

rmService​

Removes a service by its path

Arguments:

NameTypeRequiredDescription
pathstringYesPath to the service

Examples:

# Remove a service
npx @eventcatalog/sdk rmService "/OrderService"

rmServiceById​

Removes a service by its ID

Arguments:

NameTypeRequiredDescription
idstringYesThe ID of the service to remove
versionstringNoSpecific version to remove

Examples:

# Remove a service
npx @eventcatalog/sdk rmServiceById "OrderService"

versionService​

Moves the current service to a versioned directory

Arguments:

NameTypeRequiredDescription
idstringYesThe ID of the service to version

Examples:

# Version a service
npx @eventcatalog/sdk versionService "OrderService"

addFileToService​

Adds a file to a service

Arguments:

NameTypeRequiredDescription
idstringYesThe ID of the service
filejsonYesFile object: {content, fileName}
versionstringNoSpecific version

addEventToService​

Adds an event relationship to a service

Arguments:

NameTypeRequiredDescription
serviceIdstringYesThe ID of the service
directionstringYesDirection: "sends" or "receives"
eventjsonYesEvent reference: {id, version}
serviceVersionstringNoSpecific service version

addCommandToService​

Adds a command relationship to a service

Arguments:

NameTypeRequiredDescription
serviceIdstringYesThe ID of the service
directionstringYesDirection: "sends" or "receives"
commandjsonYesCommand reference: {id, version}
serviceVersionstringNoSpecific service version

addQueryToService​

Adds a query relationship to a service

Arguments:

NameTypeRequiredDescription
serviceIdstringYesThe ID of the service
directionstringYesDirection: "sends" or "receives"
queryjsonYesQuery reference: {id, version}
serviceVersionstringNoSpecific service version

addEntityToService​

Adds an entity to a service

Arguments:

NameTypeRequiredDescription
serviceIdstringYesThe ID of the service
entityjsonYesEntity reference: {id, version}
serviceVersionstringNoSpecific service version

addDataStoreToService​

Adds a data store relationship to a service

Arguments:

NameTypeRequiredDescription
serviceIdstringYesThe ID of the service
relationshipstringYesRelationship: "writesTo" or "readsFrom"
dataStorejsonYesData store reference: {id, version}
serviceVersionstringNoSpecific service version

serviceHasVersion​

Checks if a specific version of a service exists

Arguments:

NameTypeRequiredDescription
idstringYesThe ID of the service
versionstringYesVersion to check

Examples:

# Check if version exists
npx @eventcatalog/sdk serviceHasVersion "OrderService" "1.0.0"

getSpecificationFilesForService​

Returns specification files (OpenAPI, AsyncAPI) for a service

Arguments:

NameTypeRequiredDescription
idstringYesThe ID of the service
versionstringNoSpecific version

Examples:

# Get spec files
npx @eventcatalog/sdk getSpecificationFilesForService "OrderService"