@schemeless/event-store-types 2.11.0 → 3.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -19,12 +19,44 @@ export interface StoreEventsOptions {
19
19
  */
20
20
  expectedSequence?: number;
21
21
  }
22
+ export interface ISnapshotEntity<STATE = any> {
23
+ domain: string;
24
+ identifier: string;
25
+ state: STATE;
26
+ sequence: number;
27
+ created: Date;
28
+ }
29
+ export interface IEventStoreRepoCapabilities {
30
+ /**
31
+ * Supports aggregate reconstruction through eventStore.getAggregate().
32
+ * Requires getStreamEvents(domain, identifier, fromSequence).
33
+ */
34
+ aggregate?: boolean;
35
+ }
22
36
  export interface IEventStoreRepo<PAYLOAD = any, META = any> {
23
37
  init: () => Promise<void>;
24
38
  getAllEvents: (pageSize: number, startFromId?: string) => Promise<AsyncIterableIterator<Array<IEventStoreEntity<PAYLOAD, META>>>>;
25
39
  createEventEntity: (event: CreatedEvent<any>) => IEventStoreEntity<PAYLOAD, META>;
26
40
  storeEvents: (events: CreatedEvent<any>[], options?: StoreEventsOptions) => Promise<void>;
27
41
  resetStore: () => Promise<void>;
42
+ /**
43
+ * Optional explicit capability declaration.
44
+ * If omitted, runtime infers support from implemented methods for backwards compatibility.
45
+ */
46
+ capabilities?: IEventStoreRepoCapabilities;
47
+ /**
48
+ * Get events for a specific stream (domain + identifier).
49
+ * MUST use efficient index-based query (e.g., DynamoDB Query, SQL WHERE).
50
+ * Required for getAggregate to work.
51
+ *
52
+ * @param domain - Event domain
53
+ * @param identifier - Stream identifier
54
+ * @param fromSequence - Start from this sequence (exclusive), 0 = from beginning
55
+ * @returns Events ordered by sequence ascending
56
+ */
57
+ getStreamEvents?: (domain: string, identifier: string, fromSequence?: number) => Promise<IEventStoreEntity<PAYLOAD, META>[]>;
58
+ getSnapshot?: <STATE>(domain: string, identifier: string) => Promise<ISnapshotEntity<STATE> | null>;
59
+ saveSnapshot?: <STATE>(snapshot: ISnapshotEntity<STATE>) => Promise<void>;
28
60
  /**
29
61
  * Get the current sequence number for a stream.
30
62
  * Returns 0 if no events exist for this stream.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@schemeless/event-store-types",
3
- "version": "2.11.0",
3
+ "version": "3.0.1",
4
4
  "typescript:main": "src/index.ts",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -34,5 +34,5 @@
34
34
  "publishConfig": {
35
35
  "access": "public"
36
36
  },
37
- "gitHead": "299af18aa23f86c614fd38174e5c9ff54d1e3d69"
37
+ "gitHead": "705cba8aea97c2380dc986e20c170715f3bf430c"
38
38
  }