event-store-adapter-js 2.1.5-snapshot.6 → 2.1.5
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/event-store-options.d.ts +2 -1
- package/dist/event-store.d.ts +2 -2
- package/dist/event-store.js +2 -2
- package/dist/internal/event-store-for-dynamodb.d.ts +1 -0
- package/dist/internal/event-store-for-dynamodb.js +8 -5
- package/package.json +1 -1
- package/src/event-store-options.ts +3 -0
- package/src/event-store.ts +3 -0
- package/src/internal/event-store-for-dynamodb.ts +24 -0
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Aggregate, AggregateId, Event, EventSerializer, KeyResolver, SnapshotSerializer } from "./types";
|
|
1
|
+
import { Aggregate, AggregateId, Event, EventSerializer, KeyResolver, Logger, SnapshotSerializer } from "./types";
|
|
2
2
|
import moment from "moment";
|
|
3
3
|
interface EventStoreOptions<This extends EventStoreOptions<This, AID, A, E>, AID extends AggregateId, A extends Aggregate<A, AID>, E extends Event<AID>> {
|
|
4
4
|
withKeepSnapshotCount(keepSnapshotCount: number): This;
|
|
@@ -6,5 +6,6 @@ interface EventStoreOptions<This extends EventStoreOptions<This, AID, A, E>, AID
|
|
|
6
6
|
withKeyResolver(keyResolver: KeyResolver<AID>): This;
|
|
7
7
|
withEventSerializer(eventSerializer: EventSerializer<AID, E>): This;
|
|
8
8
|
withSnapshotSerializer(snapshotSerializer: SnapshotSerializer<AID, A>): This;
|
|
9
|
+
withLogger(logger: Logger): This;
|
|
9
10
|
}
|
|
10
11
|
export { EventStoreOptions };
|
package/dist/event-store.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Aggregate, AggregateId, Event, EventSerializer, KeyResolver, SnapshotSerializer } from "./types";
|
|
1
|
+
import { Aggregate, AggregateId, Event, EventSerializer, KeyResolver, Logger, SnapshotSerializer } from "./types";
|
|
2
2
|
import { DynamoDBClient } from "@aws-sdk/client-dynamodb";
|
|
3
3
|
import moment from "moment";
|
|
4
4
|
import { EventStoreWithOptions } from "./event-store-with-options";
|
|
@@ -9,7 +9,7 @@ interface EventStore<AID extends AggregateId, A extends Aggregate<A, AID>, E ext
|
|
|
9
9
|
getLatestSnapshotById(id: AID): Promise<A | undefined>;
|
|
10
10
|
}
|
|
11
11
|
declare class EventStoreFactory {
|
|
12
|
-
static ofDynamoDB<AID extends AggregateId, A extends Aggregate<A, AID>, E extends Event<AID>>(dynamodbClient: DynamoDBClient, journalTableName: string, snapshotTableName: string, journalAidIndexName: string, snapshotAidIndexName: string, shardCount: number, eventConverter: (json: string) => E, snapshotConverter: (json: string) => A, keepSnapshotCount?: number | undefined, deleteTtl?: moment.Duration | undefined, keyResolver?: KeyResolver<AID>, eventSerializer?: EventSerializer<AID, E>, snapshotSerializer?: SnapshotSerializer<AID, A
|
|
12
|
+
static ofDynamoDB<AID extends AggregateId, A extends Aggregate<A, AID>, E extends Event<AID>>(dynamodbClient: DynamoDBClient, journalTableName: string, snapshotTableName: string, journalAidIndexName: string, snapshotAidIndexName: string, shardCount: number, eventConverter: (json: string) => E, snapshotConverter: (json: string) => A, keepSnapshotCount?: number | undefined, deleteTtl?: moment.Duration | undefined, keyResolver?: KeyResolver<AID>, eventSerializer?: EventSerializer<AID, E>, snapshotSerializer?: SnapshotSerializer<AID, A>, logger?: Logger | undefined): EventStoreWithOptions<AID, A, E>;
|
|
13
13
|
static ofMemory<AID extends AggregateId, A extends Aggregate<A, AID>, E extends Event<AID>>(events?: Map<AID, E[]>, snapshots?: Map<AID, A>): EventStore<AID, A, E>;
|
|
14
14
|
}
|
|
15
15
|
export { EventStore, EventStoreFactory };
|
package/dist/event-store.js
CHANGED
|
@@ -6,8 +6,8 @@ const default_key_resolver_1 = require("./internal/default-key-resolver");
|
|
|
6
6
|
const default_serializer_1 = require("./internal/default-serializer");
|
|
7
7
|
const event_store_for_memory_1 = require("./internal/event-store-for-memory");
|
|
8
8
|
class EventStoreFactory {
|
|
9
|
-
static ofDynamoDB(dynamodbClient, journalTableName, snapshotTableName, journalAidIndexName, snapshotAidIndexName, shardCount, eventConverter, snapshotConverter, keepSnapshotCount = undefined, deleteTtl = undefined, keyResolver = new default_key_resolver_1.DefaultKeyResolver(), eventSerializer = new default_serializer_1.JsonEventSerializer(), snapshotSerializer = new default_serializer_1.JsonSnapshotSerializer()) {
|
|
10
|
-
return new event_store_for_dynamodb_1.EventStoreForDynamoDB(dynamodbClient, journalTableName, snapshotTableName, journalAidIndexName, snapshotAidIndexName, shardCount, eventConverter, snapshotConverter, keepSnapshotCount, deleteTtl, keyResolver, eventSerializer, snapshotSerializer);
|
|
9
|
+
static ofDynamoDB(dynamodbClient, journalTableName, snapshotTableName, journalAidIndexName, snapshotAidIndexName, shardCount, eventConverter, snapshotConverter, keepSnapshotCount = undefined, deleteTtl = undefined, keyResolver = new default_key_resolver_1.DefaultKeyResolver(), eventSerializer = new default_serializer_1.JsonEventSerializer(), snapshotSerializer = new default_serializer_1.JsonSnapshotSerializer(), logger = undefined) {
|
|
10
|
+
return new event_store_for_dynamodb_1.EventStoreForDynamoDB(dynamodbClient, journalTableName, snapshotTableName, journalAidIndexName, snapshotAidIndexName, shardCount, eventConverter, snapshotConverter, keepSnapshotCount, deleteTtl, keyResolver, eventSerializer, snapshotSerializer, logger);
|
|
11
11
|
}
|
|
12
12
|
static ofMemory(events = new Map(), snapshots = new Map()) {
|
|
13
13
|
return new event_store_for_memory_1.EventStoreForMemory(events, snapshots);
|
|
@@ -27,6 +27,7 @@ declare class EventStoreForDynamoDB<AID extends AggregateId, A extends Aggregate
|
|
|
27
27
|
withKeepSnapshotCount(keepSnapshotCount: number): EventStoreWithOptions<AID, A, E>;
|
|
28
28
|
withKeyResolver(keyResolver: KeyResolver<AID>): EventStoreWithOptions<AID, A, E>;
|
|
29
29
|
withSnapshotSerializer(snapshotSerializer: SnapshotSerializer<AID, A>): EventStoreWithOptions<AID, A, E>;
|
|
30
|
+
withLogger(logger: Logger): EventStoreWithOptions<AID, A, E>;
|
|
30
31
|
private createEventAndSnapshot;
|
|
31
32
|
private updateEventAndSnapshotOpt;
|
|
32
33
|
private putJournal;
|
|
@@ -138,19 +138,22 @@ class EventStoreForDynamoDB {
|
|
|
138
138
|
});
|
|
139
139
|
}
|
|
140
140
|
withDeleteTtl(deleteTtl) {
|
|
141
|
-
return new EventStoreForDynamoDB(this.dynamodbClient, this.journalTableName, this.snapshotTableName, this.journalAidIndexName, this.snapshotAidIndexName, this.shardCount, this.eventConverter, this.snapshotConverter, this.keepSnapshotCount, deleteTtl, this.keyResolver, this.eventSerializer, this.snapshotSerializer);
|
|
141
|
+
return new EventStoreForDynamoDB(this.dynamodbClient, this.journalTableName, this.snapshotTableName, this.journalAidIndexName, this.snapshotAidIndexName, this.shardCount, this.eventConverter, this.snapshotConverter, this.keepSnapshotCount, deleteTtl, this.keyResolver, this.eventSerializer, this.snapshotSerializer, this.logger);
|
|
142
142
|
}
|
|
143
143
|
withEventSerializer(eventSerializer) {
|
|
144
|
-
return new EventStoreForDynamoDB(this.dynamodbClient, this.journalTableName, this.snapshotTableName, this.journalAidIndexName, this.snapshotAidIndexName, this.shardCount, this.eventConverter, this.snapshotConverter, this.keepSnapshotCount, this.deleteTtl, this.keyResolver, eventSerializer, this.snapshotSerializer);
|
|
144
|
+
return new EventStoreForDynamoDB(this.dynamodbClient, this.journalTableName, this.snapshotTableName, this.journalAidIndexName, this.snapshotAidIndexName, this.shardCount, this.eventConverter, this.snapshotConverter, this.keepSnapshotCount, this.deleteTtl, this.keyResolver, eventSerializer, this.snapshotSerializer, this.logger);
|
|
145
145
|
}
|
|
146
146
|
withKeepSnapshotCount(keepSnapshotCount) {
|
|
147
|
-
return new EventStoreForDynamoDB(this.dynamodbClient, this.journalTableName, this.snapshotTableName, this.journalAidIndexName, this.snapshotAidIndexName, this.shardCount, this.eventConverter, this.snapshotConverter, keepSnapshotCount, this.deleteTtl, this.keyResolver, this.eventSerializer, this.snapshotSerializer);
|
|
147
|
+
return new EventStoreForDynamoDB(this.dynamodbClient, this.journalTableName, this.snapshotTableName, this.journalAidIndexName, this.snapshotAidIndexName, this.shardCount, this.eventConverter, this.snapshotConverter, keepSnapshotCount, this.deleteTtl, this.keyResolver, this.eventSerializer, this.snapshotSerializer, this.logger);
|
|
148
148
|
}
|
|
149
149
|
withKeyResolver(keyResolver) {
|
|
150
|
-
return new EventStoreForDynamoDB(this.dynamodbClient, this.journalTableName, this.snapshotTableName, this.journalAidIndexName, this.snapshotAidIndexName, this.shardCount, this.eventConverter, this.snapshotConverter, this.keepSnapshotCount, this.deleteTtl, keyResolver, this.eventSerializer, this.snapshotSerializer);
|
|
150
|
+
return new EventStoreForDynamoDB(this.dynamodbClient, this.journalTableName, this.snapshotTableName, this.journalAidIndexName, this.snapshotAidIndexName, this.shardCount, this.eventConverter, this.snapshotConverter, this.keepSnapshotCount, this.deleteTtl, keyResolver, this.eventSerializer, this.snapshotSerializer, this.logger);
|
|
151
151
|
}
|
|
152
152
|
withSnapshotSerializer(snapshotSerializer) {
|
|
153
|
-
return new EventStoreForDynamoDB(this.dynamodbClient, this.journalTableName, this.snapshotTableName, this.journalAidIndexName, this.snapshotAidIndexName, this.shardCount, this.eventConverter, this.snapshotConverter, this.keepSnapshotCount, this.deleteTtl, this.keyResolver, this.eventSerializer, snapshotSerializer);
|
|
153
|
+
return new EventStoreForDynamoDB(this.dynamodbClient, this.journalTableName, this.snapshotTableName, this.journalAidIndexName, this.snapshotAidIndexName, this.shardCount, this.eventConverter, this.snapshotConverter, this.keepSnapshotCount, this.deleteTtl, this.keyResolver, this.eventSerializer, snapshotSerializer, this.logger);
|
|
154
|
+
}
|
|
155
|
+
withLogger(logger) {
|
|
156
|
+
return new EventStoreForDynamoDB(this.dynamodbClient, this.journalTableName, this.snapshotTableName, this.journalAidIndexName, this.snapshotAidIndexName, this.shardCount, this.eventConverter, this.snapshotConverter, this.keepSnapshotCount, this.deleteTtl, this.keyResolver, this.eventSerializer, this.snapshotSerializer, logger);
|
|
154
157
|
}
|
|
155
158
|
createEventAndSnapshot(event, aggregate) {
|
|
156
159
|
var _a, _b, _c;
|
package/package.json
CHANGED
|
@@ -4,6 +4,7 @@ import {
|
|
|
4
4
|
Event,
|
|
5
5
|
EventSerializer,
|
|
6
6
|
KeyResolver,
|
|
7
|
+
Logger,
|
|
7
8
|
SnapshotSerializer,
|
|
8
9
|
} from "./types";
|
|
9
10
|
import moment from "moment";
|
|
@@ -23,6 +24,8 @@ interface EventStoreOptions<
|
|
|
23
24
|
withEventSerializer(eventSerializer: EventSerializer<AID, E>): This;
|
|
24
25
|
|
|
25
26
|
withSnapshotSerializer(snapshotSerializer: SnapshotSerializer<AID, A>): This;
|
|
27
|
+
|
|
28
|
+
withLogger(logger: Logger): This;
|
|
26
29
|
}
|
|
27
30
|
|
|
28
31
|
export { EventStoreOptions };
|
package/src/event-store.ts
CHANGED
|
@@ -4,6 +4,7 @@ import {
|
|
|
4
4
|
Event,
|
|
5
5
|
EventSerializer,
|
|
6
6
|
KeyResolver,
|
|
7
|
+
Logger,
|
|
7
8
|
SnapshotSerializer,
|
|
8
9
|
} from "./types";
|
|
9
10
|
import { EventStoreForDynamoDB } from "./internal/event-store-for-dynamodb";
|
|
@@ -56,6 +57,7 @@ class EventStoreFactory {
|
|
|
56
57
|
AID,
|
|
57
58
|
A
|
|
58
59
|
>(),
|
|
60
|
+
logger: Logger | undefined = undefined,
|
|
59
61
|
): EventStoreWithOptions<AID, A, E> {
|
|
60
62
|
return new EventStoreForDynamoDB<AID, A, E>(
|
|
61
63
|
dynamodbClient,
|
|
@@ -71,6 +73,7 @@ class EventStoreFactory {
|
|
|
71
73
|
keyResolver,
|
|
72
74
|
eventSerializer,
|
|
73
75
|
snapshotSerializer,
|
|
76
|
+
logger,
|
|
74
77
|
);
|
|
75
78
|
}
|
|
76
79
|
static ofMemory<
|
|
@@ -209,6 +209,7 @@ class EventStoreForDynamoDB<
|
|
|
209
209
|
this.keyResolver,
|
|
210
210
|
this.eventSerializer,
|
|
211
211
|
this.snapshotSerializer,
|
|
212
|
+
this.logger,
|
|
212
213
|
);
|
|
213
214
|
}
|
|
214
215
|
|
|
@@ -229,6 +230,7 @@ class EventStoreForDynamoDB<
|
|
|
229
230
|
this.keyResolver,
|
|
230
231
|
eventSerializer,
|
|
231
232
|
this.snapshotSerializer,
|
|
233
|
+
this.logger,
|
|
232
234
|
);
|
|
233
235
|
}
|
|
234
236
|
|
|
@@ -249,6 +251,7 @@ class EventStoreForDynamoDB<
|
|
|
249
251
|
this.keyResolver,
|
|
250
252
|
this.eventSerializer,
|
|
251
253
|
this.snapshotSerializer,
|
|
254
|
+
this.logger,
|
|
252
255
|
);
|
|
253
256
|
}
|
|
254
257
|
|
|
@@ -269,6 +272,7 @@ class EventStoreForDynamoDB<
|
|
|
269
272
|
keyResolver,
|
|
270
273
|
this.eventSerializer,
|
|
271
274
|
this.snapshotSerializer,
|
|
275
|
+
this.logger,
|
|
272
276
|
);
|
|
273
277
|
}
|
|
274
278
|
|
|
@@ -289,6 +293,26 @@ class EventStoreForDynamoDB<
|
|
|
289
293
|
this.keyResolver,
|
|
290
294
|
this.eventSerializer,
|
|
291
295
|
snapshotSerializer,
|
|
296
|
+
this.logger,
|
|
297
|
+
);
|
|
298
|
+
}
|
|
299
|
+
|
|
300
|
+
withLogger(logger: Logger): EventStoreWithOptions<AID, A, E> {
|
|
301
|
+
return new EventStoreForDynamoDB(
|
|
302
|
+
this.dynamodbClient,
|
|
303
|
+
this.journalTableName,
|
|
304
|
+
this.snapshotTableName,
|
|
305
|
+
this.journalAidIndexName,
|
|
306
|
+
this.snapshotAidIndexName,
|
|
307
|
+
this.shardCount,
|
|
308
|
+
this.eventConverter,
|
|
309
|
+
this.snapshotConverter,
|
|
310
|
+
this.keepSnapshotCount,
|
|
311
|
+
this.deleteTtl,
|
|
312
|
+
this.keyResolver,
|
|
313
|
+
this.eventSerializer,
|
|
314
|
+
this.snapshotSerializer,
|
|
315
|
+
logger,
|
|
292
316
|
);
|
|
293
317
|
}
|
|
294
318
|
|