@event-driven-io/emmett-mongodb 0.38.7 → 0.39.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/index.cjs +28 -247
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +2 -10
- package/dist/index.d.ts +2 -10
- package/dist/index.js +10 -229
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
package/dist/index.cjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; } var _class
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; } var _class;// ../emmett/dist/chunk-O2VMBOV4.js
|
|
2
2
|
var isNumber = (val) => typeof val === "number" && val === val;
|
|
3
3
|
var isString = (val) => typeof val === "string";
|
|
4
4
|
var isErrorConstructor = (expect) => {
|
|
@@ -41,23 +41,6 @@ var _uuid = require('uuid');
|
|
|
41
41
|
|
|
42
42
|
var _asyncretry = require('async-retry'); var _asyncretry2 = _interopRequireDefault(_asyncretry);
|
|
43
43
|
|
|
44
|
-
var _webstreamspolyfill = require('web-streams-polyfill');
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
44
|
async function tryPublishMessagesAfterCommit(messages, options, context) {
|
|
62
45
|
if (_optionalChain([options, 'optionalAccess', _4 => _4.onAfterCommit]) === void 0) return false;
|
|
63
46
|
try {
|
|
@@ -94,16 +77,16 @@ var hasDuplicates = (array, predicate) => {
|
|
|
94
77
|
return uniqueValues.size < mapped.length;
|
|
95
78
|
};
|
|
96
79
|
var getDuplicates = (array, predicate) => {
|
|
97
|
-
const
|
|
80
|
+
const map = /* @__PURE__ */ new Map();
|
|
98
81
|
for (let i = 0; i < array.length; i++) {
|
|
99
82
|
const item = array[i];
|
|
100
83
|
const key = predicate(item, i, array);
|
|
101
|
-
if (!
|
|
102
|
-
|
|
84
|
+
if (!map.has(key)) {
|
|
85
|
+
map.set(key, []);
|
|
103
86
|
}
|
|
104
|
-
|
|
87
|
+
map.get(key).push(item);
|
|
105
88
|
}
|
|
106
|
-
return Array.from(
|
|
89
|
+
return Array.from(map.values()).filter((group) => group.length > 1).flat();
|
|
107
90
|
};
|
|
108
91
|
var merge = (array, item, where, onExisting, onNotFound = () => void 0) => {
|
|
109
92
|
let wasFound = false;
|
|
@@ -348,29 +331,6 @@ var JSONParser = {
|
|
|
348
331
|
return _optionalChain([options, 'optionalAccess', _16 => _16.map]) ? options.map(parsed) : parsed;
|
|
349
332
|
}
|
|
350
333
|
};
|
|
351
|
-
var asyncRetry = async (fn, opts) => {
|
|
352
|
-
if (opts === void 0 || opts.retries === 0) return fn();
|
|
353
|
-
return _asyncretry2.default.call(void 0,
|
|
354
|
-
async (bail) => {
|
|
355
|
-
try {
|
|
356
|
-
const result = await fn();
|
|
357
|
-
if (_optionalChain([opts, 'optionalAccess', _17 => _17.shouldRetryResult]) && opts.shouldRetryResult(result)) {
|
|
358
|
-
throw new EmmettError(
|
|
359
|
-
`Retrying because of result: ${JSONParser.stringify(result)}`
|
|
360
|
-
);
|
|
361
|
-
}
|
|
362
|
-
return result;
|
|
363
|
-
} catch (error2) {
|
|
364
|
-
if (_optionalChain([opts, 'optionalAccess', _18 => _18.shouldRetryError]) && !opts.shouldRetryError(error2)) {
|
|
365
|
-
bail(error2);
|
|
366
|
-
return void 0;
|
|
367
|
-
}
|
|
368
|
-
throw error2;
|
|
369
|
-
}
|
|
370
|
-
},
|
|
371
|
-
_nullishCoalesce(opts, () => ( { retries: 0 }))
|
|
372
|
-
);
|
|
373
|
-
};
|
|
374
334
|
var AssertionError = class extends Error {
|
|
375
335
|
constructor(message2) {
|
|
376
336
|
super(message2);
|
|
@@ -398,44 +358,6 @@ function assertTrue(condition, message2) {
|
|
|
398
358
|
function assertOk(obj, message2) {
|
|
399
359
|
if (!obj) throw new AssertionError(_nullishCoalesce(message2, () => ( `Condition is not truthy`)));
|
|
400
360
|
}
|
|
401
|
-
var notifyAboutNoActiveReadersStream = (onNoActiveReaderCallback, options = {}) => new NotifyAboutNoActiveReadersStream(onNoActiveReaderCallback, options);
|
|
402
|
-
var NotifyAboutNoActiveReadersStream = (_class = class extends _webstreamspolyfill.TransformStream {
|
|
403
|
-
constructor(onNoActiveReaderCallback, options = {}) {
|
|
404
|
-
super({
|
|
405
|
-
cancel: (reason) => {
|
|
406
|
-
console.log("Stream was canceled. Reason:", reason);
|
|
407
|
-
this.stopChecking();
|
|
408
|
-
}
|
|
409
|
-
});_class.prototype.__init.call(this);_class.prototype.__init2.call(this);;
|
|
410
|
-
this.onNoActiveReaderCallback = onNoActiveReaderCallback;
|
|
411
|
-
this.streamId = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _19 => _19.streamId]), () => ( _uuid.v4.call(void 0, )));
|
|
412
|
-
this.onNoActiveReaderCallback = onNoActiveReaderCallback;
|
|
413
|
-
this.startChecking(_nullishCoalesce(_optionalChain([options, 'optionalAccess', _20 => _20.intervalCheckInMs]), () => ( 20)));
|
|
414
|
-
}
|
|
415
|
-
__init() {this.checkInterval = null}
|
|
416
|
-
|
|
417
|
-
__init2() {this._isStopped = false}
|
|
418
|
-
get hasActiveSubscribers() {
|
|
419
|
-
return !this._isStopped;
|
|
420
|
-
}
|
|
421
|
-
startChecking(interval) {
|
|
422
|
-
this.checkInterval = setInterval(() => {
|
|
423
|
-
this.checkNoActiveReader();
|
|
424
|
-
}, interval);
|
|
425
|
-
}
|
|
426
|
-
stopChecking() {
|
|
427
|
-
if (!this.checkInterval) return;
|
|
428
|
-
clearInterval(this.checkInterval);
|
|
429
|
-
this.checkInterval = null;
|
|
430
|
-
this._isStopped = true;
|
|
431
|
-
this.onNoActiveReaderCallback(this);
|
|
432
|
-
}
|
|
433
|
-
checkNoActiveReader() {
|
|
434
|
-
if (!this.readable.locked && !this._isStopped) {
|
|
435
|
-
this.stopChecking();
|
|
436
|
-
}
|
|
437
|
-
}
|
|
438
|
-
}, _class);
|
|
439
361
|
var filterProjections = (type, projections2) => {
|
|
440
362
|
const inlineProjections2 = projections2.filter((projection2) => projection2.type === type).map(({ projection: projection2 }) => projection2);
|
|
441
363
|
const duplicateRegistrations = arrayUtils.getDuplicates(
|
|
@@ -462,147 +384,6 @@ var projections = {
|
|
|
462
384
|
inline: inlineProjections,
|
|
463
385
|
async: asyncProjections
|
|
464
386
|
};
|
|
465
|
-
var filter = (filter2) => new (0, _webstreamspolyfill.TransformStream)({
|
|
466
|
-
transform(chunk, controller) {
|
|
467
|
-
if (filter2(chunk)) {
|
|
468
|
-
controller.enqueue(chunk);
|
|
469
|
-
}
|
|
470
|
-
}
|
|
471
|
-
});
|
|
472
|
-
var map = (map2) => new (0, _webstreamspolyfill.TransformStream)({
|
|
473
|
-
transform(chunk, controller) {
|
|
474
|
-
controller.enqueue(map2(chunk));
|
|
475
|
-
}
|
|
476
|
-
});
|
|
477
|
-
var reduce = (reducer, initialValue) => new ReduceTransformStream(reducer, initialValue);
|
|
478
|
-
var ReduceTransformStream = class extends _webstreamspolyfill.TransformStream {
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
constructor(reducer, initialValue) {
|
|
482
|
-
super({
|
|
483
|
-
transform: (chunk) => {
|
|
484
|
-
this.accumulator = this.reducer(this.accumulator, chunk);
|
|
485
|
-
},
|
|
486
|
-
flush: (controller) => {
|
|
487
|
-
controller.enqueue(this.accumulator);
|
|
488
|
-
controller.terminate();
|
|
489
|
-
}
|
|
490
|
-
});
|
|
491
|
-
this.accumulator = initialValue;
|
|
492
|
-
this.reducer = reducer;
|
|
493
|
-
}
|
|
494
|
-
};
|
|
495
|
-
var retryStream = (createSourceStream, handleChunk2, retryOptions = { forever: true, minTimeout: 25 }) => new (0, _webstreamspolyfill.TransformStream)({
|
|
496
|
-
start(controller) {
|
|
497
|
-
asyncRetry(
|
|
498
|
-
() => onRestream(createSourceStream, handleChunk2, controller),
|
|
499
|
-
retryOptions
|
|
500
|
-
).catch((error2) => {
|
|
501
|
-
controller.error(error2);
|
|
502
|
-
});
|
|
503
|
-
}
|
|
504
|
-
});
|
|
505
|
-
var onRestream = async (createSourceStream, handleChunk2, controller) => {
|
|
506
|
-
const sourceStream = createSourceStream();
|
|
507
|
-
const reader = sourceStream.getReader();
|
|
508
|
-
try {
|
|
509
|
-
let done;
|
|
510
|
-
do {
|
|
511
|
-
const result = await reader.read();
|
|
512
|
-
done = result.done;
|
|
513
|
-
await handleChunk2(result, controller);
|
|
514
|
-
if (done) {
|
|
515
|
-
controller.terminate();
|
|
516
|
-
}
|
|
517
|
-
} while (!done);
|
|
518
|
-
} finally {
|
|
519
|
-
reader.releaseLock();
|
|
520
|
-
}
|
|
521
|
-
};
|
|
522
|
-
var skip = (limit) => new SkipTransformStream(limit);
|
|
523
|
-
var SkipTransformStream = (_class2 = class extends _webstreamspolyfill.TransformStream {
|
|
524
|
-
__init3() {this.count = 0}
|
|
525
|
-
|
|
526
|
-
constructor(skip2) {
|
|
527
|
-
super({
|
|
528
|
-
transform: (chunk, controller) => {
|
|
529
|
-
this.count++;
|
|
530
|
-
if (this.count > this.skip) {
|
|
531
|
-
controller.enqueue(chunk);
|
|
532
|
-
}
|
|
533
|
-
}
|
|
534
|
-
});_class2.prototype.__init3.call(this);;
|
|
535
|
-
this.skip = skip2;
|
|
536
|
-
}
|
|
537
|
-
}, _class2);
|
|
538
|
-
var stopAfter = (stopCondition) => new (0, _webstreamspolyfill.TransformStream)({
|
|
539
|
-
transform(chunk, controller) {
|
|
540
|
-
controller.enqueue(chunk);
|
|
541
|
-
if (stopCondition(chunk)) {
|
|
542
|
-
controller.terminate();
|
|
543
|
-
}
|
|
544
|
-
}
|
|
545
|
-
});
|
|
546
|
-
var stopOn = (stopCondition) => new (0, _webstreamspolyfill.TransformStream)({
|
|
547
|
-
async transform(chunk, controller) {
|
|
548
|
-
if (!stopCondition(chunk)) {
|
|
549
|
-
controller.enqueue(chunk);
|
|
550
|
-
return;
|
|
551
|
-
}
|
|
552
|
-
await Promise.resolve();
|
|
553
|
-
controller.terminate();
|
|
554
|
-
}
|
|
555
|
-
});
|
|
556
|
-
var take = (limit) => new TakeTransformStream(limit);
|
|
557
|
-
var TakeTransformStream = (_class3 = class extends _webstreamspolyfill.TransformStream {
|
|
558
|
-
__init4() {this.count = 0}
|
|
559
|
-
|
|
560
|
-
constructor(limit) {
|
|
561
|
-
super({
|
|
562
|
-
transform: (chunk, controller) => {
|
|
563
|
-
if (this.count < this.limit) {
|
|
564
|
-
this.count++;
|
|
565
|
-
controller.enqueue(chunk);
|
|
566
|
-
} else {
|
|
567
|
-
controller.terminate();
|
|
568
|
-
}
|
|
569
|
-
}
|
|
570
|
-
});_class3.prototype.__init4.call(this);;
|
|
571
|
-
this.limit = limit;
|
|
572
|
-
}
|
|
573
|
-
}, _class3);
|
|
574
|
-
var waitAtMost = (waitTimeInMs) => new (0, _webstreamspolyfill.TransformStream)({
|
|
575
|
-
start(controller) {
|
|
576
|
-
const timeoutId = setTimeout(() => {
|
|
577
|
-
controller.terminate();
|
|
578
|
-
}, waitTimeInMs);
|
|
579
|
-
const originalTerminate = controller.terminate.bind(controller);
|
|
580
|
-
controller.terminate = () => {
|
|
581
|
-
clearTimeout(timeoutId);
|
|
582
|
-
originalTerminate();
|
|
583
|
-
};
|
|
584
|
-
},
|
|
585
|
-
transform(chunk, controller) {
|
|
586
|
-
controller.enqueue(chunk);
|
|
587
|
-
}
|
|
588
|
-
});
|
|
589
|
-
var streamTransformations = {
|
|
590
|
-
filter,
|
|
591
|
-
take,
|
|
592
|
-
TakeTransformStream,
|
|
593
|
-
skip,
|
|
594
|
-
SkipTransformStream,
|
|
595
|
-
map,
|
|
596
|
-
notifyAboutNoActiveReadersStream,
|
|
597
|
-
NotifyAboutNoActiveReadersStream,
|
|
598
|
-
reduce,
|
|
599
|
-
ReduceTransformStream,
|
|
600
|
-
retry: retryStream,
|
|
601
|
-
stopAfter,
|
|
602
|
-
stopOn,
|
|
603
|
-
waitAtMost
|
|
604
|
-
};
|
|
605
|
-
var { retry: retry2 } = streamTransformations;
|
|
606
387
|
|
|
607
388
|
// src/eventStore/mongoDBEventStore.ts
|
|
608
389
|
|
|
@@ -714,18 +495,18 @@ var MongoDBInlineProjectionSpec = {
|
|
|
714
495
|
if (!isErrorConstructor(args[0])) {
|
|
715
496
|
assertTrue(
|
|
716
497
|
args[0](error),
|
|
717
|
-
`Error didn't match the error condition: ${_optionalChain([error, 'optionalAccess',
|
|
498
|
+
`Error didn't match the error condition: ${_optionalChain([error, 'optionalAccess', _17 => _17.toString, 'call', _18 => _18()])}`
|
|
718
499
|
);
|
|
719
500
|
return;
|
|
720
501
|
}
|
|
721
502
|
assertTrue(
|
|
722
503
|
error instanceof args[0],
|
|
723
|
-
`Caught error is not an instance of the expected type: ${_optionalChain([error, 'optionalAccess',
|
|
504
|
+
`Caught error is not an instance of the expected type: ${_optionalChain([error, 'optionalAccess', _19 => _19.toString, 'call', _20 => _20()])}`
|
|
724
505
|
);
|
|
725
506
|
if (args[1]) {
|
|
726
507
|
assertTrue(
|
|
727
508
|
args[1](error),
|
|
728
|
-
`Error didn't match the error condition: ${_optionalChain([error, 'optionalAccess',
|
|
509
|
+
`Error didn't match the error condition: ${_optionalChain([error, 'optionalAccess', _21 => _21.toString, 'call', _22 => _22()])}`
|
|
729
510
|
);
|
|
730
511
|
}
|
|
731
512
|
} finally {
|
|
@@ -865,15 +646,15 @@ var mongoDBEventStoreStorage = (options) => {
|
|
|
865
646
|
|
|
866
647
|
// src/eventStore/mongoDBEventStore.ts
|
|
867
648
|
var MongoDBEventStoreDefaultStreamVersion = 0n;
|
|
868
|
-
var MongoDBEventStoreImplementation = (
|
|
649
|
+
var MongoDBEventStoreImplementation = (_class = class {
|
|
869
650
|
|
|
870
651
|
|
|
871
652
|
|
|
872
|
-
|
|
653
|
+
__init() {this.isClosed = false}
|
|
873
654
|
|
|
874
655
|
|
|
875
656
|
|
|
876
|
-
constructor(options) {;
|
|
657
|
+
constructor(options) {;_class.prototype.__init.call(this);_class.prototype.__init2.call(this);_class.prototype.__init3.call(this);_class.prototype.__init4.call(this);
|
|
877
658
|
this.options = options;
|
|
878
659
|
this.client = "client" in options && options.client ? options.client : new (0, _mongodb.MongoClient)(options.connectionString, options.clientOptions);
|
|
879
660
|
this.shouldManageClientLifetime = !("client" in options);
|
|
@@ -895,9 +676,9 @@ var MongoDBEventStoreImplementation = (_class4 = class {
|
|
|
895
676
|
}
|
|
896
677
|
async readStream(streamName, options) {
|
|
897
678
|
const { streamType } = fromStreamName(streamName);
|
|
898
|
-
const expectedStreamVersion = _optionalChain([options, 'optionalAccess',
|
|
679
|
+
const expectedStreamVersion = _optionalChain([options, 'optionalAccess', _23 => _23.expectedStreamVersion]);
|
|
899
680
|
const collection = await this.storage.collectionFor(streamType);
|
|
900
|
-
const
|
|
681
|
+
const filter = {
|
|
901
682
|
streamName: { $eq: streamName }
|
|
902
683
|
};
|
|
903
684
|
const eventsSliceArr = [];
|
|
@@ -910,7 +691,7 @@ var MongoDBEventStoreImplementation = (_class4 = class {
|
|
|
910
691
|
eventsSliceArr.push(Number(options.to));
|
|
911
692
|
}
|
|
912
693
|
const eventsSlice = eventsSliceArr.length > 1 ? { $slice: eventsSliceArr } : 1;
|
|
913
|
-
const stream = await collection.findOne(
|
|
694
|
+
const stream = await collection.findOne(filter, {
|
|
914
695
|
useBigInt64: true,
|
|
915
696
|
projection: {
|
|
916
697
|
metadata: 1,
|
|
@@ -936,7 +717,7 @@ var MongoDBEventStoreImplementation = (_class4 = class {
|
|
|
936
717
|
};
|
|
937
718
|
}
|
|
938
719
|
async aggregateStream(streamName, options) {
|
|
939
|
-
const stream = await this.readStream(streamName, _optionalChain([options, 'optionalAccess',
|
|
720
|
+
const stream = await this.readStream(streamName, _optionalChain([options, 'optionalAccess', _24 => _24.read]));
|
|
940
721
|
const state = stream.events.reduce(options.evolve, options.initialState());
|
|
941
722
|
return {
|
|
942
723
|
state,
|
|
@@ -946,7 +727,7 @@ var MongoDBEventStoreImplementation = (_class4 = class {
|
|
|
946
727
|
}
|
|
947
728
|
async appendToStream(streamName, events, options) {
|
|
948
729
|
const { streamId, streamType } = fromStreamName(streamName);
|
|
949
|
-
const expectedStreamVersion = _optionalChain([options, 'optionalAccess',
|
|
730
|
+
const expectedStreamVersion = _optionalChain([options, 'optionalAccess', _25 => _25.expectedStreamVersion]);
|
|
950
731
|
const collection = await this.storage.collectionFor(streamType);
|
|
951
732
|
const stream = await collection.findOne(
|
|
952
733
|
{ streamName: { $eq: streamName } },
|
|
@@ -958,7 +739,7 @@ var MongoDBEventStoreImplementation = (_class4 = class {
|
|
|
958
739
|
}
|
|
959
740
|
}
|
|
960
741
|
);
|
|
961
|
-
const currentStreamVersion = _nullishCoalesce(_optionalChain([stream, 'optionalAccess',
|
|
742
|
+
const currentStreamVersion = _nullishCoalesce(_optionalChain([stream, 'optionalAccess', _26 => _26.metadata, 'access', _27 => _27.streamPosition]), () => ( MongoDBEventStoreDefaultStreamVersion));
|
|
962
743
|
assertExpectedVersionMatchesCurrent(
|
|
963
744
|
currentStreamVersion,
|
|
964
745
|
expectedStreamVersion,
|
|
@@ -996,7 +777,7 @@ var MongoDBEventStoreImplementation = (_class4 = class {
|
|
|
996
777
|
};
|
|
997
778
|
if (this.inlineProjections) {
|
|
998
779
|
await handleInlineProjections({
|
|
999
|
-
readModels: _nullishCoalesce(_optionalChain([stream, 'optionalAccess',
|
|
780
|
+
readModels: _nullishCoalesce(_optionalChain([stream, 'optionalAccess', _28 => _28.projections]), () => ( {})),
|
|
1000
781
|
streamId,
|
|
1001
782
|
events: eventsToAppend,
|
|
1002
783
|
projections: this.inlineProjections,
|
|
@@ -1016,7 +797,7 @@ var MongoDBEventStoreImplementation = (_class4 = class {
|
|
|
1016
797
|
if (!updatedStream) {
|
|
1017
798
|
throw new ExpectedVersionConflictError(
|
|
1018
799
|
currentStreamVersion,
|
|
1019
|
-
_nullishCoalesce(_optionalChain([options, 'optionalAccess',
|
|
800
|
+
_nullishCoalesce(_optionalChain([options, 'optionalAccess', _29 => _29.expectedStreamVersion]), () => ( 0n))
|
|
1020
801
|
);
|
|
1021
802
|
}
|
|
1022
803
|
await tryPublishMessagesAfterCommit(
|
|
@@ -1031,7 +812,7 @@ var MongoDBEventStoreImplementation = (_class4 = class {
|
|
|
1031
812
|
createdNewStream: currentStreamVersion === MongoDBEventStoreDefaultStreamVersion
|
|
1032
813
|
};
|
|
1033
814
|
}
|
|
1034
|
-
|
|
815
|
+
__init2() {this.collectionFor = async (streamType) => {
|
|
1035
816
|
return this.storage.collectionFor(streamType);
|
|
1036
817
|
}}
|
|
1037
818
|
/**
|
|
@@ -1041,7 +822,7 @@ var MongoDBEventStoreImplementation = (_class4 = class {
|
|
|
1041
822
|
*
|
|
1042
823
|
* @memberof Closeable
|
|
1043
824
|
*/
|
|
1044
|
-
|
|
825
|
+
__init3() {this.close = () => {
|
|
1045
826
|
if (this.isClosed) return Promise.resolve();
|
|
1046
827
|
this.isClosed = true;
|
|
1047
828
|
if (!this.shouldManageClientLifetime) return Promise.resolve();
|
|
@@ -1067,7 +848,7 @@ var MongoDBEventStoreImplementation = (_class4 = class {
|
|
|
1067
848
|
projection: { [`projections.${projectionName}`]: 1 }
|
|
1068
849
|
}
|
|
1069
850
|
);
|
|
1070
|
-
return _nullishCoalesce(_optionalChain([result, 'optionalAccess',
|
|
851
|
+
return _nullishCoalesce(_optionalChain([result, 'optionalAccess', _30 => _30.projections, 'optionalAccess', _31 => _31[projectionName]]), () => ( null));
|
|
1071
852
|
}
|
|
1072
853
|
async findInlineProjection(streamFilter, projectionQuery, queryOptions) {
|
|
1073
854
|
const parsedStreamFilter = parseMultiProjectionQueryStreamFilter(streamFilter);
|
|
@@ -1092,13 +873,13 @@ var MongoDBEventStoreImplementation = (_class4 = class {
|
|
|
1092
873
|
projection: { [`projections.${projectionName}`]: 1 }
|
|
1093
874
|
}
|
|
1094
875
|
);
|
|
1095
|
-
if (_optionalChain([queryOptions, 'optionalAccess',
|
|
876
|
+
if (_optionalChain([queryOptions, 'optionalAccess', _32 => _32.skip])) {
|
|
1096
877
|
query = query.skip(queryOptions.skip);
|
|
1097
878
|
}
|
|
1098
|
-
if (_optionalChain([queryOptions, 'optionalAccess',
|
|
879
|
+
if (_optionalChain([queryOptions, 'optionalAccess', _33 => _33.limit])) {
|
|
1099
880
|
query = query.limit(queryOptions.limit);
|
|
1100
881
|
}
|
|
1101
|
-
if (_optionalChain([queryOptions, 'optionalAccess',
|
|
882
|
+
if (_optionalChain([queryOptions, 'optionalAccess', _34 => _34.sort])) {
|
|
1102
883
|
const sort = prependMongoFilterWithProjectionPrefix(
|
|
1103
884
|
queryOptions.sort,
|
|
1104
885
|
prefix
|
|
@@ -1127,11 +908,11 @@ var MongoDBEventStoreImplementation = (_class4 = class {
|
|
|
1127
908
|
const total = await collection.countDocuments({ $and: filters });
|
|
1128
909
|
return total;
|
|
1129
910
|
}
|
|
1130
|
-
|
|
911
|
+
__init4() {this.getConnectedClient = async () => {
|
|
1131
912
|
if (!this.isClosed) await this.client.connect();
|
|
1132
913
|
return this.client;
|
|
1133
914
|
}}
|
|
1134
|
-
},
|
|
915
|
+
}, _class);
|
|
1135
916
|
function parseSingleProjectionQueryStreamFilter(streamFilter) {
|
|
1136
917
|
const projectionName = _nullishCoalesce(streamFilter.projectionName, () => ( MongoDBDefaultInlineProjectionName));
|
|
1137
918
|
if ("streamName" in streamFilter) {
|