@event-driven-io/emmett-sqlite 0.43.0-beta.4 → 0.43.0-beta.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
@@ -1542,8 +1542,6 @@ var readProcessorCheckpoint = async (execute, options) => {
1542
1542
 
1543
1543
 
1544
1544
 
1545
-
1546
-
1547
1545
  // src/eventStore/consumers/messageBatchProcessing/index.ts
1548
1546
  var DefaultSQLiteEventStoreProcessorBatchSize = 100;
1549
1547
  var DefaultSQLiteEventStoreProcessorPullingFrequencyInMs = 50;
@@ -1929,10 +1927,10 @@ var getSQLiteEventStore = (options) => {
1929
1927
  let migrateSchema = void 0;
1930
1928
  const inlineProjections = (_nullishCoalesce(options.projections, () => ( []))).filter(({ type }) => type === "inline").map(({ projection: projection2 }) => projection2);
1931
1929
  const onBeforeCommitHook = _optionalChain([options, 'access', _98 => _98.hooks, 'optionalAccess', _99 => _99.onBeforeCommit]);
1932
- const withConnection = (handler) => pool.withConnection(async (connection) => {
1930
+ const withConnection = (handler, options2) => pool.withConnection(async (connection) => {
1933
1931
  await ensureSchemaExists(connection);
1934
1932
  return await handler(connection);
1935
- });
1933
+ }, options2);
1936
1934
  if (options) {
1937
1935
  autoGenerateSchema = _optionalChain([options, 'access', _100 => _100.schema, 'optionalAccess', _101 => _101.autoMigration]) === void 0 || _optionalChain([options, 'access', _102 => _102.schema, 'optionalAccess', _103 => _103.autoMigration]) !== "None";
1938
1936
  }
@@ -1976,7 +1974,8 @@ var getSQLiteEventStore = (options) => {
1976
1974
  throw new Error("Stream name is not string");
1977
1975
  }
1978
1976
  const result = await withConnection(
1979
- ({ execute }) => readStream(execute, streamName, read)
1977
+ ({ execute }) => readStream(execute, streamName, read),
1978
+ { readonly: true }
1980
1979
  );
1981
1980
  const currentStreamVersion = result.currentStreamVersion;
1982
1981
  assertExpectedVersionMatchesCurrent(
@@ -1995,42 +1994,29 @@ var getSQLiteEventStore = (options) => {
1995
1994
  };
1996
1995
  },
1997
1996
  readStream: async (streamName, options2) => withConnection(
1998
- ({ execute }) => readStream(execute, streamName, options2)
1997
+ ({ execute }) => readStream(execute, streamName, options2),
1998
+ { readonly: true }
1999
1999
  ),
2000
2000
  appendToStream: async (streamName, events, appendOptions) => {
2001
2001
  const [firstPart, ...rest] = streamName.split("-");
2002
2002
  const streamType = firstPart && rest.length > 0 ? firstPart : unknownTag2;
2003
- const appendResult = await asyncRetry(
2004
- () => withConnection(
2005
- (connection) => appendToStream(connection, streamName, streamType, events, {
2006
- ...appendOptions,
2007
- onBeforeCommit: async (messages, context) => {
2008
- if (inlineProjections.length > 0)
2009
- await handleProjections({
2010
- projections: inlineProjections,
2011
- events: messages,
2012
- execute: context.connection.execute,
2013
- connection: context.connection,
2014
- driverType: options.driver.driverType
2015
- });
2016
- if (onBeforeCommitHook)
2017
- await onBeforeCommitHook(messages, context);
2018
- }
2019
- })
2020
- ),
2021
- {
2022
- retries: 3,
2023
- minTimeout: 250,
2024
- factor: 1.5,
2025
- shouldRetryError: (error) => {
2026
- return (
2027
- // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-explicit-any
2028
- error.code === "SQLITE_BUSY" || _dumbo.DumboError.isInstanceOf(error, {
2029
- errorType: _dumbo.LockNotAvailableError.ErrorType
2030
- })
2031
- );
2003
+ const appendResult = await withConnection(
2004
+ (connection) => appendToStream(connection, streamName, streamType, events, {
2005
+ ...appendOptions,
2006
+ onBeforeCommit: async (messages, context) => {
2007
+ if (inlineProjections.length > 0)
2008
+ await handleProjections({
2009
+ projections: inlineProjections,
2010
+ events: messages,
2011
+ execute: context.connection.execute,
2012
+ connection: context.connection,
2013
+ driverType: options.driver.driverType
2014
+ });
2015
+ if (onBeforeCommitHook)
2016
+ await onBeforeCommitHook(messages, context);
2032
2017
  }
2033
- }
2018
+ }),
2019
+ { readonly: false }
2034
2020
  );
2035
2021
  if (!appendResult.success)
2036
2022
  throw new ExpectedVersionConflictError(
@@ -2046,7 +2032,8 @@ var getSQLiteEventStore = (options) => {
2046
2032
  },
2047
2033
  streamExists(streamName, options2) {
2048
2034
  return withConnection(
2049
- ({ execute }) => streamExists(execute, streamName, options2)
2035
+ ({ execute }) => streamExists(execute, streamName, options2),
2036
+ { readonly: true }
2050
2037
  );
2051
2038
  },
2052
2039
  consumer: (consumerOptions) => sqliteEventStoreConsumer({