@event-driven-io/emmett-postgresql 0.20.2-alpha.4 → 0.20.2-alpha.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/index.cjs CHANGED
@@ -3,24 +3,32 @@
3
3
 
4
4
  var _dumbo = require('@event-driven-io/dumbo');
5
5
 
6
- // ../emmett/dist/chunk-3XBWME34.js
7
- var a = ((n) => (n.NOT_A_NONEMPTY_STRING = "NOT_A_NONEMPTY_STRING", n.NOT_A_POSITIVE_NUMBER = "NOT_A_POSITIVE_NUMBER", n.NOT_AN_UNSIGNED_BIGINT = "NOT_AN_UNSIGNED_BIGINT", n))(a || {});
8
- var s = (t4) => typeof t4 == "number" && t4 === t4;
9
- var m = (t4) => typeof t4 == "string";
10
- var T = (t4) => typeof t4 == "function" && t4.prototype && t4.prototype.constructor === t4;
11
- var o = class t extends Error {
6
+ // ../emmett/dist/chunk-AEEEXE2R.js
7
+ var isNumber = (val) => typeof val === "number" && val === val;
8
+ var isString = (val) => typeof val === "string";
9
+ var isErrorConstructor = (expect) => {
10
+ return typeof expect === "function" && expect.prototype && // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
11
+ expect.prototype.constructor === expect;
12
+ };
13
+ var EmmettError = class _EmmettError extends Error {
12
14
 
13
- constructor(e) {
14
- let i = e && typeof e == "object" && "errorCode" in e ? e.errorCode : s(e) ? e : 500, n = e && typeof e == "object" && "message" in e ? e.message : m(e) ? e : `Error with status code '${i}' ocurred during Emmett processing`;
15
- super(n), this.errorCode = i, Object.setPrototypeOf(this, t.prototype);
15
+ constructor(options) {
16
+ const errorCode = options && typeof options === "object" && "errorCode" in options ? options.errorCode : isNumber(options) ? options : 500;
17
+ const message = options && typeof options === "object" && "message" in options ? options.message : isString(options) ? options : `Error with status code '${errorCode}' ocurred during Emmett processing`;
18
+ super(message);
19
+ this.errorCode = errorCode;
20
+ Object.setPrototypeOf(this, _EmmettError.prototype);
16
21
  }
17
22
  };
18
- var g = class t2 extends o {
19
- constructor(i, n, u2) {
20
- super({ errorCode: 412, message: _nullishCoalesce(u2, () => ( `Expected version ${n.toString()} does not match current ${_optionalChain([i, 'optionalAccess', _ => _.toString, 'call', _2 => _2()])}`)) });
21
- this.current = i;
22
- this.expected = n;
23
- Object.setPrototypeOf(this, t2.prototype);
23
+ var ConcurrencyError = class _ConcurrencyError extends EmmettError {
24
+ constructor(current, expected, message) {
25
+ super({
26
+ errorCode: 412,
27
+ message: _nullishCoalesce(message, () => ( `Expected version ${expected.toString()} does not match current ${_optionalChain([current, 'optionalAccess', _2 => _2.toString, 'call', _3 => _3()])}`))
28
+ });
29
+ this.current = current;
30
+ this.expected = expected;
31
+ Object.setPrototypeOf(this, _ConcurrencyError.prototype);
24
32
  }
25
33
  };
26
34
 
@@ -42,27 +50,48 @@ var _asyncretry = require('async-retry'); var _asyncretry2 = _interopRequireDefa
42
50
 
43
51
 
44
52
 
45
- var L = (t4, e, r2) => ({ type: t4, data: e, metadata: r2 });
46
- var xe = "STREAM_EXISTS";
47
- var F = "STREAM_DOES_NOT_EXIST";
48
- var D = "NO_CONCURRENCY_CHECK";
49
- var ge = (t4, e, r2) => e === D ? true : e == F ? t4 === r2 : e == xe ? t4 !== r2 : t4 === e;
50
- var N = (t4, e, r2) => {
51
- if (e ??= D, !ge(t4, e, r2)) throw new b(t4, e);
53
+
54
+
55
+ var event = (type, data, metadata) => {
56
+ return {
57
+ type,
58
+ data,
59
+ metadata
60
+ };
61
+ };
62
+ var STREAM_EXISTS = "STREAM_EXISTS";
63
+ var STREAM_DOES_NOT_EXIST = "STREAM_DOES_NOT_EXIST";
64
+ var NO_CONCURRENCY_CHECK = "NO_CONCURRENCY_CHECK";
65
+ var matchesExpectedVersion = (current, expected, defaultVersion) => {
66
+ if (expected === NO_CONCURRENCY_CHECK) return true;
67
+ if (expected == STREAM_DOES_NOT_EXIST) return current === defaultVersion;
68
+ if (expected == STREAM_EXISTS) return current !== defaultVersion;
69
+ return current === expected;
52
70
  };
53
- var b = class t3 extends g {
54
- constructor(e, r2) {
55
- super(_optionalChain([e, 'optionalAccess', _3 => _3.toString, 'call', _4 => _4()]), _optionalChain([r2, 'optionalAccess', _5 => _5.toString, 'call', _6 => _6()])), Object.setPrototypeOf(this, t3.prototype);
71
+ var assertExpectedVersionMatchesCurrent = (current, expected, defaultVersion) => {
72
+ expected ??= NO_CONCURRENCY_CHECK;
73
+ if (!matchesExpectedVersion(current, expected, defaultVersion))
74
+ throw new ExpectedVersionConflictError(current, expected);
75
+ };
76
+ var ExpectedVersionConflictError = class _ExpectedVersionConflictError extends ConcurrencyError {
77
+ constructor(current, expected) {
78
+ super(_optionalChain([current, 'optionalAccess', _4 => _4.toString, 'call', _5 => _5()]), _optionalChain([expected, 'optionalAccess', _6 => _6.toString, 'call', _7 => _7()]));
79
+ Object.setPrototypeOf(this, _ExpectedVersionConflictError.prototype);
56
80
  }
57
81
  };
58
- var O = (t4, e = {}) => new S(t4, e);
59
- var S = (_class = class extends _webstreamspolyfill.TransformStream {
60
- constructor(r2, n = {}) {
61
- super({ cancel: (o2) => {
62
- console.log("Stream was canceled. Reason:", o2), this.stopChecking();
63
- } });_class.prototype.__init.call(this);_class.prototype.__init2.call(this);;
64
- this.onNoActiveReaderCallback = r2;
65
- this.streamId = _nullishCoalesce(_optionalChain([n, 'optionalAccess', _7 => _7.streamId]), () => ( _uuid.v4.call(void 0, ))), this.onNoActiveReaderCallback = r2, this.startChecking(_nullishCoalesce(_optionalChain([n, 'optionalAccess', _8 => _8.intervalCheckInMs]), () => ( 20)));
82
+ var notifyAboutNoActiveReadersStream = (onNoActiveReaderCallback, options = {}) => new NotifyAboutNoActiveReadersStream(onNoActiveReaderCallback, options);
83
+ var NotifyAboutNoActiveReadersStream = (_class = class extends _webstreamspolyfill.TransformStream {
84
+ constructor(onNoActiveReaderCallback, options = {}) {
85
+ super({
86
+ cancel: (reason) => {
87
+ console.log("Stream was canceled. Reason:", reason);
88
+ this.stopChecking();
89
+ }
90
+ });_class.prototype.__init.call(this);_class.prototype.__init2.call(this);;
91
+ this.onNoActiveReaderCallback = onNoActiveReaderCallback;
92
+ this.streamId = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _8 => _8.streamId]), () => ( _uuid.v4.call(void 0, )));
93
+ this.onNoActiveReaderCallback = onNoActiveReaderCallback;
94
+ this.startChecking(_nullishCoalesce(_optionalChain([options, 'optionalAccess', _9 => _9.intervalCheckInMs]), () => ( 20)));
66
95
  }
67
96
  __init() {this.checkInterval = null}
68
97
 
@@ -70,182 +99,322 @@ var S = (_class = class extends _webstreamspolyfill.TransformStream {
70
99
  get hasActiveSubscribers() {
71
100
  return !this._isStopped;
72
101
  }
73
- startChecking(r2) {
102
+ startChecking(interval) {
74
103
  this.checkInterval = setInterval(() => {
75
104
  this.checkNoActiveReader();
76
- }, r2);
105
+ }, interval);
77
106
  }
78
107
  stopChecking() {
79
- this.checkInterval && (clearInterval(this.checkInterval), this.checkInterval = null, this._isStopped = true, this.onNoActiveReaderCallback(this));
108
+ if (!this.checkInterval) return;
109
+ clearInterval(this.checkInterval);
110
+ this.checkInterval = null;
111
+ this._isStopped = true;
112
+ this.onNoActiveReaderCallback(this);
80
113
  }
81
114
  checkNoActiveReader() {
82
- !this.readable.locked && !this._isStopped && this.stopChecking();
115
+ if (!this.readable.locked && !this._isStopped) {
116
+ this.stopChecking();
117
+ }
83
118
  }
84
119
  }, _class);
85
- var d2 = (t4, e) => {
86
- if (Oe(t4)) return t4.equals(e);
87
- if (Array.isArray(t4)) return Array.isArray(e) && t4.length === e.length && t4.every((o2, a2) => d2(o2, e[a2]));
88
- if (typeof t4 != "object" || typeof e != "object" || t4 === null || e === null) return t4 === e;
89
- if (Array.isArray(e)) return false;
90
- let r2 = Object.keys(t4), n = Object.keys(e);
91
- if (r2.length !== n.length || !r2.every((o2) => n.includes(o2))) return false;
92
- for (let o2 in t4) {
93
- if (t4[o2] instanceof Function && e[o2] instanceof Function) continue;
94
- if (!d2(t4[o2], e[o2])) return false;
120
+ var deepEquals = (left, right) => {
121
+ if (isEquatable(left)) {
122
+ return left.equals(right);
123
+ }
124
+ if (Array.isArray(left)) {
125
+ return Array.isArray(right) && left.length === right.length && left.every((val, index) => deepEquals(val, right[index]));
126
+ }
127
+ if (typeof left !== "object" || typeof right !== "object" || left === null || right === null) {
128
+ return left === right;
129
+ }
130
+ if (Array.isArray(right)) return false;
131
+ const keys1 = Object.keys(left);
132
+ const keys2 = Object.keys(right);
133
+ if (keys1.length !== keys2.length || !keys1.every((key) => keys2.includes(key)))
134
+ return false;
135
+ for (const key in left) {
136
+ if (left[key] instanceof Function && right[key] instanceof Function)
137
+ continue;
138
+ const isEqual = deepEquals(left[key], right[key]);
139
+ if (!isEqual) {
140
+ return false;
141
+ }
95
142
  }
96
143
  return true;
97
144
  };
98
- var Oe = (t4) => t4 && typeof t4 == "object" && "equals" in t4 && typeof t4.equals == "function";
99
- var w2 = async (t4, e) => e === void 0 || e.retries === 0 ? t4() : _asyncretry2.default.call(void 0, async (r2) => {
100
- try {
101
- return await t4();
102
- } catch (n) {
103
- throw _optionalChain([e, 'optionalAccess', _9 => _9.shouldRetryError]) && !e.shouldRetryError(n) && r2(n), n;
145
+ var isEquatable = (left) => {
146
+ return left && typeof left === "object" && "equals" in left && typeof left["equals"] === "function";
147
+ };
148
+ var asyncRetry = async (fn, opts) => {
149
+ if (opts === void 0 || opts.retries === 0) return fn();
150
+ return _asyncretry2.default.call(void 0,
151
+ async (bail) => {
152
+ try {
153
+ return await fn();
154
+ } catch (error2) {
155
+ if (_optionalChain([opts, 'optionalAccess', _10 => _10.shouldRetryError]) && !opts.shouldRetryError(error2)) {
156
+ bail(error2);
157
+ }
158
+ throw error2;
159
+ }
160
+ },
161
+ _nullishCoalesce(opts, () => ( { retries: 0 }))
162
+ );
163
+ };
164
+ var projection = (definition) => definition;
165
+ var ParseError = class extends Error {
166
+ constructor(text) {
167
+ super(`Cannot parse! ${text}`);
104
168
  }
105
- }, _nullishCoalesce(e, () => ( { retries: 0 })));
106
- var Wr = (t4) => t4;
107
- var W = class extends Error {
108
- constructor(e) {
109
- super(`Cannot parse! ${e}`);
169
+ };
170
+ var JSONParser = {
171
+ stringify: (value, options) => {
172
+ return JSON.stringify(
173
+ _optionalChain([options, 'optionalAccess', _11 => _11.map]) ? options.map(value) : value,
174
+ //TODO: Consider adding support to DateTime and adding specific format to mark that's a bigint
175
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-return
176
+ (_, v) => typeof v === "bigint" ? v.toString() : v
177
+ );
178
+ },
179
+ parse: (text, options) => {
180
+ const parsed = JSON.parse(text, _optionalChain([options, 'optionalAccess', _12 => _12.reviver]));
181
+ if (_optionalChain([options, 'optionalAccess', _13 => _13.typeCheck]) && !_optionalChain([options, 'optionalAccess', _14 => _14.typeCheck, 'call', _15 => _15(parsed)]))
182
+ throw new ParseError(text);
183
+ return _optionalChain([options, 'optionalAccess', _16 => _16.map]) ? options.map(parsed) : parsed;
110
184
  }
111
185
  };
112
- var c2 = { stringify: (t4, e) => JSON.stringify(_optionalChain([e, 'optionalAccess', _10 => _10.map]) ? e.map(t4) : t4, (r2, n) => typeof n == "bigint" ? n.toString() : n), parse: (t4, e) => {
113
- let r2 = JSON.parse(t4, _optionalChain([e, 'optionalAccess', _11 => _11.reviver]));
114
- if (_optionalChain([e, 'optionalAccess', _12 => _12.typeCheck]) && !_optionalChain([e, 'optionalAccess', _13 => _13.typeCheck, 'call', _14 => _14(r2)])) throw new W(t4);
115
- return _optionalChain([e, 'optionalAccess', _15 => _15.map]) ? e.map(r2) : r2;
116
- } };
117
- var ae = (t4) => new (0, _webstreamspolyfill.TransformStream)({ transform(e, r2) {
118
- t4(e) && r2.enqueue(e);
119
- } });
120
- var se = (t4) => new (0, _webstreamspolyfill.TransformStream)({ transform(e, r2) {
121
- r2.enqueue(t4(e));
122
- } });
123
- var ie = (t4, e) => new g2(t4, e);
124
- var g2 = class extends _webstreamspolyfill.TransformStream {
186
+ var filter = (filter2) => new (0, _webstreamspolyfill.TransformStream)({
187
+ transform(chunk, controller) {
188
+ if (filter2(chunk)) {
189
+ controller.enqueue(chunk);
190
+ }
191
+ }
192
+ });
193
+ var map = (map2) => new (0, _webstreamspolyfill.TransformStream)({
194
+ transform(chunk, controller) {
195
+ controller.enqueue(map2(chunk));
196
+ }
197
+ });
198
+ var reduce = (reducer, initialValue) => new ReduceTransformStream(reducer, initialValue);
199
+ var ReduceTransformStream = class extends _webstreamspolyfill.TransformStream {
125
200
 
126
201
 
127
- constructor(e, r2) {
128
- super({ transform: (n) => {
129
- this.accumulator = this.reducer(this.accumulator, n);
130
- }, flush: (n) => {
131
- n.enqueue(this.accumulator), n.terminate();
132
- } }), this.accumulator = r2, this.reducer = e;
202
+ constructor(reducer, initialValue) {
203
+ super({
204
+ transform: (chunk) => {
205
+ this.accumulator = this.reducer(this.accumulator, chunk);
206
+ },
207
+ flush: (controller) => {
208
+ controller.enqueue(this.accumulator);
209
+ controller.terminate();
210
+ }
211
+ });
212
+ this.accumulator = initialValue;
213
+ this.reducer = reducer;
133
214
  }
134
215
  };
135
- var me = (t4, e, r2 = { forever: true, minTimeout: 25 }) => new (0, _webstreamspolyfill.TransformStream)({ start(n) {
136
- w2(() => Ne(t4, e, n), r2).catch((o2) => {
137
- n.error(o2);
138
- });
139
- } });
140
- var Ne = async (t4, e, r2) => {
141
- let o2 = t4().getReader();
216
+ var retryStream = (createSourceStream, handleChunk2, retryOptions = { forever: true, minTimeout: 25 }) => new (0, _webstreamspolyfill.TransformStream)({
217
+ start(controller) {
218
+ asyncRetry(
219
+ () => onRestream(createSourceStream, handleChunk2, controller),
220
+ retryOptions
221
+ ).catch((error2) => {
222
+ controller.error(error2);
223
+ });
224
+ }
225
+ });
226
+ var onRestream = async (createSourceStream, handleChunk2, controller) => {
227
+ const sourceStream = createSourceStream();
228
+ const reader = sourceStream.getReader();
142
229
  try {
143
- let a2;
230
+ let done;
144
231
  do {
145
- let i = await o2.read();
146
- a2 = i.done, await e(i, r2), a2 && r2.terminate();
147
- } while (!a2);
232
+ const result = await reader.read();
233
+ done = result.done;
234
+ await handleChunk2(result, controller);
235
+ if (done) {
236
+ controller.terminate();
237
+ }
238
+ } while (!done);
148
239
  } finally {
149
- o2.releaseLock();
240
+ reader.releaseLock();
150
241
  }
151
242
  };
152
- var de = (t4) => new h(t4);
153
- var h = (_class2 = class extends _webstreamspolyfill.TransformStream {
243
+ var skip = (limit) => new SkipTransformStream(limit);
244
+ var SkipTransformStream = (_class2 = class extends _webstreamspolyfill.TransformStream {
154
245
  __init3() {this.count = 0}
155
246
 
156
- constructor(e) {
157
- super({ transform: (r2, n) => {
158
- this.count++, this.count > this.skip && n.enqueue(r2);
159
- } });_class2.prototype.__init3.call(this);, this.skip = e;
247
+ constructor(skip2) {
248
+ super({
249
+ transform: (chunk, controller) => {
250
+ this.count++;
251
+ if (this.count > this.skip) {
252
+ controller.enqueue(chunk);
253
+ }
254
+ }
255
+ });_class2.prototype.__init3.call(this);;
256
+ this.skip = skip2;
160
257
  }
161
258
  }, _class2);
162
- var pe = (t4) => new (0, _webstreamspolyfill.TransformStream)({ transform(e, r2) {
163
- r2.enqueue(e), t4(e) && r2.terminate();
164
- } });
165
- var le = (t4) => new (0, _webstreamspolyfill.TransformStream)({ async transform(e, r2) {
166
- if (!t4(e)) {
167
- r2.enqueue(e);
168
- return;
259
+ var stopAfter = (stopCondition) => new (0, _webstreamspolyfill.TransformStream)({
260
+ transform(chunk, controller) {
261
+ controller.enqueue(chunk);
262
+ if (stopCondition(chunk)) {
263
+ controller.terminate();
264
+ }
169
265
  }
170
- await Promise.resolve(), r2.terminate();
171
- } });
172
- var ce = (t4) => new C(t4);
173
- var C = (_class3 = class extends _webstreamspolyfill.TransformStream {
266
+ });
267
+ var stopOn = (stopCondition) => new (0, _webstreamspolyfill.TransformStream)({
268
+ async transform(chunk, controller) {
269
+ if (!stopCondition(chunk)) {
270
+ controller.enqueue(chunk);
271
+ return;
272
+ }
273
+ await Promise.resolve();
274
+ controller.terminate();
275
+ }
276
+ });
277
+ var take = (limit) => new TakeTransformStream(limit);
278
+ var TakeTransformStream = (_class3 = class extends _webstreamspolyfill.TransformStream {
174
279
  __init4() {this.count = 0}
175
280
 
176
- constructor(e) {
177
- super({ transform: (r2, n) => {
178
- this.count < this.limit ? (this.count++, n.enqueue(r2)) : n.terminate();
179
- } });_class3.prototype.__init4.call(this);, this.limit = e;
281
+ constructor(limit) {
282
+ super({
283
+ transform: (chunk, controller) => {
284
+ if (this.count < this.limit) {
285
+ this.count++;
286
+ controller.enqueue(chunk);
287
+ } else {
288
+ controller.terminate();
289
+ }
290
+ }
291
+ });_class3.prototype.__init4.call(this);;
292
+ this.limit = limit;
180
293
  }
181
294
  }, _class3);
182
- var ue = (t4) => new (0, _webstreamspolyfill.TransformStream)({ start(e) {
183
- let r2 = setTimeout(() => {
184
- e.terminate();
185
- }, t4), n = e.terminate.bind(e);
186
- e.terminate = () => {
187
- clearTimeout(r2), n();
188
- };
189
- }, transform(e, r2) {
190
- r2.enqueue(e);
191
- } });
192
- var fe = { filter: ae, take: ce, TakeTransformStream: C, skip: de, SkipTransformStream: h, map: se, notifyAboutNoActiveReadersStream: O, NotifyAboutNoActiveReadersStream: S, reduce: ie, ReduceTransformStream: g2, retry: me, stopAfter: pe, stopOn: le, waitAtMost: ue };
193
- var { retry: Be } = fe;
194
- var p2 = class extends Error {
195
- constructor(e) {
196
- super(e);
295
+ var waitAtMost = (waitTimeInMs) => new (0, _webstreamspolyfill.TransformStream)({
296
+ start(controller) {
297
+ const timeoutId = setTimeout(() => {
298
+ controller.terminate();
299
+ }, waitTimeInMs);
300
+ const originalTerminate = controller.terminate.bind(controller);
301
+ controller.terminate = () => {
302
+ clearTimeout(timeoutId);
303
+ originalTerminate();
304
+ };
305
+ },
306
+ transform(chunk, controller) {
307
+ controller.enqueue(chunk);
197
308
  }
309
+ });
310
+ var streamTransformations = {
311
+ filter,
312
+ take,
313
+ TakeTransformStream,
314
+ skip,
315
+ SkipTransformStream,
316
+ map,
317
+ notifyAboutNoActiveReadersStream,
318
+ NotifyAboutNoActiveReadersStream,
319
+ reduce,
320
+ ReduceTransformStream,
321
+ retry: retryStream,
322
+ stopAfter,
323
+ stopOn,
324
+ waitAtMost
198
325
  };
199
- var po = (t4) => {
200
- throw new p2(_nullishCoalesce(t4, () => ( "That should not ever happened, right?")));
326
+ var { retry: retry2 } = streamTransformations;
327
+ var AssertionError = class extends Error {
328
+ constructor(message) {
329
+ super(message);
330
+ }
331
+ };
332
+ var assertFails = (message) => {
333
+ throw new AssertionError(_nullishCoalesce(message, () => ( "That should not ever happened, right?")));
201
334
  };
202
- var Ke = (t4, e, r2) => {
203
- if (!d2(t4, e)) throw new p2(_nullishCoalesce(r2, () => ( `subObj:
204
- ${c2.stringify(e)}
335
+ var assertDeepEqual = (actual, expected, message) => {
336
+ if (!deepEquals(actual, expected))
337
+ throw new AssertionError(
338
+ _nullishCoalesce(message, () => ( `subObj:
339
+ ${JSONParser.stringify(expected)}
205
340
  is not equal to
206
- ${c2.stringify(t4)}`)));
341
+ ${JSONParser.stringify(actual)}`))
342
+ );
207
343
  };
208
- function s2(t4, e) {
209
- if (!t4) throw new p2(_nullishCoalesce(e, () => ( "Condition is false")));
344
+ function assertTrue(condition, message) {
345
+ if (!condition) throw new AssertionError(_nullishCoalesce(message, () => ( `Condition is false`)));
210
346
  }
211
- function U(t4, e) {
212
- if (!t4) throw new p2(_nullishCoalesce(e, () => ( "Condition is not truthy")));
347
+ function assertOk(obj, message) {
348
+ if (!obj) throw new AssertionError(_nullishCoalesce(message, () => ( `Condition is not truthy`)));
213
349
  }
214
- function u(t4, e, r2) {
215
- if (t4 !== e) throw new p2(`${_nullishCoalesce(r2, () => ( "Objects are not equal"))}:
216
- Expected: ${c2.stringify(t4)}
217
- Actual:${c2.stringify(e)}`);
350
+ function assertEqual(expected, actual, message) {
351
+ if (expected !== actual)
352
+ throw new AssertionError(
353
+ `${_nullishCoalesce(message, () => ( "Objects are not equal"))}:
354
+ Expected: ${JSONParser.stringify(expected)}
355
+ Actual:${JSONParser.stringify(actual)}`
356
+ );
218
357
  }
219
- function Ee(t4, e, r2) {
220
- if (t4 === e) throw new p2(_nullishCoalesce(r2, () => ( `Objects are equal: ${c2.stringify(t4)}`)));
358
+ function assertNotEqual(obj, other, message) {
359
+ if (obj === other)
360
+ throw new AssertionError(
361
+ _nullishCoalesce(message, () => ( `Objects are equal: ${JSONParser.stringify(obj)}`))
362
+ );
221
363
  }
222
- function vo(t4) {
223
- Ee(t4, null), U(t4);
364
+ function assertIsNotNull(result) {
365
+ assertNotEqual(result, null);
366
+ assertOk(result);
224
367
  }
225
- var go = (t4) => ({ isEmpty: () => u(t4.length, 0), isNotEmpty: () => Ee(t4.length, 0), hasSize: (e) => u(t4.length, e), containsElements: (...e) => {
226
- s2(e.every((r2) => e.some((n) => d2(r2, n))));
227
- }, containsExactlyInAnyOrder: (...e) => {
228
- u(t4.length, e.length), s2(t4.every((r2) => e.some((n) => d2(r2, n))));
229
- }, containsExactlyInAnyOrderElementsOf: (e) => {
230
- u(t4.length, e.length), s2(t4.every((r2) => e.some((n) => d2(r2, n))));
231
- }, containsExactlyElementsOf: (e) => {
232
- u(t4.length, e.length);
233
- for (let r2 = 0; r2 < t4.length; r2++) s2(d2(t4[r2], e[r2]));
234
- }, containsExactly: (e) => {
235
- u(t4.length, 1), s2(d2(t4[0], e));
236
- }, contains: (e) => {
237
- s2(t4.some((r2) => d2(r2, e)));
238
- }, containsOnlyOnceElementsOf: (e) => {
239
- s2(e.map((r2) => t4.filter((n) => d2(n, r2)).length).filter((r2) => r2 === 1).length === e.length);
240
- }, containsAnyOf: (...e) => {
241
- s2(t4.some((r2) => e.some((n) => d2(r2, n))));
242
- }, allMatch: (e) => {
243
- s2(t4.every(e));
244
- }, anyMatches: (e) => {
245
- s2(t4.some(e));
246
- }, allMatchAsync: async (e) => {
247
- for (let r2 of t4) s2(await e(r2));
248
- } });
368
+ var assertThatArray = (array) => {
369
+ return {
370
+ isEmpty: () => assertEqual(array.length, 0),
371
+ isNotEmpty: () => assertNotEqual(array.length, 0),
372
+ hasSize: (length) => assertEqual(array.length, length),
373
+ containsElements: (...other) => {
374
+ assertTrue(other.every((ts) => other.some((o) => deepEquals(ts, o))));
375
+ },
376
+ containsExactlyInAnyOrder: (...other) => {
377
+ assertEqual(array.length, other.length);
378
+ assertTrue(array.every((ts) => other.some((o) => deepEquals(ts, o))));
379
+ },
380
+ containsExactlyInAnyOrderElementsOf: (other) => {
381
+ assertEqual(array.length, other.length);
382
+ assertTrue(array.every((ts) => other.some((o) => deepEquals(ts, o))));
383
+ },
384
+ containsExactlyElementsOf: (other) => {
385
+ assertEqual(array.length, other.length);
386
+ for (let i = 0; i < array.length; i++) {
387
+ assertTrue(deepEquals(array[i], other[i]));
388
+ }
389
+ },
390
+ containsExactly: (elem) => {
391
+ assertEqual(array.length, 1);
392
+ assertTrue(deepEquals(array[0], elem));
393
+ },
394
+ contains: (elem) => {
395
+ assertTrue(array.some((a) => deepEquals(a, elem)));
396
+ },
397
+ containsOnlyOnceElementsOf: (other) => {
398
+ assertTrue(
399
+ other.map((o) => array.filter((a) => deepEquals(a, o)).length).filter((a) => a === 1).length === other.length
400
+ );
401
+ },
402
+ containsAnyOf: (...other) => {
403
+ assertTrue(array.some((a) => other.some((o) => deepEquals(a, o))));
404
+ },
405
+ allMatch: (matches) => {
406
+ assertTrue(array.every(matches));
407
+ },
408
+ anyMatches: (matches) => {
409
+ assertTrue(array.some(matches));
410
+ },
411
+ allMatchAsync: async (matches) => {
412
+ for (const item of array) {
413
+ assertTrue(await matches(item));
414
+ }
415
+ }
416
+ };
417
+ };
249
418
 
250
419
  // src/eventStore/postgreSQLEventStore.ts
251
420
  require('pg');
@@ -278,13 +447,13 @@ var withoutIdAndVersion = (doc) => {
278
447
  };
279
448
  var assertDocumentsEqual = (actual, expected) => {
280
449
  if ("_id" in expected)
281
- u(
450
+ assertEqual(
282
451
  expected._id,
283
452
  actual._id,
284
453
  // eslint-disable-next-line @typescript-eslint/restrict-template-expressions
285
454
  `Document ids are not matching! Expected: ${expected._id}, actual: ${actual._id}`
286
455
  );
287
- return Ke(
456
+ return assertDeepEqual(
288
457
  withoutIdAndVersion(actual),
289
458
  withoutIdAndVersion(expected)
290
459
  );
@@ -294,7 +463,7 @@ var documentExists = (document, options) => (assertOptions) => withCollection(
294
463
  const result = await collection.findOne(
295
464
  "withId" in options ? { _id: options.withId } : options.matchingFilter
296
465
  );
297
- vo(result);
466
+ assertIsNotNull(result);
298
467
  assertDocumentsEqual(result, document);
299
468
  },
300
469
  { ...options, ...assertOptions }
@@ -304,13 +473,13 @@ var documentsAreTheSame = (documents, options) => (assertOptions) => withCollect
304
473
  const result = await collection.find(
305
474
  "withId" in options ? { _id: options.withId } : options.matchingFilter
306
475
  );
307
- u(
476
+ assertEqual(
308
477
  documents.length,
309
478
  result.length,
310
479
  "Different Documents Count than expected"
311
480
  );
312
481
  for (let i = 0; i < documents.length; i++) {
313
- go(result).contains(documents[i]);
482
+ assertThatArray(result).contains(documents[i]);
314
483
  }
315
484
  },
316
485
  { ...options, ...assertOptions }
@@ -320,7 +489,7 @@ var documentsMatchingHaveCount = (expectedCount, options) => (assertOptions) =>
320
489
  const result = await collection.find(
321
490
  "withId" in options ? { _id: options.withId } : options.matchingFilter
322
491
  );
323
- u(
492
+ assertEqual(
324
493
  expectedCount,
325
494
  result.length,
326
495
  "Different Documents Count than expected"
@@ -333,7 +502,7 @@ var documentMatchingExists = (options) => (assertOptions) => withCollection(
333
502
  const result = await collection.find(
334
503
  "withId" in options ? { _id: options.withId } : options.matchingFilter
335
504
  );
336
- go(result).isNotEmpty();
505
+ assertThatArray(result).isNotEmpty();
337
506
  },
338
507
  { ...options, ...assertOptions }
339
508
  );
@@ -342,7 +511,7 @@ var documentDoesNotExist = (options) => (assertOptions) => withCollection(
342
511
  const result = await collection.findOne(
343
512
  "withId" in options ? { _id: options.withId } : options.matchingFilter
344
513
  );
345
- vo(result);
514
+ assertIsNotNull(result);
346
515
  },
347
516
  { ...options, ...assertOptions }
348
517
  );
@@ -365,22 +534,22 @@ var expectPongoDocuments = {
365
534
  })
366
535
  };
367
536
  },
368
- matching: (filter) => {
537
+ matching: (filter2) => {
369
538
  return {
370
539
  toBeTheSame: (documents) => documentsAreTheSame(documents, {
371
- matchingFilter: filter,
540
+ matchingFilter: filter2,
372
541
  inCollection: collectionName
373
542
  }),
374
543
  toHaveCount: (expectedCount) => documentsMatchingHaveCount(expectedCount, {
375
- matchingFilter: filter,
544
+ matchingFilter: filter2,
376
545
  inCollection: collectionName
377
546
  }),
378
547
  toExist: () => documentMatchingExists({
379
- matchingFilter: filter,
548
+ matchingFilter: filter2,
380
549
  inCollection: collectionName
381
550
  }),
382
551
  notToExist: () => documentDoesNotExist({
383
- matchingFilter: filter,
552
+ matchingFilter: filter2,
384
553
  inCollection: collectionName
385
554
  })
386
555
  };
@@ -414,14 +583,14 @@ var pongoMultiStreamProjection = (options) => {
414
583
  return pongoProjection({
415
584
  handle: async (events, { pongo }) => {
416
585
  const collection = pongo.db().collection(collectionName);
417
- for (const event of events) {
418
- await collection.handle(getDocumentId(event), async (document) => {
586
+ for (const event2 of events) {
587
+ await collection.handle(getDocumentId(event2), async (document) => {
419
588
  return "initialState" in options ? await options.evolve(
420
589
  _nullishCoalesce(document, () => ( options.initialState())),
421
- event
590
+ event2
422
591
  ) : await options.evolve(
423
592
  document,
424
- event
593
+ event2
425
594
  );
426
595
  });
427
596
  }
@@ -432,7 +601,7 @@ var pongoMultiStreamProjection = (options) => {
432
601
  var pongoSingleStreamProjection = (options) => {
433
602
  return pongoMultiStreamProjection({
434
603
  ...options,
435
- getDocumentId: (event) => event.metadata.streamName
604
+ getDocumentId: (event2) => event2.metadata.streamName
436
605
  });
437
606
  };
438
607
 
@@ -444,7 +613,7 @@ var pongoSingleStreamProjection = (options) => {
444
613
  var PostgreSQLProjectionSpec = {
445
614
  for: (options) => {
446
615
  {
447
- const { projection, ...dumoOptions } = options;
616
+ const { projection: projection2, ...dumoOptions } = options;
448
617
  const { connectionString } = dumoOptions;
449
618
  return (givenEvents) => {
450
619
  return {
@@ -452,13 +621,13 @@ var PostgreSQLProjectionSpec = {
452
621
  const allEvents = [];
453
622
  const run = async (pool) => {
454
623
  let globalPosition = 0n;
455
- const numberOfTimes = _nullishCoalesce(_optionalChain([options2, 'optionalAccess', _16 => _16.numberOfTimes]), () => ( 1));
456
- for (const event of [
624
+ const numberOfTimes = _nullishCoalesce(_optionalChain([options2, 'optionalAccess', _17 => _17.numberOfTimes]), () => ( 1));
625
+ for (const event2 of [
457
626
  ...givenEvents,
458
627
  ...Array.from({ length: numberOfTimes }).flatMap(() => events)
459
628
  ]) {
460
629
  allEvents.push({
461
- ...event,
630
+ ...event2,
462
631
  metadata: {
463
632
  ...{
464
633
  globalPosition: ++globalPosition,
@@ -466,14 +635,14 @@ var PostgreSQLProjectionSpec = {
466
635
  streamName: `test-${_uuid.v4.call(void 0, )}`,
467
636
  eventId: _uuid.v4.call(void 0, )
468
637
  },
469
- ..._nullishCoalesce(event.metadata, () => ( {}))
638
+ ..._nullishCoalesce(event2.metadata, () => ( {}))
470
639
  }
471
640
  });
472
641
  }
473
642
  await pool.withTransaction(
474
643
  (transaction) => handleProjections({
475
644
  events: allEvents,
476
- projections: [projection],
645
+ projections: [projection2],
477
646
  connection: {
478
647
  connectionString,
479
648
  transaction
@@ -488,7 +657,7 @@ var PostgreSQLProjectionSpec = {
488
657
  await run(pool);
489
658
  const succeeded = await assert({ pool, connectionString });
490
659
  if (succeeded !== void 0 && succeeded === false)
491
- po(
660
+ assertFails(
492
661
  _nullishCoalesce(message, () => ( "Projection specification didn't match the criteria"))
493
662
  );
494
663
  } finally {
@@ -499,25 +668,25 @@ var PostgreSQLProjectionSpec = {
499
668
  const pool = _dumbo.dumbo.call(void 0, dumoOptions);
500
669
  try {
501
670
  await run(pool);
502
- throw new p2("Handler did not fail as expected");
671
+ throw new AssertionError("Handler did not fail as expected");
503
672
  } catch (error) {
504
- if (error instanceof p2) throw error;
673
+ if (error instanceof AssertionError) throw error;
505
674
  if (args.length === 0) return;
506
- if (!T(args[0])) {
507
- s2(
675
+ if (!isErrorConstructor(args[0])) {
676
+ assertTrue(
508
677
  args[0](error),
509
- `Error didn't match the error condition: ${_optionalChain([error, 'optionalAccess', _17 => _17.toString, 'call', _18 => _18()])}`
678
+ `Error didn't match the error condition: ${_optionalChain([error, 'optionalAccess', _18 => _18.toString, 'call', _19 => _19()])}`
510
679
  );
511
680
  return;
512
681
  }
513
- s2(
682
+ assertTrue(
514
683
  error instanceof args[0],
515
- `Caught error is not an instance of the expected type: ${_optionalChain([error, 'optionalAccess', _19 => _19.toString, 'call', _20 => _20()])}`
684
+ `Caught error is not an instance of the expected type: ${_optionalChain([error, 'optionalAccess', _20 => _20.toString, 'call', _21 => _21()])}`
516
685
  );
517
686
  if (args[1]) {
518
- s2(
687
+ assertTrue(
519
688
  args[1](error),
520
- `Error didn't match the error condition: ${_optionalChain([error, 'optionalAccess', _21 => _21.toString, 'call', _22 => _22()])}`
689
+ `Error didn't match the error condition: ${_optionalChain([error, 'optionalAccess', _22 => _22.toString, 'call', _23 => _23()])}`
521
690
  );
522
691
  }
523
692
  } finally {
@@ -531,12 +700,12 @@ var PostgreSQLProjectionSpec = {
531
700
  }
532
701
  }
533
702
  };
534
- var eventInStream = (streamName, event) => {
703
+ var eventInStream = (streamName, event2) => {
535
704
  return {
536
- ...event,
705
+ ...event2,
537
706
  metadata: {
538
- ..._nullishCoalesce(event.metadata, () => ( {})),
539
- streamName: _nullishCoalesce(_optionalChain([event, 'access', _23 => _23.metadata, 'optionalAccess', _24 => _24.streamName]), () => ( streamName))
707
+ ..._nullishCoalesce(event2.metadata, () => ( {})),
708
+ streamName: _nullishCoalesce(_optionalChain([event2, 'access', _24 => _24.metadata, 'optionalAccess', _25 => _25.streamName]), () => ( streamName))
540
709
  }
541
710
  };
542
711
  };
@@ -546,7 +715,7 @@ var eventsInStream = (streamName, events) => {
546
715
  var newEventsInStream = eventsInStream;
547
716
  var assertSQLQueryResultMatches = (sql3, rows) => async ({ pool: { execute } }) => {
548
717
  const result = await execute.query(sql3);
549
- go(rows).containsExactlyInAnyOrder(...result.rows);
718
+ assertThatArray(rows).containsExactlyInAnyOrder(...result.rows);
550
719
  };
551
720
  var expectSQL = {
552
721
  query: (sql3) => ({
@@ -565,11 +734,11 @@ var handleProjections = async (options) => {
565
734
  } = options;
566
735
  const eventTypes = events.map((e) => e.type);
567
736
  const projections = allProjections.filter(
568
- (p3) => p3.canHandle.some((type) => eventTypes.includes(type))
737
+ (p) => p.canHandle.some((type) => eventTypes.includes(type))
569
738
  );
570
739
  const client = await transaction.connection.open();
571
- for (const projection of projections) {
572
- await projection.handle(events, {
740
+ for (const projection2 of projections) {
741
+ await projection2.handle(events, {
573
742
  connectionString,
574
743
  client,
575
744
  transaction,
@@ -577,7 +746,7 @@ var handleProjections = async (options) => {
577
746
  });
578
747
  }
579
748
  };
580
- var postgreSQLProjection = (definition) => Wr(definition);
749
+ var postgreSQLProjection = (definition) => projection(definition);
581
750
  var postgreSQLRawBatchSQLProjection = (handle, ...canHandle) => postgreSQLProjection({
582
751
  canHandle,
583
752
  handle: async (events, context) => {
@@ -588,8 +757,8 @@ var postgreSQLRawBatchSQLProjection = (handle, ...canHandle) => postgreSQLProjec
588
757
  var postgreSQLRawSQLProjection = (handle, ...canHandle) => postgreSQLRawBatchSQLProjection(
589
758
  async (events, context) => {
590
759
  const sqls = [];
591
- for (const event of events) {
592
- sqls.push(await handle(event, context));
760
+ for (const event2 of events) {
761
+ sqls.push(await handle(event2, context));
593
762
  }
594
763
  return sqls;
595
764
  },
@@ -729,7 +898,7 @@ var appendToStream = (pool, streamName, streamType, events, options) => pool.wit
729
898
  let appendResult;
730
899
  try {
731
900
  const expectedStreamVersion = toExpectedVersion(
732
- _optionalChain([options, 'optionalAccess', _25 => _25.expectedStreamVersion])
901
+ _optionalChain([options, 'optionalAccess', _26 => _26.expectedStreamVersion])
733
902
  );
734
903
  const eventsToAppend = events.map((e, i) => ({
735
904
  ...e,
@@ -749,7 +918,7 @@ var appendToStream = (pool, streamName, streamType, events, options) => pool.wit
749
918
  expectedStreamVersion
750
919
  }
751
920
  );
752
- if (_optionalChain([options, 'optionalAccess', _26 => _26.preCommitHook]))
921
+ if (_optionalChain([options, 'optionalAccess', _27 => _27.preCommitHook]))
753
922
  await options.preCommitHook(eventsToAppend, { transaction });
754
923
  } catch (error) {
755
924
  if (!isOptimisticConcurrencyError(error)) throw error;
@@ -778,9 +947,9 @@ var appendToStream = (pool, streamName, streamType, events, options) => pool.wit
778
947
  });
779
948
  var toExpectedVersion = (expected) => {
780
949
  if (expected === void 0) return null;
781
- if (expected === D) return null;
782
- if (expected == F) return null;
783
- if (expected == xe) return null;
950
+ if (expected === NO_CONCURRENCY_CHECK) return null;
951
+ if (expected == STREAM_DOES_NOT_EXIST) return null;
952
+ if (expected == STREAM_EXISTS) return null;
784
953
  return expected;
785
954
  };
786
955
  var isOptimisticConcurrencyError = (error) => error instanceof Error && "code" in error && error.code === "23505";
@@ -799,14 +968,14 @@ var appendEventsRaw = (execute, streamId, streamType, events, options) => _dumbo
799
968
  %L::text
800
969
  )`,
801
970
  events.map((e) => _dumbo.sql.call(void 0, "%L", e.metadata.eventId)).join(","),
802
- events.map((e) => _dumbo.sql.call(void 0, "%L", c2.stringify(e.data))).join(","),
803
- events.map((e) => _dumbo.sql.call(void 0, "%L", c2.stringify(_nullishCoalesce(e.metadata, () => ( {}))))).join(","),
971
+ events.map((e) => _dumbo.sql.call(void 0, "%L", JSONParser.stringify(e.data))).join(","),
972
+ events.map((e) => _dumbo.sql.call(void 0, "%L", JSONParser.stringify(_nullishCoalesce(e.metadata, () => ( {}))))).join(","),
804
973
  events.map(() => `'1'`).join(","),
805
974
  events.map((e) => _dumbo.sql.call(void 0, "%L", e.type)).join(","),
806
975
  streamId,
807
976
  streamType,
808
- _nullishCoalesce(_optionalChain([options, 'optionalAccess', _27 => _27.expectedStreamVersion]), () => ( "NULL")),
809
- _nullishCoalesce(_optionalChain([options, 'optionalAccess', _28 => _28.partition]), () => ( defaultTag))
977
+ _nullishCoalesce(_optionalChain([options, 'optionalAccess', _28 => _28.expectedStreamVersion]), () => ( "NULL")),
978
+ _nullishCoalesce(_optionalChain([options, 'optionalAccess', _29 => _29.partition]), () => ( defaultTag))
810
979
  )
811
980
  )
812
981
  );
@@ -1124,11 +1293,11 @@ var readStream = async (execute, streamId, options) => {
1124
1293
  FROM ${eventsTable.name}
1125
1294
  WHERE stream_id = %L AND partition = %L AND is_archived = FALSE ${fromCondition} ${toCondition}`,
1126
1295
  streamId,
1127
- _nullishCoalesce(_optionalChain([options, 'optionalAccess', _29 => _29.partition]), () => ( defaultTag))
1296
+ _nullishCoalesce(_optionalChain([options, 'optionalAccess', _30 => _30.partition]), () => ( defaultTag))
1128
1297
  )
1129
1298
  ),
1130
1299
  (row) => {
1131
- const rawEvent = L(
1300
+ const rawEvent = event(
1132
1301
  row.event_type,
1133
1302
  row.event_data,
1134
1303
  row.event_metadata
@@ -1188,7 +1357,7 @@ var getPostgreSQLEventStore = (connectionString, options = defaultPostgreSQLOpti
1188
1357
  };
1189
1358
  const pool = "dumbo" in poolOptions ? poolOptions.dumbo : _dumbo.dumbo.call(void 0, poolOptions);
1190
1359
  let migrateSchema;
1191
- const autoGenerateSchema = _optionalChain([options, 'access', _30 => _30.schema, 'optionalAccess', _31 => _31.autoMigration]) === void 0 || _optionalChain([options, 'access', _32 => _32.schema, 'optionalAccess', _33 => _33.autoMigration]) !== "None";
1360
+ const autoGenerateSchema = _optionalChain([options, 'access', _31 => _31.schema, 'optionalAccess', _32 => _32.autoMigration]) === void 0 || _optionalChain([options, 'access', _33 => _33.schema, 'optionalAccess', _34 => _34.autoMigration]) !== "None";
1192
1361
  const ensureSchemaExists = () => {
1193
1362
  if (!autoGenerateSchema) return Promise.resolve();
1194
1363
  if (!migrateSchema) {
@@ -1196,7 +1365,7 @@ var getPostgreSQLEventStore = (connectionString, options = defaultPostgreSQLOpti
1196
1365
  }
1197
1366
  return migrateSchema;
1198
1367
  };
1199
- const inlineProjections = (_nullishCoalesce(options.projections, () => ( []))).filter(({ type }) => type === "inline").map(({ projection }) => projection);
1368
+ const inlineProjections = (_nullishCoalesce(options.projections, () => ( []))).filter(({ type }) => type === "inline").map(({ projection: projection2 }) => projection2);
1200
1369
  const preCommitHook = inlineProjections.length > 0 ? (events, { transaction }) => handleProjections({
1201
1370
  projections: inlineProjections,
1202
1371
  connection: {
@@ -1215,18 +1384,18 @@ var getPostgreSQLEventStore = (connectionString, options = defaultPostgreSQLOpti
1215
1384
  },
1216
1385
  async aggregateStream(streamName, options2) {
1217
1386
  const { evolve, initialState, read } = options2;
1218
- const expectedStreamVersion = _optionalChain([read, 'optionalAccess', _34 => _34.expectedStreamVersion]);
1387
+ const expectedStreamVersion = _optionalChain([read, 'optionalAccess', _35 => _35.expectedStreamVersion]);
1219
1388
  let state = initialState();
1220
1389
  const result = await this.readStream(streamName, options2.read);
1221
1390
  const currentStreamVersion = result.currentStreamVersion;
1222
- N(
1391
+ assertExpectedVersionMatchesCurrent(
1223
1392
  currentStreamVersion,
1224
1393
  expectedStreamVersion,
1225
1394
  PostgreSQLEventStoreDefaultStreamVersion
1226
1395
  );
1227
- for (const event of result.events) {
1228
- if (!event) continue;
1229
- state = evolve(state, event);
1396
+ for (const event2 of result.events) {
1397
+ if (!event2) continue;
1398
+ state = evolve(state, event2);
1230
1399
  }
1231
1400
  return {
1232
1401
  currentStreamVersion,
@@ -1253,10 +1422,10 @@ var getPostgreSQLEventStore = (connectionString, options = defaultPostgreSQLOpti
1253
1422
  }
1254
1423
  );
1255
1424
  if (!appendResult.success)
1256
- throw new b(
1425
+ throw new ExpectedVersionConflictError(
1257
1426
  -1n,
1258
1427
  //TODO: Return actual version in case of error
1259
- _nullishCoalesce(_optionalChain([options2, 'optionalAccess', _35 => _35.expectedStreamVersion]), () => ( D))
1428
+ _nullishCoalesce(_optionalChain([options2, 'optionalAccess', _36 => _36.expectedStreamVersion]), () => ( NO_CONCURRENCY_CHECK))
1260
1429
  );
1261
1430
  return {
1262
1431
  nextExpectedStreamVersion: appendResult.nextStreamPosition,