@event-driven-io/emmett-sqlite 0.43.0-beta.3 → 0.43.0-beta.4
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/cloudflare.d.cts +1 -1
- package/dist/cloudflare.d.ts +1 -1
- package/dist/index.cjs +37 -17
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +40 -20
- package/dist/index.js.map +1 -1
- package/dist/sqlite3.d.cts +1 -1
- package/dist/sqlite3.d.ts +1 -1
- package/dist/{sqliteProjection-BJ6uAnzZ.d.cts → sqliteProjection-DBJa19a5.d.cts} +2 -2
- package/dist/{sqliteProjection-BJ6uAnzZ.d.ts → sqliteProjection-DBJa19a5.d.ts} +2 -2
- package/package.json +3 -3
package/dist/cloudflare.d.cts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { D1Database } from '@cloudflare/workers-types';
|
|
2
2
|
import { d1DumboDriver, D1PoolOptions } from '@event-driven-io/dumbo/cloudflare';
|
|
3
|
-
import { E as EventStoreDriver, S as SQLiteEventStoreOptions } from './sqliteProjection-
|
|
3
|
+
import { E as EventStoreDriver, S as SQLiteEventStoreOptions } from './sqliteProjection-DBJa19a5.cjs';
|
|
4
4
|
import '@event-driven-io/dumbo';
|
|
5
5
|
import '@event-driven-io/dumbo/sqlite';
|
|
6
6
|
import '@event-driven-io/emmett';
|
package/dist/cloudflare.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { D1Database } from '@cloudflare/workers-types';
|
|
2
2
|
import { d1DumboDriver, D1PoolOptions } from '@event-driven-io/dumbo/cloudflare';
|
|
3
|
-
import { E as EventStoreDriver, S as SQLiteEventStoreOptions } from './sqliteProjection-
|
|
3
|
+
import { E as EventStoreDriver, S as SQLiteEventStoreOptions } from './sqliteProjection-DBJa19a5.js';
|
|
4
4
|
import '@event-driven-io/dumbo';
|
|
5
5
|
import '@event-driven-io/dumbo/sqlite';
|
|
6
6
|
import '@event-driven-io/emmett';
|
package/dist/index.cjs
CHANGED
|
@@ -1540,6 +1540,10 @@ var readProcessorCheckpoint = async (execute, options) => {
|
|
|
1540
1540
|
// src/eventStore/SQLiteEventStore.ts
|
|
1541
1541
|
|
|
1542
1542
|
|
|
1543
|
+
|
|
1544
|
+
|
|
1545
|
+
|
|
1546
|
+
|
|
1543
1547
|
// src/eventStore/consumers/messageBatchProcessing/index.ts
|
|
1544
1548
|
var DefaultSQLiteEventStoreProcessorBatchSize = 100;
|
|
1545
1549
|
var DefaultSQLiteEventStoreProcessorPullingFrequencyInMs = 50;
|
|
@@ -1802,10 +1806,10 @@ var sqliteEventStoreConsumer = (options) => {
|
|
|
1802
1806
|
if (messagePuller) {
|
|
1803
1807
|
_optionalChain([abortController, 'optionalAccess', _94 => _94.abort, 'call', _95 => _95()]);
|
|
1804
1808
|
await messagePuller.stop();
|
|
1805
|
-
messagePuller = void 0;
|
|
1806
|
-
abortController = null;
|
|
1807
1809
|
}
|
|
1808
1810
|
await start;
|
|
1811
|
+
messagePuller = void 0;
|
|
1812
|
+
abortController = null;
|
|
1809
1813
|
await stopProcessors();
|
|
1810
1814
|
};
|
|
1811
1815
|
const init = async () => {
|
|
@@ -1925,7 +1929,7 @@ var getSQLiteEventStore = (options) => {
|
|
|
1925
1929
|
let migrateSchema = void 0;
|
|
1926
1930
|
const inlineProjections = (_nullishCoalesce(options.projections, () => ( []))).filter(({ type }) => type === "inline").map(({ projection: projection2 }) => projection2);
|
|
1927
1931
|
const onBeforeCommitHook = _optionalChain([options, 'access', _98 => _98.hooks, 'optionalAccess', _99 => _99.onBeforeCommit]);
|
|
1928
|
-
const withConnection =
|
|
1932
|
+
const withConnection = (handler) => pool.withConnection(async (connection) => {
|
|
1929
1933
|
await ensureSchemaExists(connection);
|
|
1930
1934
|
return await handler(connection);
|
|
1931
1935
|
});
|
|
@@ -1996,21 +2000,37 @@ var getSQLiteEventStore = (options) => {
|
|
|
1996
2000
|
appendToStream: async (streamName, events, appendOptions) => {
|
|
1997
2001
|
const [firstPart, ...rest] = streamName.split("-");
|
|
1998
2002
|
const streamType = firstPart && rest.length > 0 ? firstPart : unknownTag2;
|
|
1999
|
-
const appendResult = await
|
|
2000
|
-
(
|
|
2001
|
-
|
|
2002
|
-
|
|
2003
|
-
|
|
2004
|
-
|
|
2005
|
-
|
|
2006
|
-
|
|
2007
|
-
|
|
2008
|
-
|
|
2009
|
-
|
|
2010
|
-
|
|
2011
|
-
|
|
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
|
+
);
|
|
2012
2032
|
}
|
|
2013
|
-
}
|
|
2033
|
+
}
|
|
2014
2034
|
);
|
|
2015
2035
|
if (!appendResult.success)
|
|
2016
2036
|
throw new ExpectedVersionConflictError(
|