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:
- JSON Schema Event Type: DRY
EventType
definition using JSON Schemas andjson-schema-to-ts
- Zod Event Type: DRY
EventType
definition usingzod
💾 Event Storage Adapters
- DynamoDB Event Storage Adapter: Implementation of the
EventStorageAdapter
interface based on DynamoDB. - Redux Event Storage Adapter: Implementation of the
EventStorageAdapter
interface based on a Redux store, along with tooling to configure the store and hooks to read from it efficiently. - In-Memory Event Storage Adapter: Implementation of the
EventStorageAdapter
interface using a local Node/JS object. To be used in manual or unit tests.
🏋️♂️ Commands
To add run-time validation to your commands:
- JSON Schema Command: DRY
Command
definition using JSON Schemas andjson-schema-to-ts
- Zod Command: DRY
Command
definition usingzod
📨 Message Queue Adapters
- SQS Message Queue Adapter: Implementation of the
MessageQueueAdapter
interface based on AWS SQS. - SQS + S3 Message Queue Adapter: Implementation of the
MessageQueueAdapter
interface based on AWS SQS and S3. - In-Memory Message Queue Adapter: Implementation of the
MessageQueueAdapter
interface using a local Node/JS queue. To be used in manual or unit tests.
🚌 Message Buses Adapters
- EventBridge Message Bus Adapter: Implementation of the
MessageBusAdapter
interface based on AWS EventBridge. - EventBridge + S3 Message Bus Adapter: Implementation of the
MessageBusAdapter
interface based on AWS EventBridge and S3. - In-Memory Message Bus Adapter: Implementation of the
MessageBusAdapter
interface using a local Node/JS event emitter. To be used in manual or unit tests.