@event-driven-io/emmett-sqlite 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 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(); } } async function _asyncNullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return await 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; var _class2; var _class3;// src/connection/sqliteConnection.ts
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(); } } async function _asyncNullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return await 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; }// src/connection/sqliteConnection.ts
2
2
  var _sqlite3 = require('sqlite3'); var _sqlite32 = _interopRequireDefault(_sqlite3);
3
3
  var isSQLiteError = (error) => {
4
4
  if (error instanceof Error && "code" in error) {
@@ -139,23 +139,6 @@ var _uuid = require('uuid');
139
139
 
140
140
  var _asyncretry = require('async-retry'); var _asyncretry2 = _interopRequireDefault(_asyncretry);
141
141
 
142
- var _webstreamspolyfill = require('web-streams-polyfill');
143
-
144
-
145
-
146
-
147
-
148
-
149
-
150
-
151
-
152
-
153
-
154
-
155
-
156
-
157
-
158
-
159
142
  var STREAM_EXISTS = "STREAM_EXISTS";
160
143
  var STREAM_DOES_NOT_EXIST = "STREAM_DOES_NOT_EXIST";
161
144
  var NO_CONCURRENCY_CHECK = "NO_CONCURRENCY_CHECK";
@@ -197,67 +180,6 @@ var JSONParser = {
197
180
  return _optionalChain([options, 'optionalAccess', _13 => _13.map]) ? options.map(parsed) : parsed;
198
181
  }
199
182
  };
200
- var asyncRetry = async (fn, opts) => {
201
- if (opts === void 0 || opts.retries === 0) return fn();
202
- return _asyncretry2.default.call(void 0,
203
- async (bail) => {
204
- try {
205
- const result = await fn();
206
- if (_optionalChain([opts, 'optionalAccess', _14 => _14.shouldRetryResult]) && opts.shouldRetryResult(result)) {
207
- throw new EmmettError(
208
- `Retrying because of result: ${JSONParser.stringify(result)}`
209
- );
210
- }
211
- return result;
212
- } catch (error2) {
213
- if (_optionalChain([opts, 'optionalAccess', _15 => _15.shouldRetryError]) && !opts.shouldRetryError(error2)) {
214
- bail(error2);
215
- return void 0;
216
- }
217
- throw error2;
218
- }
219
- },
220
- _nullishCoalesce(opts, () => ( { retries: 0 }))
221
- );
222
- };
223
- var notifyAboutNoActiveReadersStream = (onNoActiveReaderCallback, options = {}) => new NotifyAboutNoActiveReadersStream(onNoActiveReaderCallback, options);
224
- var NotifyAboutNoActiveReadersStream = (_class = class extends _webstreamspolyfill.TransformStream {
225
- constructor(onNoActiveReaderCallback, options = {}) {
226
- super({
227
- cancel: (reason) => {
228
- console.log("Stream was canceled. Reason:", reason);
229
- this.stopChecking();
230
- }
231
- });_class.prototype.__init.call(this);_class.prototype.__init2.call(this);;
232
- this.onNoActiveReaderCallback = onNoActiveReaderCallback;
233
- this.streamId = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _16 => _16.streamId]), () => ( _uuid.v4.call(void 0, )));
234
- this.onNoActiveReaderCallback = onNoActiveReaderCallback;
235
- this.startChecking(_nullishCoalesce(_optionalChain([options, 'optionalAccess', _17 => _17.intervalCheckInMs]), () => ( 20)));
236
- }
237
- __init() {this.checkInterval = null}
238
-
239
- __init2() {this._isStopped = false}
240
- get hasActiveSubscribers() {
241
- return !this._isStopped;
242
- }
243
- startChecking(interval) {
244
- this.checkInterval = setInterval(() => {
245
- this.checkNoActiveReader();
246
- }, interval);
247
- }
248
- stopChecking() {
249
- if (!this.checkInterval) return;
250
- clearInterval(this.checkInterval);
251
- this.checkInterval = null;
252
- this._isStopped = true;
253
- this.onNoActiveReaderCallback(this);
254
- }
255
- checkNoActiveReader() {
256
- if (!this.readable.locked && !this._isStopped) {
257
- this.stopChecking();
258
- }
259
- }
260
- }, _class);
261
183
  var getCheckpoint = (message2) => {
262
184
  return "checkpoint" in message2.metadata && // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
263
185
  isBigint(message2.metadata.checkpoint) ? (
@@ -273,147 +195,6 @@ var getCheckpoint = (message2) => {
273
195
  message2.metadata.streamPosition
274
196
  ) : null;
275
197
  };
276
- var filter = (filter2) => new (0, _webstreamspolyfill.TransformStream)({
277
- transform(chunk, controller) {
278
- if (filter2(chunk)) {
279
- controller.enqueue(chunk);
280
- }
281
- }
282
- });
283
- var map = (map2) => new (0, _webstreamspolyfill.TransformStream)({
284
- transform(chunk, controller) {
285
- controller.enqueue(map2(chunk));
286
- }
287
- });
288
- var reduce = (reducer, initialValue) => new ReduceTransformStream(reducer, initialValue);
289
- var ReduceTransformStream = class extends _webstreamspolyfill.TransformStream {
290
-
291
-
292
- constructor(reducer, initialValue) {
293
- super({
294
- transform: (chunk) => {
295
- this.accumulator = this.reducer(this.accumulator, chunk);
296
- },
297
- flush: (controller) => {
298
- controller.enqueue(this.accumulator);
299
- controller.terminate();
300
- }
301
- });
302
- this.accumulator = initialValue;
303
- this.reducer = reducer;
304
- }
305
- };
306
- var retryStream = (createSourceStream, handleChunk2, retryOptions = { forever: true, minTimeout: 25 }) => new (0, _webstreamspolyfill.TransformStream)({
307
- start(controller) {
308
- asyncRetry(
309
- () => onRestream(createSourceStream, handleChunk2, controller),
310
- retryOptions
311
- ).catch((error2) => {
312
- controller.error(error2);
313
- });
314
- }
315
- });
316
- var onRestream = async (createSourceStream, handleChunk2, controller) => {
317
- const sourceStream = createSourceStream();
318
- const reader = sourceStream.getReader();
319
- try {
320
- let done;
321
- do {
322
- const result = await reader.read();
323
- done = result.done;
324
- await handleChunk2(result, controller);
325
- if (done) {
326
- controller.terminate();
327
- }
328
- } while (!done);
329
- } finally {
330
- reader.releaseLock();
331
- }
332
- };
333
- var skip = (limit) => new SkipTransformStream(limit);
334
- var SkipTransformStream = (_class2 = class extends _webstreamspolyfill.TransformStream {
335
- __init3() {this.count = 0}
336
-
337
- constructor(skip2) {
338
- super({
339
- transform: (chunk, controller) => {
340
- this.count++;
341
- if (this.count > this.skip) {
342
- controller.enqueue(chunk);
343
- }
344
- }
345
- });_class2.prototype.__init3.call(this);;
346
- this.skip = skip2;
347
- }
348
- }, _class2);
349
- var stopAfter = (stopCondition) => new (0, _webstreamspolyfill.TransformStream)({
350
- transform(chunk, controller) {
351
- controller.enqueue(chunk);
352
- if (stopCondition(chunk)) {
353
- controller.terminate();
354
- }
355
- }
356
- });
357
- var stopOn = (stopCondition) => new (0, _webstreamspolyfill.TransformStream)({
358
- async transform(chunk, controller) {
359
- if (!stopCondition(chunk)) {
360
- controller.enqueue(chunk);
361
- return;
362
- }
363
- await Promise.resolve();
364
- controller.terminate();
365
- }
366
- });
367
- var take = (limit) => new TakeTransformStream(limit);
368
- var TakeTransformStream = (_class3 = class extends _webstreamspolyfill.TransformStream {
369
- __init4() {this.count = 0}
370
-
371
- constructor(limit) {
372
- super({
373
- transform: (chunk, controller) => {
374
- if (this.count < this.limit) {
375
- this.count++;
376
- controller.enqueue(chunk);
377
- } else {
378
- controller.terminate();
379
- }
380
- }
381
- });_class3.prototype.__init4.call(this);;
382
- this.limit = limit;
383
- }
384
- }, _class3);
385
- var waitAtMost = (waitTimeInMs) => new (0, _webstreamspolyfill.TransformStream)({
386
- start(controller) {
387
- const timeoutId = setTimeout(() => {
388
- controller.terminate();
389
- }, waitTimeInMs);
390
- const originalTerminate = controller.terminate.bind(controller);
391
- controller.terminate = () => {
392
- clearTimeout(timeoutId);
393
- originalTerminate();
394
- };
395
- },
396
- transform(chunk, controller) {
397
- controller.enqueue(chunk);
398
- }
399
- });
400
- var streamTransformations = {
401
- filter,
402
- take,
403
- TakeTransformStream,
404
- skip,
405
- SkipTransformStream,
406
- map,
407
- notifyAboutNoActiveReadersStream,
408
- NotifyAboutNoActiveReadersStream,
409
- reduce,
410
- ReduceTransformStream,
411
- retry: retryStream,
412
- stopAfter,
413
- stopOn,
414
- waitAtMost
415
- };
416
- var { retry: retry2 } = streamTransformations;
417
198
 
418
199
  // src/eventStore/schema/appendToStream.ts
419
200
 
@@ -453,7 +234,7 @@ var subscriptionsTable = {
453
234
  var appendToStream = async (connection, streamName, streamType, messages, options) => {
454
235
  if (messages.length === 0) return { success: false };
455
236
  const expectedStreamVersion = toExpectedVersion(
456
- _optionalChain([options, 'optionalAccess', _18 => _18.expectedStreamVersion])
237
+ _optionalChain([options, 'optionalAccess', _14 => _14.expectedStreamVersion])
457
238
  );
458
239
  const messagesToAppend = messages.map(
459
240
  (m, i) => ({
@@ -478,7 +259,7 @@ var appendToStream = async (connection, streamName, streamType, messages, option
478
259
  expectedStreamVersion
479
260
  }
480
261
  );
481
- if (_optionalChain([options, 'optionalAccess', _19 => _19.onBeforeCommit]))
262
+ if (_optionalChain([options, 'optionalAccess', _15 => _15.onBeforeCommit]))
482
263
  await options.onBeforeCommit(messagesToAppend, { connection });
483
264
  return result;
484
265
  });
@@ -494,7 +275,7 @@ var appendToStreamRaw = async (connection, streamId, streamType, messages, optio
494
275
  let streamPosition;
495
276
  let globalPosition;
496
277
  try {
497
- let expectedStreamVersion = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _20 => _20.expectedStreamVersion]), () => ( null));
278
+ let expectedStreamVersion = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _16 => _16.expectedStreamVersion]), () => ( null));
498
279
  if (expectedStreamVersion == null) {
499
280
  expectedStreamVersion = await getLastStreamPosition(
500
281
  connection,
@@ -520,7 +301,7 @@ var appendToStreamRaw = async (connection, streamId, streamType, messages, optio
520
301
  [
521
302
  streamId,
522
303
  messages.length,
523
- _nullishCoalesce(_optionalChain([options, 'optionalAccess', _21 => _21.partition]), () => ( streamsTable.columns.partition)),
304
+ _nullishCoalesce(_optionalChain([options, 'optionalAccess', _17 => _17.partition]), () => ( streamsTable.columns.partition)),
524
305
  streamType
525
306
  ]
526
307
  );
@@ -536,7 +317,7 @@ var appendToStreamRaw = async (connection, streamId, streamType, messages, optio
536
317
  [
537
318
  messages.length,
538
319
  streamId,
539
- _nullishCoalesce(_optionalChain([options, 'optionalAccess', _22 => _22.partition]), () => ( streamsTable.columns.partition))
320
+ _nullishCoalesce(_optionalChain([options, 'optionalAccess', _18 => _18.partition]), () => ( streamsTable.columns.partition))
540
321
  ]
541
322
  );
542
323
  }
@@ -556,10 +337,10 @@ var appendToStreamRaw = async (connection, streamId, streamType, messages, optio
556
337
  messages,
557
338
  expectedStreamVersion,
558
339
  streamId,
559
- _nullishCoalesce(_optionalChain([options, 'optionalAccess', _23 => _23.partition, 'optionalAccess', _24 => _24.toString, 'call', _25 => _25()]), () => ( defaultTag))
340
+ _nullishCoalesce(_optionalChain([options, 'optionalAccess', _19 => _19.partition, 'optionalAccess', _20 => _20.toString, 'call', _21 => _21()]), () => ( defaultTag))
560
341
  );
561
342
  const returningIds = await connection.query(sqlString, values);
562
- if (returningIds.length === 0 || !_optionalChain([returningIds, 'access', _26 => _26[returningIds.length - 1], 'optionalAccess', _27 => _27.global_position])) {
343
+ if (returningIds.length === 0 || !_optionalChain([returningIds, 'access', _22 => _22[returningIds.length - 1], 'optionalAccess', _23 => _23.global_position])) {
563
344
  throw new Error("Could not find global position");
564
345
  }
565
346
  globalPosition = BigInt(
@@ -580,14 +361,14 @@ var appendToStreamRaw = async (connection, streamId, streamType, messages, optio
580
361
  };
581
362
  };
582
363
  var isOptimisticConcurrencyError = (error) => {
583
- return _optionalChain([error, 'optionalAccess', _28 => _28.errno]) !== void 0 && error.errno === 19;
364
+ return _optionalChain([error, 'optionalAccess', _24 => _24.errno]) !== void 0 && error.errno === 19;
584
365
  };
585
366
  async function getLastStreamPosition(connection, streamId, expectedStreamVersion) {
586
367
  const result = await connection.querySingle(
587
368
  `SELECT CAST(stream_position AS VARCHAR) AS stream_position FROM ${streamsTable.name} WHERE stream_id = ?`,
588
369
  [streamId]
589
370
  );
590
- if (_optionalChain([result, 'optionalAccess', _29 => _29.stream_position]) == null) {
371
+ if (_optionalChain([result, 'optionalAccess', _25 => _25.stream_position]) == null) {
591
372
  expectedStreamVersion = 0n;
592
373
  } else {
593
374
  expectedStreamVersion = BigInt(result.stream_position);
@@ -597,7 +378,7 @@ async function getLastStreamPosition(connection, streamId, expectedStreamVersion
597
378
  var buildMessageInsertQuery = (messages, expectedStreamVersion, streamId, partition) => {
598
379
  const query = messages.reduce(
599
380
  (queryBuilder, message) => {
600
- if (_optionalChain([message, 'access', _30 => _30.metadata, 'optionalAccess', _31 => _31.streamPosition]) == null || typeof message.metadata.streamPosition !== "bigint") {
381
+ if (_optionalChain([message, 'access', _26 => _26.metadata, 'optionalAccess', _27 => _27.streamPosition]) == null || typeof message.metadata.streamPosition !== "bigint") {
601
382
  throw new Error("Stream position is required");
602
383
  }
603
384
  const streamPosition = BigInt(message.metadata.streamPosition) + BigInt(expectedStreamVersion);
@@ -609,7 +390,7 @@ var buildMessageInsertQuery = (messages, expectedStreamVersion, streamId, partit
609
390
  message.kind === "Event" ? "E" : "C",
610
391
  JSONParser.stringify(message.data),
611
392
  JSONParser.stringify(message.metadata),
612
- _nullishCoalesce(_optionalChain([expectedStreamVersion, 'optionalAccess', _32 => _32.toString, 'call', _33 => _33()]), () => ( 0)),
393
+ _nullishCoalesce(_optionalChain([expectedStreamVersion, 'optionalAccess', _28 => _28.toString, 'call', _29 => _29()]), () => ( 0)),
613
394
  message.type,
614
395
  message.metadata.messageId,
615
396
  false
@@ -713,7 +494,7 @@ var readLastMessageGlobalPosition = async (db, options) => {
713
494
  ORDER BY global_position
714
495
  LIMIT 1`
715
496
  ),
716
- [_nullishCoalesce(_optionalChain([options, 'optionalAccess', _34 => _34.partition]), () => ( defaultTag))]
497
+ [_nullishCoalesce(_optionalChain([options, 'optionalAccess', _30 => _30.partition]), () => ( defaultTag))]
717
498
  )
718
499
  );
719
500
  return {
@@ -736,7 +517,7 @@ var readMessagesBatch = async (db, options) => {
736
517
  ORDER BY global_position
737
518
  ${limitCondition}`
738
519
  ),
739
- [_nullishCoalesce(_optionalChain([options, 'optionalAccess', _35 => _35.partition]), () => ( defaultTag))]
520
+ [_nullishCoalesce(_optionalChain([options, 'optionalAccess', _31 => _31.partition]), () => ( defaultTag))]
740
521
  )).map((row) => {
741
522
  const rawEvent = {
742
523
  type: row.message_type,
@@ -777,7 +558,7 @@ var readProcessorCheckpoint = async (db, options) => {
777
558
  WHERE partition = ? AND subscription_id = ?
778
559
  LIMIT 1`
779
560
  ),
780
- [_nullishCoalesce(_optionalChain([options, 'optionalAccess', _36 => _36.partition]), () => ( defaultTag)), options.processorId]
561
+ [_nullishCoalesce(_optionalChain([options, 'optionalAccess', _32 => _32.partition]), () => ( defaultTag)), options.processorId]
781
562
  )
782
563
  );
783
564
  return {
@@ -852,12 +633,12 @@ var genericSQLiteProcessor = (options) => {
852
633
  const { eachMessage } = options;
853
634
  let isActive = true;
854
635
  const getDb = (context) => {
855
- const fileName = _nullishCoalesce(context.fileName, () => ( _optionalChain([options, 'access', _37 => _37.connectionOptions, 'optionalAccess', _38 => _38.fileName])));
636
+ const fileName = _nullishCoalesce(context.fileName, () => ( _optionalChain([options, 'access', _33 => _33.connectionOptions, 'optionalAccess', _34 => _34.fileName])));
856
637
  if (!fileName)
857
638
  throw new EmmettError(
858
639
  `SQLite processor '${options.processorId}' is missing file name. Ensure that you passed it through options`
859
640
  );
860
- const connection = _nullishCoalesce(_nullishCoalesce(context.connection, () => ( _optionalChain([options, 'access', _39 => _39.connectionOptions, 'optionalAccess', _40 => _40.connection]))), () => ( sqliteConnection({ fileName })));
641
+ const connection = _nullishCoalesce(_nullishCoalesce(context.connection, () => ( _optionalChain([options, 'access', _35 => _35.connectionOptions, 'optionalAccess', _36 => _36.connection]))), () => ( sqliteConnection({ fileName })));
861
642
  return { connection, fileName };
862
643
  };
863
644
  return {
@@ -959,7 +740,7 @@ var sqliteEventStoreConsumer = (options) => {
959
740
  })
960
741
  );
961
742
  return result.some(
962
- (r) => r.status === "fulfilled" && _optionalChain([r, 'access', _41 => _41.value, 'optionalAccess', _42 => _42.type]) !== "STOP"
743
+ (r) => r.status === "fulfilled" && _optionalChain([r, 'access', _37 => _37.value, 'optionalAccess', _38 => _38.type]) !== "STOP"
963
744
  ) ? void 0 : {
964
745
  type: "STOP"
965
746
  };
@@ -967,8 +748,8 @@ var sqliteEventStoreConsumer = (options) => {
967
748
  const messagePooler = currentMessagePuller = sqliteEventStoreMessageBatchPuller({
968
749
  connection,
969
750
  eachBatch,
970
- batchSize: _nullishCoalesce(_optionalChain([pulling, 'optionalAccess', _43 => _43.batchSize]), () => ( DefaultSQLiteEventStoreProcessorBatchSize)),
971
- pullingFrequencyInMs: _nullishCoalesce(_optionalChain([pulling, 'optionalAccess', _44 => _44.pullingFrequencyInMs]), () => ( DefaultSQLiteEventStoreProcessorPullingFrequencyInMs))
751
+ batchSize: _nullishCoalesce(_optionalChain([pulling, 'optionalAccess', _39 => _39.batchSize]), () => ( DefaultSQLiteEventStoreProcessorBatchSize)),
752
+ pullingFrequencyInMs: _nullishCoalesce(_optionalChain([pulling, 'optionalAccess', _40 => _40.pullingFrequencyInMs]), () => ( DefaultSQLiteEventStoreProcessorPullingFrequencyInMs))
972
753
  });
973
754
  const stop = async () => {
974
755
  if (!isRunning) return;
@@ -1038,7 +819,7 @@ var getSQLiteEventStore = (options) => {
1038
819
  const fileName = _nullishCoalesce(options.fileName, () => ( InMemorySQLiteDatabase));
1039
820
  const isInMemory = fileName === InMemorySQLiteDatabase || fileName === InMemorySharedCacheSQLiteDatabase;
1040
821
  const inlineProjections = (_nullishCoalesce(options.projections, () => ( []))).filter(({ type }) => type === "inline").map(({ projection: projection2 }) => projection2);
1041
- const onBeforeCommitHook = _optionalChain([options, 'access', _45 => _45.hooks, 'optionalAccess', _46 => _46.onBeforeCommit]);
822
+ const onBeforeCommitHook = _optionalChain([options, 'access', _41 => _41.hooks, 'optionalAccess', _42 => _42.onBeforeCommit]);
1042
823
  const createConnection = () => {
1043
824
  if (database != null) {
1044
825
  return database;
@@ -1068,7 +849,7 @@ var getSQLiteEventStore = (options) => {
1068
849
  }
1069
850
  };
1070
851
  if (options) {
1071
- autoGenerateSchema = _optionalChain([options, 'access', _47 => _47.schema, 'optionalAccess', _48 => _48.autoMigration]) === void 0 || _optionalChain([options, 'access', _49 => _49.schema, 'optionalAccess', _50 => _50.autoMigration]) !== "None";
852
+ autoGenerateSchema = _optionalChain([options, 'access', _43 => _43.schema, 'optionalAccess', _44 => _44.autoMigration]) === void 0 || _optionalChain([options, 'access', _45 => _45.schema, 'optionalAccess', _46 => _46.autoMigration]) !== "None";
1072
853
  }
1073
854
  const ensureSchemaExists = async (connection) => {
1074
855
  if (!autoGenerateSchema) return Promise.resolve();
@@ -1081,7 +862,7 @@ var getSQLiteEventStore = (options) => {
1081
862
  return {
1082
863
  async aggregateStream(streamName, options2) {
1083
864
  const { evolve, initialState, read } = options2;
1084
- const expectedStreamVersion = _optionalChain([read, 'optionalAccess', _51 => _51.expectedStreamVersion]);
865
+ const expectedStreamVersion = _optionalChain([read, 'optionalAccess', _47 => _47.expectedStreamVersion]);
1085
866
  let state = initialState();
1086
867
  if (typeof streamName !== "string") {
1087
868
  throw new Error("Stream name is not string");
@@ -1135,7 +916,7 @@ var getSQLiteEventStore = (options) => {
1135
916
  throw new ExpectedVersionConflictError(
1136
917
  -1n,
1137
918
  //TODO: Return actual version in case of error
1138
- _nullishCoalesce(_optionalChain([options2, 'optionalAccess', _52 => _52.expectedStreamVersion]), () => ( NO_CONCURRENCY_CHECK))
919
+ _nullishCoalesce(_optionalChain([options2, 'optionalAccess', _48 => _48.expectedStreamVersion]), () => ( NO_CONCURRENCY_CHECK))
1139
920
  );
1140
921
  return {
1141
922
  nextExpectedStreamVersion: appendResult.nextStreamPosition,
@@ -1163,7 +944,7 @@ var readStream = async (db, streamId, options) => {
1163
944
  FROM ${messagesTable.name}
1164
945
  WHERE stream_id = ? AND partition = ? AND is_archived = FALSE ${fromCondition} ${toCondition}
1165
946
  ORDER BY stream_position ASC`,
1166
- [streamId, _nullishCoalesce(_optionalChain([options, 'optionalAccess', _53 => _53.partition]), () => ( defaultTag))]
947
+ [streamId, _nullishCoalesce(_optionalChain([options, 'optionalAccess', _49 => _49.partition]), () => ( defaultTag))]
1167
948
  );
1168
949
  const messages = results.map((row) => {
1169
950
  const rawEvent = {
@@ -1220,9 +1001,9 @@ async function storeSubscriptionCheckpointSQLite(db, processorId, version, posit
1220
1001
  [processorId, partition]
1221
1002
  )
1222
1003
  );
1223
- if (_optionalChain([current_position, 'optionalAccess', _54 => _54.last_processed_position]) === position) {
1004
+ if (_optionalChain([current_position, 'optionalAccess', _50 => _50.last_processed_position]) === position) {
1224
1005
  return 0;
1225
- } else if (position !== null && current_position !== null && _optionalChain([current_position, 'optionalAccess', _55 => _55.last_processed_position]) > position) {
1006
+ } else if (position !== null && current_position !== null && _optionalChain([current_position, 'optionalAccess', _51 => _51.last_processed_position]) > position) {
1226
1007
  return 2;
1227
1008
  } else {
1228
1009
  return 2;
@@ -1249,7 +1030,7 @@ async function storeSubscriptionCheckpointSQLite(db, processorId, version, posit
1249
1030
  [processorId, partition]
1250
1031
  )
1251
1032
  );
1252
- if (_optionalChain([current, 'optionalAccess', _56 => _56.last_processed_position]) === position) {
1033
+ if (_optionalChain([current, 'optionalAccess', _52 => _52.last_processed_position]) === position) {
1253
1034
  return 0;
1254
1035
  } else {
1255
1036
  return 2;