@schemeless/event-store-types 2.9.0 → 2.10.0
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.
- package/dist/Errors.d.ts +6 -0
- package/dist/Errors.js +13 -0
- package/dist/Repo.types.d.ts +15 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/package.json +2 -2
package/dist/Errors.d.ts
ADDED
package/dist/Errors.js
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ConcurrencyError = void 0;
|
|
4
|
+
class ConcurrencyError extends Error {
|
|
5
|
+
constructor(streamKey, expectedSequence, actualSequence) {
|
|
6
|
+
super(`Concurrency conflict on stream "${streamKey}": expected sequence ${expectedSequence}, but found ${actualSequence}`);
|
|
7
|
+
this.streamKey = streamKey;
|
|
8
|
+
this.expectedSequence = expectedSequence;
|
|
9
|
+
this.actualSequence = actualSequence;
|
|
10
|
+
this.name = 'ConcurrencyError';
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
exports.ConcurrencyError = ConcurrencyError;
|
package/dist/Repo.types.d.ts
CHANGED
|
@@ -8,14 +8,28 @@ export interface IEventStoreEntity<PAYLOAD = any, META = any> {
|
|
|
8
8
|
identifier?: string;
|
|
9
9
|
correlationId?: string;
|
|
10
10
|
causationId?: string;
|
|
11
|
+
sequence?: number;
|
|
11
12
|
readonly created: Date;
|
|
12
13
|
}
|
|
14
|
+
export interface StoreEventsOptions {
|
|
15
|
+
/**
|
|
16
|
+
* Expected sequence number for the stream (domain + identifier).
|
|
17
|
+
* If provided, the store will verify the current sequence matches
|
|
18
|
+
* before writing. Throws ConcurrencyError on mismatch.
|
|
19
|
+
*/
|
|
20
|
+
expectedSequence?: number;
|
|
21
|
+
}
|
|
13
22
|
export interface IEventStoreRepo<PAYLOAD = any, META = any> {
|
|
14
23
|
init: () => Promise<void>;
|
|
15
24
|
getAllEvents: (pageSize: number, startFromId?: string) => Promise<AsyncIterableIterator<Array<IEventStoreEntity<PAYLOAD, META>>>>;
|
|
16
25
|
createEventEntity: (event: CreatedEvent<any>) => IEventStoreEntity<PAYLOAD, META>;
|
|
17
|
-
storeEvents: (events: CreatedEvent<any>[]) => Promise<void>;
|
|
26
|
+
storeEvents: (events: CreatedEvent<any>[], options?: StoreEventsOptions) => Promise<void>;
|
|
18
27
|
resetStore: () => Promise<void>;
|
|
28
|
+
/**
|
|
29
|
+
* Get the current sequence number for a stream.
|
|
30
|
+
* Returns 0 if no events exist for this stream.
|
|
31
|
+
*/
|
|
32
|
+
getStreamSequence?: (domain: string, identifier: string) => Promise<number>;
|
|
19
33
|
/**
|
|
20
34
|
* Retrieves a single event by its ID.
|
|
21
35
|
* Required for revert operations.
|
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@schemeless/event-store-types",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.10.0",
|
|
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": "
|
|
37
|
+
"gitHead": "396c3bfbe61bb81b93f0d3d0686388ed3d80a594"
|
|
38
38
|
}
|