@schemeless/event-store-types 2.3.0 → 2.3.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.
- package/jest.config.js +3 -0
- package/package.json +2 -2
- package/readme.md +51 -0
- package/tsconfig.json +5 -1
package/jest.config.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@schemeless/event-store-types",
|
|
3
|
-
"version": "2.3.
|
|
3
|
+
"version": "2.3.1",
|
|
4
4
|
"typescript:main": "src/index.ts",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -32,5 +32,5 @@
|
|
|
32
32
|
"publishConfig": {
|
|
33
33
|
"access": "public"
|
|
34
34
|
},
|
|
35
|
-
"gitHead": "
|
|
35
|
+
"gitHead": "727d39bd2300bb875489fe42a44775e5d4cd774e"
|
|
36
36
|
}
|
package/readme.md
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
# @schemeless/event-store-types
|
|
2
|
+
|
|
3
|
+
Shared TypeScript definitions used by the event store runtime, adapters, and application code. Import these contracts when authoring event flows, observers, or custom persistence layers.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
yarn add @schemeless/event-store-types
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Event primitives
|
|
12
|
+
|
|
13
|
+
The package defines the shape of event inputs, created events, and the lifecycle metadata that flows through the runtime.
|
|
14
|
+
|
|
15
|
+
```ts
|
|
16
|
+
import { BaseEventInput, CreatedEvent, EventFlow } from '@schemeless/event-store-types';
|
|
17
|
+
|
|
18
|
+
const draft: BaseEventInput<{ id: string }> = {
|
|
19
|
+
payload: { id: '123' },
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
const eventFlow: EventFlow = {
|
|
23
|
+
domain: 'user',
|
|
24
|
+
type: 'registered',
|
|
25
|
+
receive: (eventStore) => eventStore.receive(eventFlow),
|
|
26
|
+
};
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
`CreatedEvent` extends the base shape with generated identifiers and timestamps, while `SideEffectsState`, `EventOutputState`, and `EventObserverState` describe the possible outcomes emitted by the runtime.
|
|
30
|
+
|
|
31
|
+
## Repository contracts
|
|
32
|
+
|
|
33
|
+
`Repo.types` exposes the `IEventStoreRepo` and `IEventStoreEntity` interfaces. Adapters implement these to integrate with the core runtime.
|
|
34
|
+
|
|
35
|
+
```ts
|
|
36
|
+
import { IEventStoreRepo } from '@schemeless/event-store-types';
|
|
37
|
+
|
|
38
|
+
class CustomRepo implements IEventStoreRepo {
|
|
39
|
+
async init() {}
|
|
40
|
+
async getAllEvents(pageSize: number) {
|
|
41
|
+
// return an async iterator of stored events
|
|
42
|
+
}
|
|
43
|
+
createEventEntity(event) {
|
|
44
|
+
return event;
|
|
45
|
+
}
|
|
46
|
+
async storeEvents(events) {}
|
|
47
|
+
async resetStore() {}
|
|
48
|
+
}
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
The iterator returned by `getAllEvents` yields arrays of `IEventStoreEntity` records. Each record includes identifiers, correlation/causation metadata, and the `created` timestamp so replays can process history in order.
|
package/tsconfig.json
CHANGED
|
@@ -10,7 +10,11 @@
|
|
|
10
10
|
"experimentalDecorators": true,
|
|
11
11
|
"emitDecoratorMetadata": true,
|
|
12
12
|
"skipLibCheck": true,
|
|
13
|
-
"strictPropertyInitialization": false
|
|
13
|
+
"strictPropertyInitialization": false,
|
|
14
|
+
"baseUrl": ".",
|
|
15
|
+
"paths": {
|
|
16
|
+
"@schemeless/*": ["../*/src"]
|
|
17
|
+
}
|
|
14
18
|
},
|
|
15
19
|
"exclude": ["node_modules"],
|
|
16
20
|
"include": ["src/**/*.ts"]
|