ManagementClient
API reference for ManagementClient
Class: ManagementClient
Section titled “Class: ManagementClient”Management client for creating and managing event stores.
Provides operations for the lifecycle of event stores including:
- Creating new event stores
- Listing available event stores
- Getting details about specific event stores
- Updating event store settings
- Deleting event stores
Constructors
Section titled “Constructors”Constructor
Section titled “Constructor”new ManagementClient(
http
):ManagementClient
Creates a new ManagementClient instance.
Parameters
Section titled “Parameters”The HTTP client to use for API requests
Returns
Section titled “Returns”ManagementClient
Methods
Section titled “Methods”createEventStore()
Section titled “createEventStore()”createEventStore(
options
):Promise
<EventStoreInfo
>
Creates a new event store in the DeltaBase platform.
Parameters
Section titled “Parameters”options
Section titled “options”Configuration for the new event store
Returns
Section titled “Returns”Promise
<EventStoreInfo
>
Promise resolving to the created event store information
Throws
Section titled “Throws”When an event store with the same name exists
Throws
Section titled “Throws”When request validation fails
Throws
Section titled “Throws”When authentication fails
Throws
Section titled “Throws”When the server encounters an error
Example
Section titled “Example”import { isEventStoreAlreadyExistsError, isValidationError} from '@delta-base/server';
try { const eventStore = await managementClient.createEventStore({ name: 'orders-production', description: 'Production event store for order events', settings: { retentionPeriodDays: 90, maxStreamSizeBytes: 1073741824 // 1GB } });} catch (error) { if (isEventStoreAlreadyExistsError(error)) { console.log(`Event store '${error.name}' already exists`); // Handle existing event store } else if (isValidationError(error)) { console.log('Validation errors:', error.validationErrors); // Handle validation failures } else { throw error; // Re-throw unknown errors }}
deleteEventStore()
Section titled “deleteEventStore()”deleteEventStore(
eventStoreId
):Promise
<void
>
Permanently deletes an event store and all its data.
This operation cannot be undone. All event streams, events, and subscriptions associated with this event store will be deleted.
Parameters
Section titled “Parameters”eventStoreId
Section titled “eventStoreId”string
ID of the event store to delete
Returns
Section titled “Returns”Promise
<void
>
Promise that resolves when the deletion is complete
Example
Section titled “Example”// Delete an event storeawait managementClient.deleteEventStore('es_12345');
getEventStore()
Section titled “getEventStore()”getEventStore(
eventStoreId
):Promise
<EventStoreDetailsResponse
>
Retrieves detailed information about a specific event store.
Parameters
Section titled “Parameters”eventStoreId
Section titled “eventStoreId”string
ID of the event store to retrieve
Returns
Section titled “Returns”Promise
<EventStoreDetailsResponse
>
Promise resolving to detailed information about the event store
Example
Section titled “Example”// Get details for a specific event storeconst eventStore = await managementClient.getEventStore('es_12345');
// Access statisticsif (eventStore.statistics) { console.log(`Total events: ${eventStore.statistics.totalEvents}`); console.log(`Storage used: ${eventStore.statistics.databaseSizeBytes} bytes`);}
listEventStores()
Section titled “listEventStores()”listEventStores():
Promise
<EventStoreListResponse
>
Retrieves a list of all event stores accessible to the current user.
Returns
Section titled “Returns”Promise
<EventStoreListResponse
>
Promise resolving to a list of event stores and total count
Example
Section titled “Example”// Get all available event storesconst { eventStores, totalCount } = await managementClient.listEventStores();
// Display event store nameseventStores.forEach(store => { console.log(`${store.name} (${store.id}): ${store.status}`);});
updateEventStore()
Section titled “updateEventStore()”updateEventStore(
eventStoreId
,settings
):Promise
<EventStoreInfo
>
Updates settings for an existing event store.
Parameters
Section titled “Parameters”eventStoreId
Section titled “eventStoreId”string
ID of the event store to update
settings
Section titled “settings”New settings for the event store
description?
Section titled “description?”string
Optional new description for the event store
maxStreamSizeBytes?
Section titled “maxStreamSizeBytes?”number
Optional new maximum stream size in bytes
retentionPeriodDays?
Section titled “retentionPeriodDays?”number
Optional new retention period in days
Returns
Section titled “Returns”Promise
<EventStoreInfo
>
Promise resolving to the updated event store information
Example
Section titled “Example”// Update event store descriptionconst updated = await managementClient.updateEventStore('es_12345', { description: 'Updated description for this event store'});
// Update event store retention settingsconst updated = await managementClient.updateEventStore('es_12345', { retentionPeriodDays: 180, // Keep events for 6 months maxStreamSizeBytes: 536870912 // 512MB per stream});