feat: update aggregate implementation

This commit is contained in:
2025-08-11 13:34:28 +02:00
parent 9dddc4e79f
commit cc8c558db6
37 changed files with 361 additions and 511 deletions

View File

@@ -6,8 +6,7 @@ import { afterAll, describe } from "@std/testing/bdd";
import { BrowserAdapter } from "../adapters/browser/adapter.ts";
import { EventStore, EventStoreHooks } from "../libraries/event-store.ts";
import { Projector } from "../libraries/projector.ts";
import { aggregates } from "./mocks/aggregates.ts";
import { events, EventStoreFactory } from "./mocks/events.ts";
import { Events, events } from "./mocks/events.ts";
import testAddEvent from "./store/add-event.ts";
import testCreateSnapshot from "./store/create-snapshot.ts";
import testMakeAggregateReducer from "./store/make-aggregate-reducer.ts";
@@ -18,7 +17,7 @@ import testPushManyAggregates from "./store/push-many-aggregates.ts";
import testReduce from "./store/reduce.ts";
import testReplayEvents from "./store/replay-events.ts";
const eventStoreFn = async (options: { hooks?: EventStoreHooks<EventStoreFactory> } = {}) => getEventStore(options);
const eventStoreFn = async (options: { hooks?: EventStoreHooks<Events> } = {}) => getEventStore(options);
/*
|--------------------------------------------------------------------------------
@@ -44,7 +43,6 @@ describe("Adapter > Browser (IndexedDb)", () => {
testReplayEvents(eventStoreFn);
testReduce(eventStoreFn);
testOnceProjection(eventStoreFn);
testPushAggregate(eventStoreFn);
testPushManyAggregates(eventStoreFn);
});
@@ -55,15 +53,14 @@ describe("Adapter > Browser (IndexedDb)", () => {
|--------------------------------------------------------------------------------
*/
function getEventStore({ hooks = {} }: { hooks?: EventStoreHooks<EventStoreFactory> }) {
function getEventStore({ hooks = {} }: { hooks?: EventStoreHooks<Events> }) {
const store = new EventStore({
adapter: new BrowserAdapter("indexeddb"),
events,
aggregates,
hooks,
});
const projector = new Projector<EventStoreFactory>();
const projector = new Projector<Events>();
if (hooks.onEventsInserted === undefined) {
store.onEventsInserted(async (records, { batch }) => {