Skip to content

ManagementClient

API reference for ManagementClient

@delta-base/server


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

new ManagementClient(http): ManagementClient

Creates a new ManagementClient instance.

HttpClient

The HTTP client to use for API requests

ManagementClient

createEventStore(options): Promise<EventStoreInfo>

Creates a new event store in the DeltaBase platform.

CreateEventStoreOptions

Configuration for the new event store

Promise<EventStoreInfo>

Promise resolving to the created event store information

When an event store with the same name exists

When request validation fails

When authentication fails

When the server encounters an error

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(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.

string

ID of the event store to delete

Promise<void>

Promise that resolves when the deletion is complete

// Delete an event store
await managementClient.deleteEventStore('es_12345');

getEventStore(eventStoreId): Promise<EventStoreDetailsResponse>

Retrieves detailed information about a specific event store.

string

ID of the event store to retrieve

Promise<EventStoreDetailsResponse>

Promise resolving to detailed information about the event store

// Get details for a specific event store
const eventStore = await managementClient.getEventStore('es_12345');
// Access statistics
if (eventStore.statistics) {
console.log(`Total events: ${eventStore.statistics.totalEvents}`);
console.log(`Storage used: ${eventStore.statistics.databaseSizeBytes} bytes`);
}

listEventStores(): Promise<EventStoreListResponse>

Retrieves a list of all event stores accessible to the current user.

Promise<EventStoreListResponse>

Promise resolving to a list of event stores and total count

// Get all available event stores
const { eventStores, totalCount } = await managementClient.listEventStores();
// Display event store names
eventStores.forEach(store => {
console.log(`${store.name} (${store.id}): ${store.status}`);
});

updateEventStore(eventStoreId, settings): Promise<EventStoreInfo>

Updates settings for an existing event store.

string

ID of the event store to update

New settings for the event store

string

Optional new description for the event store

number

Optional new maximum stream size in bytes

number

Optional new retention period in days

Promise<EventStoreInfo>

Promise resolving to the updated event store information

// Update event store description
const updated = await managementClient.updateEventStore('es_12345', {
description: 'Updated description for this event store'
});
// Update event store retention settings
const updated = await managementClient.updateEventStore('es_12345', {
retentionPeriodDays: 180, // Keep events for 6 months
maxStreamSizeBytes: 536870912 // 512MB per stream
});