event-store-adapter-js 2.1.5 → 2.1.6-snapshot.2
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.
|
@@ -158,7 +158,7 @@ class EventStoreForDynamoDB {
|
|
|
158
158
|
createEventAndSnapshot(event, aggregate) {
|
|
159
159
|
var _a, _b, _c;
|
|
160
160
|
return __awaiter(this, void 0, void 0, function* () {
|
|
161
|
-
(_a = this.logger) === null || _a === void 0 ? void 0 : _a.debug(`createEventAndSnapshot(${JSON.stringify(event)}, ${JSON.stringify(aggregate)}): start`);
|
|
161
|
+
(_a = this.logger) === null || _a === void 0 ? void 0 : _a.debug(`private createEventAndSnapshot(${JSON.stringify(event)}, ${JSON.stringify(aggregate)}): start`);
|
|
162
162
|
const putSnapshot = this.putSnapshot(event, 0, aggregate);
|
|
163
163
|
const putJournal = this.putJournal(event);
|
|
164
164
|
const transactWriteItems = [
|
|
@@ -184,13 +184,13 @@ class EventStoreForDynamoDB {
|
|
|
184
184
|
throw e;
|
|
185
185
|
}
|
|
186
186
|
}
|
|
187
|
-
(_c = this.logger) === null || _c === void 0 ? void 0 : _c.debug(`createEventAndSnapshot(
|
|
187
|
+
(_c = this.logger) === null || _c === void 0 ? void 0 : _c.debug(`private createEventAndSnapshot(...): finished`);
|
|
188
188
|
});
|
|
189
189
|
}
|
|
190
190
|
updateEventAndSnapshotOpt(event, version, aggregate) {
|
|
191
191
|
var _a, _b, _c;
|
|
192
192
|
return __awaiter(this, void 0, void 0, function* () {
|
|
193
|
-
(_a = this.logger) === null || _a === void 0 ? void 0 : _a.debug(`updateEventAndSnapshotOpt(${JSON.stringify(event)}, ${version}, ${JSON.stringify(aggregate)}): start`);
|
|
193
|
+
(_a = this.logger) === null || _a === void 0 ? void 0 : _a.debug(`private updateEventAndSnapshotOpt(${JSON.stringify(event)}, ${version}, ${JSON.stringify(aggregate)}): start`);
|
|
194
194
|
const update = this.updateSnapshot(event, 0, version, aggregate);
|
|
195
195
|
const put = this.putJournal(event);
|
|
196
196
|
const transactWriteItems = [
|
|
@@ -216,12 +216,12 @@ class EventStoreForDynamoDB {
|
|
|
216
216
|
throw e;
|
|
217
217
|
}
|
|
218
218
|
}
|
|
219
|
-
(_c = this.logger) === null || _c === void 0 ? void 0 : _c.debug(`updateEventAndSnapshotOpt(
|
|
219
|
+
(_c = this.logger) === null || _c === void 0 ? void 0 : _c.debug(`private updateEventAndSnapshotOpt(...): finished`);
|
|
220
220
|
});
|
|
221
221
|
}
|
|
222
222
|
putJournal(event) {
|
|
223
223
|
var _a, _b;
|
|
224
|
-
(_a = this.logger) === null || _a === void 0 ? void 0 : _a.debug(`putSnapshot(${JSON.stringify(event)}): start`);
|
|
224
|
+
(_a = this.logger) === null || _a === void 0 ? void 0 : _a.debug(`private putSnapshot(${JSON.stringify(event)}): start`);
|
|
225
225
|
const pkey = this.keyResolver.resolvePartitionKey(event.aggregateId, this.shardCount);
|
|
226
226
|
const skey = this.keyResolver.resolveSortKey(event.aggregateId, event.sequenceNumber);
|
|
227
227
|
const payload = this.eventSerializer.serialize(event);
|
|
@@ -237,12 +237,12 @@ class EventStoreForDynamoDB {
|
|
|
237
237
|
},
|
|
238
238
|
ConditionExpression: "attribute_not_exists(pkey) AND attribute_not_exists(skey)",
|
|
239
239
|
};
|
|
240
|
-
(_b = this.logger) === null || _b === void 0 ? void 0 : _b.debug(`putSnapshot(
|
|
240
|
+
(_b = this.logger) === null || _b === void 0 ? void 0 : _b.debug(`private putSnapshot(...): finished`);
|
|
241
241
|
return result;
|
|
242
242
|
}
|
|
243
243
|
putSnapshot(event, sequenceNumber, aggregate) {
|
|
244
|
-
var _a, _b;
|
|
245
|
-
(_a = this.logger) === null || _a === void 0 ? void 0 : _a.debug(`putSnapshot(${JSON.stringify(event)}, ${sequenceNumber}, ${JSON.stringify(aggregate)}): start`);
|
|
244
|
+
var _a, _b, _c;
|
|
245
|
+
(_a = this.logger) === null || _a === void 0 ? void 0 : _a.debug(`private putSnapshot(${JSON.stringify(event)}, ${sequenceNumber}, ${JSON.stringify(aggregate)}): start`);
|
|
246
246
|
const pkey = this.keyResolver.resolvePartitionKey(event.aggregateId, this.shardCount);
|
|
247
247
|
const skey = this.keyResolver.resolveSortKey(event.aggregateId, sequenceNumber);
|
|
248
248
|
const payload = this.snapshotSerializer.serialize(aggregate);
|
|
@@ -262,12 +262,13 @@ class EventStoreForDynamoDB {
|
|
|
262
262
|
},
|
|
263
263
|
ConditionExpression: "attribute_not_exists(pkey) AND attribute_not_exists(skey)",
|
|
264
264
|
};
|
|
265
|
-
(_b = this.logger) === null || _b === void 0 ? void 0 : _b.debug(
|
|
265
|
+
(_b = this.logger) === null || _b === void 0 ? void 0 : _b.debug("result = " + JSON.stringify(result));
|
|
266
|
+
(_c = this.logger) === null || _c === void 0 ? void 0 : _c.debug(`private putSnapshot(...): finished`);
|
|
266
267
|
return result;
|
|
267
268
|
}
|
|
268
269
|
updateSnapshot(event, sequenceNumber, version, aggregate) {
|
|
269
|
-
var _a, _b;
|
|
270
|
-
(_a = this.logger) === null || _a === void 0 ? void 0 : _a.debug(`updateSnapshot(${JSON.stringify(event)}, ${sequenceNumber}, ${version}, ${JSON.stringify(aggregate)}): start`);
|
|
270
|
+
var _a, _b, _c;
|
|
271
|
+
(_a = this.logger) === null || _a === void 0 ? void 0 : _a.debug(`private updateSnapshot(event = ${JSON.stringify(event)}, sequenceNumber = ${sequenceNumber}, version = ${version}, aggregate = ${JSON.stringify(aggregate)}): start`);
|
|
271
272
|
const pkey = this.keyResolver.resolvePartitionKey(event.aggregateId, this.shardCount);
|
|
272
273
|
const skey = this.keyResolver.resolveSortKey(event.aggregateId, sequenceNumber);
|
|
273
274
|
const keys = {
|
|
@@ -307,7 +308,8 @@ class EventStoreForDynamoDB {
|
|
|
307
308
|
ConditionExpression: "#version=:before_version",
|
|
308
309
|
};
|
|
309
310
|
}
|
|
310
|
-
(_b = this.logger) === null || _b === void 0 ? void 0 : _b.debug(
|
|
311
|
+
(_b = this.logger) === null || _b === void 0 ? void 0 : _b.debug("result = " + JSON.stringify(result));
|
|
312
|
+
(_c = this.logger) === null || _c === void 0 ? void 0 : _c.debug(`private updateSnapshot(...): finished`);
|
|
311
313
|
return result;
|
|
312
314
|
}
|
|
313
315
|
tryPurgeExcessSnapshots(event) {
|
package/package.json
CHANGED
|
@@ -318,7 +318,7 @@ class EventStoreForDynamoDB<
|
|
|
318
318
|
|
|
319
319
|
private async createEventAndSnapshot(event: E, aggregate: A): Promise<void> {
|
|
320
320
|
this.logger?.debug(
|
|
321
|
-
`createEventAndSnapshot(${JSON.stringify(event)}, ${JSON.stringify(
|
|
321
|
+
`private createEventAndSnapshot(${JSON.stringify(event)}, ${JSON.stringify(
|
|
322
322
|
aggregate,
|
|
323
323
|
)}): start`,
|
|
324
324
|
);
|
|
@@ -347,11 +347,7 @@ class EventStoreForDynamoDB<
|
|
|
347
347
|
throw e;
|
|
348
348
|
}
|
|
349
349
|
}
|
|
350
|
-
this.logger?.debug(
|
|
351
|
-
`createEventAndSnapshot(${JSON.stringify(event)}, ${JSON.stringify(
|
|
352
|
-
aggregate,
|
|
353
|
-
)}): finished`,
|
|
354
|
-
);
|
|
350
|
+
this.logger?.debug(`private createEventAndSnapshot(...): finished`);
|
|
355
351
|
}
|
|
356
352
|
|
|
357
353
|
private async updateEventAndSnapshotOpt(
|
|
@@ -360,7 +356,7 @@ class EventStoreForDynamoDB<
|
|
|
360
356
|
aggregate: A | undefined,
|
|
361
357
|
): Promise<void> {
|
|
362
358
|
this.logger?.debug(
|
|
363
|
-
`updateEventAndSnapshotOpt(${JSON.stringify(
|
|
359
|
+
`private updateEventAndSnapshotOpt(${JSON.stringify(
|
|
364
360
|
event,
|
|
365
361
|
)}, ${version}, ${JSON.stringify(aggregate)}): start`,
|
|
366
362
|
);
|
|
@@ -389,15 +385,11 @@ class EventStoreForDynamoDB<
|
|
|
389
385
|
throw e;
|
|
390
386
|
}
|
|
391
387
|
}
|
|
392
|
-
this.logger?.debug(
|
|
393
|
-
`updateEventAndSnapshotOpt(${JSON.stringify(
|
|
394
|
-
event,
|
|
395
|
-
)}, ${version}, ${JSON.stringify(aggregate)}): finished`,
|
|
396
|
-
);
|
|
388
|
+
this.logger?.debug(`private updateEventAndSnapshotOpt(...): finished`);
|
|
397
389
|
}
|
|
398
390
|
|
|
399
391
|
private putJournal(event: E): Put {
|
|
400
|
-
this.logger?.debug(`putSnapshot(${JSON.stringify(event)}): start`);
|
|
392
|
+
this.logger?.debug(`private putSnapshot(${JSON.stringify(event)}): start`);
|
|
401
393
|
const pkey = this.keyResolver.resolvePartitionKey(
|
|
402
394
|
event.aggregateId,
|
|
403
395
|
this.shardCount,
|
|
@@ -420,13 +412,13 @@ class EventStoreForDynamoDB<
|
|
|
420
412
|
ConditionExpression:
|
|
421
413
|
"attribute_not_exists(pkey) AND attribute_not_exists(skey)",
|
|
422
414
|
};
|
|
423
|
-
this.logger?.debug(`putSnapshot(
|
|
415
|
+
this.logger?.debug(`private putSnapshot(...): finished`);
|
|
424
416
|
return result;
|
|
425
417
|
}
|
|
426
418
|
|
|
427
419
|
private putSnapshot(event: E, sequenceNumber: number, aggregate: A): Put {
|
|
428
420
|
this.logger?.debug(
|
|
429
|
-
`putSnapshot(${JSON.stringify(
|
|
421
|
+
`private putSnapshot(${JSON.stringify(
|
|
430
422
|
event,
|
|
431
423
|
)}, ${sequenceNumber}, ${JSON.stringify(aggregate)}): start`,
|
|
432
424
|
);
|
|
@@ -456,11 +448,8 @@ class EventStoreForDynamoDB<
|
|
|
456
448
|
ConditionExpression:
|
|
457
449
|
"attribute_not_exists(pkey) AND attribute_not_exists(skey)",
|
|
458
450
|
};
|
|
459
|
-
this.logger?.debug(
|
|
460
|
-
|
|
461
|
-
event,
|
|
462
|
-
)}, ${sequenceNumber}, ${JSON.stringify(aggregate)}): finished`,
|
|
463
|
-
);
|
|
451
|
+
this.logger?.debug("result = " + JSON.stringify(result));
|
|
452
|
+
this.logger?.debug(`private putSnapshot(...): finished`);
|
|
464
453
|
return result;
|
|
465
454
|
}
|
|
466
455
|
|
|
@@ -471,9 +460,9 @@ class EventStoreForDynamoDB<
|
|
|
471
460
|
aggregate: A | undefined,
|
|
472
461
|
): Update {
|
|
473
462
|
this.logger?.debug(
|
|
474
|
-
`updateSnapshot(${JSON.stringify(
|
|
463
|
+
`private updateSnapshot(event = ${JSON.stringify(
|
|
475
464
|
event,
|
|
476
|
-
)}, ${sequenceNumber}, ${version}, ${JSON.stringify(aggregate)}): start`,
|
|
465
|
+
)}, sequenceNumber = ${sequenceNumber}, version = ${version}, aggregate = ${JSON.stringify(aggregate)}): start`,
|
|
477
466
|
);
|
|
478
467
|
const pkey = this.keyResolver.resolvePartitionKey(
|
|
479
468
|
event.aggregateId,
|
|
@@ -529,13 +518,8 @@ class EventStoreForDynamoDB<
|
|
|
529
518
|
ConditionExpression: "#version=:before_version",
|
|
530
519
|
};
|
|
531
520
|
}
|
|
532
|
-
this.logger?.debug(
|
|
533
|
-
|
|
534
|
-
event,
|
|
535
|
-
)}, ${sequenceNumber}, ${version}, ${JSON.stringify(
|
|
536
|
-
aggregate,
|
|
537
|
-
)}): finished`,
|
|
538
|
-
);
|
|
521
|
+
this.logger?.debug("result = " + JSON.stringify(result));
|
|
522
|
+
this.logger?.debug(`private updateSnapshot(...): finished`);
|
|
539
523
|
return result;
|
|
540
524
|
}
|
|
541
525
|
|