Skip to main content

Packages

🎯 Test Tools

The official test tools package facilitates the writing of unit tests: It allows mocking event stores, populating them with an initial state and resetting them to it in a boilerplate-free and type-safe way:

import { mockEventStore } from '@castore/lib-test-tools';

describe('My awesome test', () => {
const mockedPokemonsEventStore = mockEventStore(pokemonsEventStore, [
// 👇 Provide initial state (list of event details) in a type-safe way
{
aggregateId: 'pikachu1',
version: 1,
type: 'POKEMON_APPEARED',
...
},
]);

beforeEach(() => {
// 👇 Reset to initial state
mockedPokemonsEventStore.reset();
});
});

🌊 Dam

Dam is a suite of utils that facilitates data migration and maintenance operations with Castore (for instance, dispatching all the events of an event store - ordered by their timestamps - to a message queue):

import { pourEventStoreEvents } from '@castore/lib-dam';

const maintenanceMessageQueue = new NotificationMessageQueue({
sourceEventStores: [pokemonEventStore],
...
});

await pourEventStoreEvents({
eventStore: pokemonEventStore,
messageChannel: maintenanceMessageQueue,
// 👇 Optional `timestamp` filters
filters: {
from: '2020-01-01T00:00:00.000Z',
to: '2023-01-01T00:00:00.000Z',
},
// 👇 Optional rate limit (messages/second)
rateLimit: 100,
});

🌈 React Visualizer

The React Visualizer package exposes a React component to visualize, design and manually test Castore event stores and commands.

Here is a hosted example, based on this documentation code snippets about pokemons and trainers. You can find the related source code (commands & event stores) in the demo package.

📅 Event Types

To add run-time validation to your event types:

💾 Event Storage Adapters

🏋️‍♂️ Commands

To add run-time validation to your commands:

📨 Message Queue Adapters

🚌 Message Buses Adapters