@event-driven-io/emmett-sqlite 0.42.0-beta.5 → 0.42.0-rc.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.
package/dist/index.cjs CHANGED
@@ -558,6 +558,49 @@ var assertThatArray = (array) => {
558
558
  }
559
559
  };
560
560
  };
561
+ var downcastRecordedMessage = (recordedMessage, options) => {
562
+ if (!_optionalChain([options, 'optionalAccess', _20 => _20.downcast]))
563
+ return recordedMessage;
564
+ const downcasted = options.downcast(
565
+ recordedMessage
566
+ );
567
+ return {
568
+ ...recordedMessage,
569
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
570
+ data: downcasted.data,
571
+ ..."metadata" in recordedMessage || "metadata" in downcasted ? {
572
+ metadata: {
573
+ ..."metadata" in recordedMessage ? recordedMessage.metadata : {},
574
+ ..."metadata" in downcasted ? downcasted.metadata : {}
575
+ }
576
+ } : {}
577
+ };
578
+ };
579
+ var downcastRecordedMessages = (recordedMessages, options) => {
580
+ if (!_optionalChain([options, 'optionalAccess', _21 => _21.downcast]))
581
+ return recordedMessages;
582
+ return recordedMessages.map(
583
+ (recordedMessage) => downcastRecordedMessage(recordedMessage, options)
584
+ );
585
+ };
586
+ var upcastRecordedMessage = (recordedMessage, options) => {
587
+ if (!_optionalChain([options, 'optionalAccess', _22 => _22.upcast]))
588
+ return recordedMessage;
589
+ const upcasted = options.upcast(
590
+ recordedMessage
591
+ );
592
+ return {
593
+ ...recordedMessage,
594
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
595
+ data: upcasted.data,
596
+ ..."metadata" in recordedMessage || "metadata" in upcasted ? {
597
+ metadata: {
598
+ ..."metadata" in recordedMessage ? recordedMessage.metadata : {},
599
+ ..."metadata" in upcasted ? upcasted.metadata : {}
600
+ }
601
+ } : {}
602
+ };
603
+ };
561
604
  var getCheckpoint = (message2) => {
562
605
  return "checkpoint" in message2.metadata ? (
563
606
  // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
@@ -859,12 +902,12 @@ var schemaSQL = [
859
902
  var createEventStoreSchema = async (connection, hooks) => {
860
903
  await connection.withTransaction(async () => {
861
904
  await migration_0_42_0_FromSubscriptionsToProcessors(connection);
862
- if (_optionalChain([hooks, 'optionalAccess', _20 => _20.onBeforeSchemaCreated])) {
905
+ if (_optionalChain([hooks, 'optionalAccess', _23 => _23.onBeforeSchemaCreated])) {
863
906
  await hooks.onBeforeSchemaCreated({ connection });
864
907
  }
865
908
  await connection.batchCommand(schemaSQL);
866
909
  });
867
- if (_optionalChain([hooks, 'optionalAccess', _21 => _21.onAfterSchemaCreated])) {
910
+ if (_optionalChain([hooks, 'optionalAccess', _24 => _24.onAfterSchemaCreated])) {
868
911
  await hooks.onAfterSchemaCreated();
869
912
  }
870
913
  };
@@ -887,7 +930,7 @@ var readLastMessageGlobalPosition = async (db, options) => {
887
930
  ORDER BY global_position
888
931
  LIMIT 1`
889
932
  ),
890
- [_nullishCoalesce(_optionalChain([options, 'optionalAccess', _22 => _22.partition]), () => ( defaultTag2))]
933
+ [_nullishCoalesce(_optionalChain([options, 'optionalAccess', _25 => _25.partition]), () => ( defaultTag2))]
891
934
  )
892
935
  );
893
936
  return {
@@ -910,7 +953,7 @@ var readMessagesBatch = async (db, options) => {
910
953
  ORDER BY global_position
911
954
  ${limitCondition}`
912
955
  ),
913
- [_nullishCoalesce(_optionalChain([options, 'optionalAccess', _23 => _23.partition]), () => ( defaultTag2))]
956
+ [_nullishCoalesce(_optionalChain([options, 'optionalAccess', _26 => _26.partition]), () => ( defaultTag2))]
914
957
  )).map((row) => {
915
958
  const rawEvent = {
916
959
  type: row.message_type,
@@ -1012,7 +1055,7 @@ var zipSQLiteEventStoreMessageBatchPullerStartFrom = (options) => {
1012
1055
  var appendToStream = async (connection, streamName, streamType, messages, options) => {
1013
1056
  if (messages.length === 0) return { success: false };
1014
1057
  const expectedStreamVersion = toExpectedVersion(
1015
- _optionalChain([options, 'optionalAccess', _24 => _24.expectedStreamVersion])
1058
+ _optionalChain([options, 'optionalAccess', _27 => _27.expectedStreamVersion])
1016
1059
  );
1017
1060
  const messagesToAppend = messages.map(
1018
1061
  (m, i) => ({
@@ -1032,12 +1075,12 @@ var appendToStream = async (connection, streamName, streamType, messages, option
1032
1075
  connection,
1033
1076
  streamName,
1034
1077
  streamType,
1035
- messagesToAppend,
1078
+ downcastRecordedMessages(messagesToAppend, _optionalChain([options, 'optionalAccess', _28 => _28.schema, 'optionalAccess', _29 => _29.versioning])),
1036
1079
  {
1037
1080
  expectedStreamVersion
1038
1081
  }
1039
1082
  );
1040
- if (_optionalChain([options, 'optionalAccess', _25 => _25.onBeforeCommit]))
1083
+ if (_optionalChain([options, 'optionalAccess', _30 => _30.onBeforeCommit]))
1041
1084
  await options.onBeforeCommit(messagesToAppend, { connection });
1042
1085
  return result;
1043
1086
  });
@@ -1053,7 +1096,7 @@ var appendToStreamRaw = async (connection, streamId, streamType, messages, optio
1053
1096
  let streamPosition;
1054
1097
  let globalPosition;
1055
1098
  try {
1056
- let expectedStreamVersion = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _26 => _26.expectedStreamVersion]), () => ( null));
1099
+ let expectedStreamVersion = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _31 => _31.expectedStreamVersion]), () => ( null));
1057
1100
  if (expectedStreamVersion == null) {
1058
1101
  expectedStreamVersion = await getLastStreamPosition(
1059
1102
  connection,
@@ -1079,7 +1122,7 @@ var appendToStreamRaw = async (connection, streamId, streamType, messages, optio
1079
1122
  [
1080
1123
  streamId,
1081
1124
  messages.length,
1082
- _nullishCoalesce(_optionalChain([options, 'optionalAccess', _27 => _27.partition]), () => ( streamsTable.columns.partition)),
1125
+ _nullishCoalesce(_optionalChain([options, 'optionalAccess', _32 => _32.partition]), () => ( streamsTable.columns.partition)),
1083
1126
  streamType
1084
1127
  ]
1085
1128
  );
@@ -1095,7 +1138,7 @@ var appendToStreamRaw = async (connection, streamId, streamType, messages, optio
1095
1138
  [
1096
1139
  messages.length,
1097
1140
  streamId,
1098
- _nullishCoalesce(_optionalChain([options, 'optionalAccess', _28 => _28.partition]), () => ( streamsTable.columns.partition))
1141
+ _nullishCoalesce(_optionalChain([options, 'optionalAccess', _33 => _33.partition]), () => ( streamsTable.columns.partition))
1099
1142
  ]
1100
1143
  );
1101
1144
  }
@@ -1115,10 +1158,10 @@ var appendToStreamRaw = async (connection, streamId, streamType, messages, optio
1115
1158
  messages,
1116
1159
  expectedStreamVersion,
1117
1160
  streamId,
1118
- _nullishCoalesce(_optionalChain([options, 'optionalAccess', _29 => _29.partition, 'optionalAccess', _30 => _30.toString, 'call', _31 => _31()]), () => ( defaultTag2))
1161
+ _nullishCoalesce(_optionalChain([options, 'optionalAccess', _34 => _34.partition, 'optionalAccess', _35 => _35.toString, 'call', _36 => _36()]), () => ( defaultTag2))
1119
1162
  );
1120
1163
  const returningIds = await connection.query(sqlString, values);
1121
- if (returningIds.length === 0 || !_optionalChain([returningIds, 'access', _32 => _32[returningIds.length - 1], 'optionalAccess', _33 => _33.global_position])) {
1164
+ if (returningIds.length === 0 || !_optionalChain([returningIds, 'access', _37 => _37[returningIds.length - 1], 'optionalAccess', _38 => _38.global_position])) {
1122
1165
  throw new Error("Could not find global position");
1123
1166
  }
1124
1167
  globalPosition = BigInt(
@@ -1139,14 +1182,14 @@ var appendToStreamRaw = async (connection, streamId, streamType, messages, optio
1139
1182
  };
1140
1183
  };
1141
1184
  var isOptimisticConcurrencyError = (error) => {
1142
- return _optionalChain([error, 'optionalAccess', _34 => _34.errno]) !== void 0 && error.errno === 19;
1185
+ return _optionalChain([error, 'optionalAccess', _39 => _39.errno]) !== void 0 && error.errno === 19;
1143
1186
  };
1144
1187
  async function getLastStreamPosition(connection, streamId, expectedStreamVersion) {
1145
1188
  const result = await connection.querySingle(
1146
1189
  `SELECT CAST(stream_position AS VARCHAR) AS stream_position FROM ${streamsTable.name} WHERE stream_id = ?`,
1147
1190
  [streamId]
1148
1191
  );
1149
- if (_optionalChain([result, 'optionalAccess', _35 => _35.stream_position]) == null) {
1192
+ if (_optionalChain([result, 'optionalAccess', _40 => _40.stream_position]) == null) {
1150
1193
  expectedStreamVersion = 0n;
1151
1194
  } else {
1152
1195
  expectedStreamVersion = BigInt(result.stream_position);
@@ -1156,7 +1199,7 @@ async function getLastStreamPosition(connection, streamId, expectedStreamVersion
1156
1199
  var buildMessageInsertQuery = (messages, expectedStreamVersion, streamId, partition) => {
1157
1200
  const query = messages.reduce(
1158
1201
  (queryBuilder, message) => {
1159
- if (_optionalChain([message, 'access', _36 => _36.metadata, 'optionalAccess', _37 => _37.streamPosition]) == null || typeof message.metadata.streamPosition !== "bigint") {
1202
+ if (_optionalChain([message, 'access', _41 => _41.metadata, 'optionalAccess', _42 => _42.streamPosition]) == null || typeof message.metadata.streamPosition !== "bigint") {
1160
1203
  throw new Error("Stream position is required");
1161
1204
  }
1162
1205
  const streamPosition = BigInt(message.metadata.streamPosition) + BigInt(expectedStreamVersion);
@@ -1168,7 +1211,7 @@ var buildMessageInsertQuery = (messages, expectedStreamVersion, streamId, partit
1168
1211
  message.kind === "Event" ? "E" : "C",
1169
1212
  JSONParser.stringify(message.data),
1170
1213
  JSONParser.stringify(message.metadata),
1171
- _nullishCoalesce(_optionalChain([expectedStreamVersion, 'optionalAccess', _38 => _38.toString, 'call', _39 => _39()]), () => ( 0)),
1214
+ _nullishCoalesce(_optionalChain([expectedStreamVersion, 'optionalAccess', _43 => _43.toString, 'call', _44 => _44()]), () => ( 0)),
1172
1215
  message.type,
1173
1216
  message.metadata.messageId,
1174
1217
  false
@@ -1210,7 +1253,7 @@ var readProcessorCheckpoint = async (db, options) => {
1210
1253
  WHERE partition = ? AND processor_id = ?
1211
1254
  LIMIT 1`
1212
1255
  ),
1213
- [_nullishCoalesce(_optionalChain([options, 'optionalAccess', _40 => _40.partition]), () => ( defaultTag2)), options.processorId]
1256
+ [_nullishCoalesce(_optionalChain([options, 'optionalAccess', _45 => _45.partition]), () => ( defaultTag2)), options.processorId]
1214
1257
  )
1215
1258
  );
1216
1259
  return {
@@ -1220,9 +1263,9 @@ var readProcessorCheckpoint = async (db, options) => {
1220
1263
 
1221
1264
  // src/eventStore/schema/readStream.ts
1222
1265
  var readStream = async (db, streamId, options) => {
1223
- const fromCondition = options && "from" in options ? `AND stream_position >= ${options.from}` : "";
1266
+ const fromCondition = _optionalChain([options, 'optionalAccess', _46 => _46.from]) ? `AND stream_position >= ${options.from}` : "";
1224
1267
  const to = Number(
1225
- options && "to" in options ? options.to : options && "maxCount" in options && options.maxCount ? options.from + options.maxCount : NaN
1268
+ _nullishCoalesce(_optionalChain([options, 'optionalAccess', _47 => _47.to]), () => ( (_optionalChain([options, 'optionalAccess', _48 => _48.maxCount]) ? (_nullishCoalesce(options.from, () => ( 0n))) + options.maxCount : NaN)))
1226
1269
  );
1227
1270
  const toCondition = !isNaN(to) ? `AND stream_position <= ${to}` : "";
1228
1271
  const results = await db.query(
@@ -1230,7 +1273,7 @@ var readStream = async (db, streamId, options) => {
1230
1273
  FROM ${messagesTable.name}
1231
1274
  WHERE stream_id = ? AND partition = ? AND is_archived = FALSE ${fromCondition} ${toCondition}
1232
1275
  ORDER BY stream_position ASC`,
1233
- [streamId, _nullishCoalesce(_optionalChain([options, 'optionalAccess', _41 => _41.partition]), () => ( defaultTag2))]
1276
+ [streamId, _nullishCoalesce(_optionalChain([options, 'optionalAccess', _49 => _49.partition]), () => ( defaultTag2))]
1234
1277
  );
1235
1278
  const messages = results.map((row) => {
1236
1279
  const rawEvent = {
@@ -1245,11 +1288,12 @@ var readStream = async (db, streamId, options) => {
1245
1288
  streamPosition: BigInt(row.stream_position),
1246
1289
  globalPosition: BigInt(row.global_position)
1247
1290
  };
1248
- return {
1291
+ const event = {
1249
1292
  ...rawEvent,
1250
1293
  kind: "Event",
1251
1294
  metadata
1252
1295
  };
1296
+ return upcastRecordedMessage(event, _optionalChain([options, 'optionalAccess', _50 => _50.schema, 'optionalAccess', _51 => _51.versioning]));
1253
1297
  });
1254
1298
  return messages.length > 0 ? {
1255
1299
  currentStreamVersion: messages[messages.length - 1].metadata.streamPosition,
@@ -1296,7 +1340,7 @@ async function storeSubscriptionCheckpointSQLite(db, processorId, version, posit
1296
1340
  [processorId, partition]
1297
1341
  )
1298
1342
  );
1299
- const currentPosition = current_position && _optionalChain([current_position, 'optionalAccess', _42 => _42.last_processed_checkpoint]) !== null ? BigInt(current_position.last_processed_checkpoint) : null;
1343
+ const currentPosition = current_position && _optionalChain([current_position, 'optionalAccess', _52 => _52.last_processed_checkpoint]) !== null ? BigInt(current_position.last_processed_checkpoint) : null;
1300
1344
  if (currentPosition === position) {
1301
1345
  return 0;
1302
1346
  } else if (position !== null && currentPosition !== null && currentPosition > position) {
@@ -1332,7 +1376,7 @@ async function storeSubscriptionCheckpointSQLite(db, processorId, version, posit
1332
1376
  [processorId, partition]
1333
1377
  )
1334
1378
  );
1335
- const currentPosition = current && _optionalChain([current, 'optionalAccess', _43 => _43.last_processed_checkpoint]) !== null ? BigInt(current.last_processed_checkpoint) : null;
1379
+ const currentPosition = current && _optionalChain([current, 'optionalAccess', _53 => _53.last_processed_checkpoint]) !== null ? BigInt(current.last_processed_checkpoint) : null;
1336
1380
  if (currentPosition === position) {
1337
1381
  return 0;
1338
1382
  } else {
@@ -1363,12 +1407,12 @@ var genericSQLiteProcessor = (options) => {
1363
1407
  const { eachMessage } = options;
1364
1408
  let isActive = true;
1365
1409
  const getDb = (context) => {
1366
- const fileName = _nullishCoalesce(context.fileName, () => ( _optionalChain([options, 'access', _44 => _44.connectionOptions, 'optionalAccess', _45 => _45.fileName])));
1410
+ const fileName = _nullishCoalesce(context.fileName, () => ( _optionalChain([options, 'access', _54 => _54.connectionOptions, 'optionalAccess', _55 => _55.fileName])));
1367
1411
  if (!fileName)
1368
1412
  throw new EmmettError(
1369
1413
  `SQLite processor '${options.processorId}' is missing file name. Ensure that you passed it through options`
1370
1414
  );
1371
- const connection = _nullishCoalesce(_nullishCoalesce(context.connection, () => ( _optionalChain([options, 'access', _46 => _46.connectionOptions, 'optionalAccess', _47 => _47.connection]))), () => ( sqliteConnection({ fileName })));
1415
+ const connection = _nullishCoalesce(_nullishCoalesce(context.connection, () => ( _optionalChain([options, 'access', _56 => _56.connectionOptions, 'optionalAccess', _57 => _57.connection]))), () => ( sqliteConnection({ fileName })));
1372
1416
  return { connection, fileName };
1373
1417
  };
1374
1418
  return {
@@ -1470,7 +1514,7 @@ var sqliteEventStoreConsumer = (options) => {
1470
1514
  })
1471
1515
  );
1472
1516
  return result.some(
1473
- (r) => r.status === "fulfilled" && _optionalChain([r, 'access', _48 => _48.value, 'optionalAccess', _49 => _49.type]) !== "STOP"
1517
+ (r) => r.status === "fulfilled" && _optionalChain([r, 'access', _58 => _58.value, 'optionalAccess', _59 => _59.type]) !== "STOP"
1474
1518
  ) ? void 0 : {
1475
1519
  type: "STOP"
1476
1520
  };
@@ -1478,8 +1522,8 @@ var sqliteEventStoreConsumer = (options) => {
1478
1522
  const messagePooler = currentMessagePuller = sqliteEventStoreMessageBatchPuller({
1479
1523
  pool,
1480
1524
  eachBatch,
1481
- batchSize: _nullishCoalesce(_optionalChain([pulling, 'optionalAccess', _50 => _50.batchSize]), () => ( DefaultSQLiteEventStoreProcessorBatchSize)),
1482
- pullingFrequencyInMs: _nullishCoalesce(_optionalChain([pulling, 'optionalAccess', _51 => _51.pullingFrequencyInMs]), () => ( DefaultSQLiteEventStoreProcessorPullingFrequencyInMs))
1525
+ batchSize: _nullishCoalesce(_optionalChain([pulling, 'optionalAccess', _60 => _60.batchSize]), () => ( DefaultSQLiteEventStoreProcessorBatchSize)),
1526
+ pullingFrequencyInMs: _nullishCoalesce(_optionalChain([pulling, 'optionalAccess', _61 => _61.pullingFrequencyInMs]), () => ( DefaultSQLiteEventStoreProcessorPullingFrequencyInMs))
1483
1527
  });
1484
1528
  const stop = async () => {
1485
1529
  if (!isRunning) return;
@@ -1536,9 +1580,9 @@ var streamExists = async (db, streamId, options) => {
1536
1580
  from ${streamsTable.name}
1537
1581
  WHERE stream_id = ? AND partition = ? AND is_archived = FALSE)
1538
1582
  `,
1539
- [streamId, _nullishCoalesce(_optionalChain([options, 'optionalAccess', _52 => _52.partition]), () => ( defaultTag2))]
1583
+ [streamId, _nullishCoalesce(_optionalChain([options, 'optionalAccess', _62 => _62.partition]), () => ( defaultTag2))]
1540
1584
  );
1541
- return _nullishCoalesce(_optionalChain([queryResult, 'access', _53 => _53[0], 'optionalAccess', _54 => _54.exists]), () => ( false));
1585
+ return _nullishCoalesce(_optionalChain([queryResult, 'access', _63 => _63[0], 'optionalAccess', _64 => _64.exists]), () => ( false));
1542
1586
  };
1543
1587
 
1544
1588
  // src/eventStore/SQLiteEventStore.ts
@@ -1549,13 +1593,13 @@ var getSQLiteEventStore = (options) => {
1549
1593
  const pool = _nullishCoalesce(options.pool, () => ( SQLiteConnectionPool(options)));
1550
1594
  let migrateSchema = void 0;
1551
1595
  const inlineProjections = (_nullishCoalesce(options.projections, () => ( []))).filter(({ type }) => type === "inline").map(({ projection: projection2 }) => projection2);
1552
- const onBeforeCommitHook = _optionalChain([options, 'access', _55 => _55.hooks, 'optionalAccess', _56 => _56.onBeforeCommit]);
1596
+ const onBeforeCommitHook = _optionalChain([options, 'access', _65 => _65.hooks, 'optionalAccess', _66 => _66.onBeforeCommit]);
1553
1597
  const withConnection = async (handler) => pool.withConnection(async (database) => {
1554
1598
  await ensureSchemaExists(database);
1555
1599
  return await handler(database);
1556
1600
  });
1557
1601
  if (options) {
1558
- autoGenerateSchema = _optionalChain([options, 'access', _57 => _57.schema, 'optionalAccess', _58 => _58.autoMigration]) === void 0 || _optionalChain([options, 'access', _59 => _59.schema, 'optionalAccess', _60 => _60.autoMigration]) !== "None";
1602
+ autoGenerateSchema = _optionalChain([options, 'access', _67 => _67.schema, 'optionalAccess', _68 => _68.autoMigration]) === void 0 || _optionalChain([options, 'access', _69 => _69.schema, 'optionalAccess', _70 => _70.autoMigration]) !== "None";
1559
1603
  }
1560
1604
  const migrate = (connection) => {
1561
1605
  if (!migrateSchema) {
@@ -1571,11 +1615,11 @@ var getSQLiteEventStore = (options) => {
1571
1615
  });
1572
1616
  }
1573
1617
  }
1574
- if (_optionalChain([options, 'access', _61 => _61.hooks, 'optionalAccess', _62 => _62.onBeforeSchemaCreated])) {
1618
+ if (_optionalChain([options, 'access', _71 => _71.hooks, 'optionalAccess', _72 => _72.onBeforeSchemaCreated])) {
1575
1619
  await options.hooks.onBeforeSchemaCreated(context);
1576
1620
  }
1577
1621
  },
1578
- onAfterSchemaCreated: _optionalChain([options, 'access', _63 => _63.hooks, 'optionalAccess', _64 => _64.onAfterSchemaCreated])
1622
+ onAfterSchemaCreated: _optionalChain([options, 'access', _73 => _73.hooks, 'optionalAccess', _74 => _74.onAfterSchemaCreated])
1579
1623
  });
1580
1624
  }
1581
1625
  return migrateSchema;
@@ -1587,13 +1631,13 @@ var getSQLiteEventStore = (options) => {
1587
1631
  return {
1588
1632
  async aggregateStream(streamName, options2) {
1589
1633
  const { evolve, initialState, read } = options2;
1590
- const expectedStreamVersion = _optionalChain([read, 'optionalAccess', _65 => _65.expectedStreamVersion]);
1634
+ const expectedStreamVersion = _optionalChain([read, 'optionalAccess', _75 => _75.expectedStreamVersion]);
1591
1635
  let state = initialState();
1592
1636
  if (typeof streamName !== "string") {
1593
1637
  throw new Error("Stream name is not string");
1594
1638
  }
1595
1639
  const result = await withConnection(
1596
- (connection) => readStream(connection, streamName, options2.read)
1640
+ (connection) => readStream(connection, streamName, read)
1597
1641
  );
1598
1642
  const currentStreamVersion = result.currentStreamVersion;
1599
1643
  assertExpectedVersionMatchesCurrent(
@@ -1612,7 +1656,11 @@ var getSQLiteEventStore = (options) => {
1612
1656
  };
1613
1657
  },
1614
1658
  readStream: async (streamName, options2) => withConnection(
1615
- (connection) => readStream(connection, streamName, options2)
1659
+ (connection) => readStream(
1660
+ connection,
1661
+ streamName,
1662
+ options2
1663
+ )
1616
1664
  ),
1617
1665
  appendToStream: async (streamName, events, options2) => {
1618
1666
  const [firstPart, ...rest] = streamName.split("-");
@@ -1635,7 +1683,7 @@ var getSQLiteEventStore = (options) => {
1635
1683
  throw new ExpectedVersionConflictError(
1636
1684
  -1n,
1637
1685
  //TODO: Return actual version in case of error
1638
- _nullishCoalesce(_optionalChain([options2, 'optionalAccess', _66 => _66.expectedStreamVersion]), () => ( NO_CONCURRENCY_CHECK))
1686
+ _nullishCoalesce(_optionalChain([options2, 'optionalAccess', _76 => _76.expectedStreamVersion]), () => ( NO_CONCURRENCY_CHECK))
1639
1687
  );
1640
1688
  return {
1641
1689
  nextExpectedStreamVersion: appendResult.nextStreamPosition,
@@ -1676,7 +1724,7 @@ var SQLiteProjectionSpec = {
1676
1724
  const allEvents = [];
1677
1725
  const run = async (connection2) => {
1678
1726
  let globalPosition = 0n;
1679
- const numberOfTimes = _nullishCoalesce(_optionalChain([options2, 'optionalAccess', _67 => _67.numberOfTimes]), () => ( 1));
1727
+ const numberOfTimes = _nullishCoalesce(_optionalChain([options2, 'optionalAccess', _77 => _77.numberOfTimes]), () => ( 1));
1680
1728
  for (const event of [
1681
1729
  ...givenEvents,
1682
1730
  ...Array.from({ length: numberOfTimes }).flatMap(() => events)
@@ -1738,18 +1786,18 @@ var SQLiteProjectionSpec = {
1738
1786
  if (!isErrorConstructor(args[0])) {
1739
1787
  assertTrue(
1740
1788
  args[0](error),
1741
- `Error didn't match the error condition: ${_optionalChain([error, 'optionalAccess', _68 => _68.toString, 'call', _69 => _69()])}`
1789
+ `Error didn't match the error condition: ${_optionalChain([error, 'optionalAccess', _78 => _78.toString, 'call', _79 => _79()])}`
1742
1790
  );
1743
1791
  return;
1744
1792
  }
1745
1793
  assertTrue(
1746
1794
  error instanceof args[0],
1747
- `Caught error is not an instance of the expected type: ${_optionalChain([error, 'optionalAccess', _70 => _70.toString, 'call', _71 => _71()])}`
1795
+ `Caught error is not an instance of the expected type: ${_optionalChain([error, 'optionalAccess', _80 => _80.toString, 'call', _81 => _81()])}`
1748
1796
  );
1749
1797
  if (args[1]) {
1750
1798
  assertTrue(
1751
1799
  args[1](error),
1752
- `Error didn't match the error condition: ${_optionalChain([error, 'optionalAccess', _72 => _72.toString, 'call', _73 => _73()])}`
1800
+ `Error didn't match the error condition: ${_optionalChain([error, 'optionalAccess', _82 => _82.toString, 'call', _83 => _83()])}`
1753
1801
  );
1754
1802
  }
1755
1803
  } finally {
@@ -1768,7 +1816,7 @@ var eventInStream = (streamName, event) => {
1768
1816
  ...event,
1769
1817
  metadata: {
1770
1818
  ..._nullishCoalesce(event.metadata, () => ( {})),
1771
- streamName: _nullishCoalesce(_optionalChain([event, 'access', _74 => _74.metadata, 'optionalAccess', _75 => _75.streamName]), () => ( streamName))
1819
+ streamName: _nullishCoalesce(_optionalChain([event, 'access', _84 => _84.metadata, 'optionalAccess', _85 => _85.streamName]), () => ( streamName))
1772
1820
  }
1773
1821
  };
1774
1822
  };