@event-driven-io/emmett-sqlite 0.41.0-alpha.3 → 0.41.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 +47 -46
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +40 -39
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.d.cts
CHANGED
|
@@ -335,4 +335,4 @@ declare const subscriptionsTable: {
|
|
|
335
335
|
name: string;
|
|
336
336
|
};
|
|
337
337
|
|
|
338
|
-
export { type AppendEventResult, type EventHandler, InMemorySQLiteDatabase, InMemorySharedCacheSQLiteDatabase, type Parameters$1 as Parameters, type ReadLastMessageGlobalPositionResult, type ReadMessagesBatchOptions, type ReadMessagesBatchResult, type ReadProcessorCheckpointResult, type SQLiteConnection, type SQLiteError, type SQLiteEventStore, type SQLiteEventStoreConnectionOptions, SQLiteEventStoreDefaultStreamVersion, type SQLiteEventStoreOptions, type SQLiteProjectionAssert, type SQLiteProjectionDefinition, type SQLiteProjectionHandler, type SQLiteProjectionHandlerContext, type SQLiteProjectionHandlerOptions, SQLiteProjectionSpec, type SQLiteProjectionSpecEvent, type SQLiteProjectionSpecOptions, type SQLiteProjectionSpecWhenOptions, type SQLiteRawBatchSQLProjection, type SQLiteRawSQLProjection, type SQLiteReadEvent, type SQLiteReadEventMetadata, type StoreLastProcessedProcessorPositionResult, appendToStream, assertSQLQueryResultMatches, createEventStoreSchema, defaultTag, emmettPrefix, eventInStream, eventsInStream, expectSQL, getSQLiteEventStore, globalNames, globalTag, handleProjections, isSQLiteError, messagesTable, messagesTableSQL, newEventsInStream, readLastMessageGlobalPosition, readMessagesBatch, readProcessorCheckpoint, readStream, schemaSQL, sql, sqliteConnection, sqliteProjection, sqliteRawBatchSQLProjection, sqliteRawSQLProjection, storeProcessorCheckpoint, streamsTable, streamsTableSQL, subscriptionsTable, subscriptionsTableSQL };
|
|
338
|
+
export { type AppendEventResult, type EventHandler, InMemorySQLiteDatabase, InMemorySharedCacheSQLiteDatabase, type Parameters$1 as Parameters, type ReadLastMessageGlobalPositionResult, type ReadMessagesBatchOptions, type ReadMessagesBatchResult, type ReadProcessorCheckpointResult, type SQLiteConnection, SQLiteConnectionPool, type SQLiteConnectionPoolOptions, type SQLiteError, type SQLiteEventStore, type SQLiteEventStoreConnectionOptions, SQLiteEventStoreDefaultStreamVersion, type SQLiteEventStoreOptions, type SQLiteProjectionAssert, type SQLiteProjectionDefinition, type SQLiteProjectionHandler, type SQLiteProjectionHandlerContext, type SQLiteProjectionHandlerOptions, SQLiteProjectionSpec, type SQLiteProjectionSpecEvent, type SQLiteProjectionSpecOptions, type SQLiteProjectionSpecWhenOptions, type SQLiteRawBatchSQLProjection, type SQLiteRawSQLProjection, type SQLiteReadEvent, type SQLiteReadEventMetadata, type StoreLastProcessedProcessorPositionResult, appendToStream, assertSQLQueryResultMatches, createEventStoreSchema, defaultTag, emmettPrefix, eventInStream, eventsInStream, expectSQL, getSQLiteEventStore, globalNames, globalTag, handleProjections, isSQLiteError, messagesTable, messagesTableSQL, newEventsInStream, readLastMessageGlobalPosition, readMessagesBatch, readProcessorCheckpoint, readStream, schemaSQL, sql, sqliteConnection, sqliteProjection, sqliteRawBatchSQLProjection, sqliteRawSQLProjection, storeProcessorCheckpoint, streamsTable, streamsTableSQL, subscriptionsTable, subscriptionsTableSQL };
|
package/dist/index.d.ts
CHANGED
|
@@ -335,4 +335,4 @@ declare const subscriptionsTable: {
|
|
|
335
335
|
name: string;
|
|
336
336
|
};
|
|
337
337
|
|
|
338
|
-
export { type AppendEventResult, type EventHandler, InMemorySQLiteDatabase, InMemorySharedCacheSQLiteDatabase, type Parameters$1 as Parameters, type ReadLastMessageGlobalPositionResult, type ReadMessagesBatchOptions, type ReadMessagesBatchResult, type ReadProcessorCheckpointResult, type SQLiteConnection, type SQLiteError, type SQLiteEventStore, type SQLiteEventStoreConnectionOptions, SQLiteEventStoreDefaultStreamVersion, type SQLiteEventStoreOptions, type SQLiteProjectionAssert, type SQLiteProjectionDefinition, type SQLiteProjectionHandler, type SQLiteProjectionHandlerContext, type SQLiteProjectionHandlerOptions, SQLiteProjectionSpec, type SQLiteProjectionSpecEvent, type SQLiteProjectionSpecOptions, type SQLiteProjectionSpecWhenOptions, type SQLiteRawBatchSQLProjection, type SQLiteRawSQLProjection, type SQLiteReadEvent, type SQLiteReadEventMetadata, type StoreLastProcessedProcessorPositionResult, appendToStream, assertSQLQueryResultMatches, createEventStoreSchema, defaultTag, emmettPrefix, eventInStream, eventsInStream, expectSQL, getSQLiteEventStore, globalNames, globalTag, handleProjections, isSQLiteError, messagesTable, messagesTableSQL, newEventsInStream, readLastMessageGlobalPosition, readMessagesBatch, readProcessorCheckpoint, readStream, schemaSQL, sql, sqliteConnection, sqliteProjection, sqliteRawBatchSQLProjection, sqliteRawSQLProjection, storeProcessorCheckpoint, streamsTable, streamsTableSQL, subscriptionsTable, subscriptionsTableSQL };
|
|
338
|
+
export { type AppendEventResult, type EventHandler, InMemorySQLiteDatabase, InMemorySharedCacheSQLiteDatabase, type Parameters$1 as Parameters, type ReadLastMessageGlobalPositionResult, type ReadMessagesBatchOptions, type ReadMessagesBatchResult, type ReadProcessorCheckpointResult, type SQLiteConnection, SQLiteConnectionPool, type SQLiteConnectionPoolOptions, type SQLiteError, type SQLiteEventStore, type SQLiteEventStoreConnectionOptions, SQLiteEventStoreDefaultStreamVersion, type SQLiteEventStoreOptions, type SQLiteProjectionAssert, type SQLiteProjectionDefinition, type SQLiteProjectionHandler, type SQLiteProjectionHandlerContext, type SQLiteProjectionHandlerOptions, SQLiteProjectionSpec, type SQLiteProjectionSpecEvent, type SQLiteProjectionSpecOptions, type SQLiteProjectionSpecWhenOptions, type SQLiteRawBatchSQLProjection, type SQLiteRawSQLProjection, type SQLiteReadEvent, type SQLiteReadEventMetadata, type StoreLastProcessedProcessorPositionResult, appendToStream, assertSQLQueryResultMatches, createEventStoreSchema, defaultTag, emmettPrefix, eventInStream, eventsInStream, expectSQL, getSQLiteEventStore, globalNames, globalTag, handleProjections, isSQLiteError, messagesTable, messagesTableSQL, newEventsInStream, readLastMessageGlobalPosition, readMessagesBatch, readProcessorCheckpoint, readStream, schemaSQL, sql, sqliteConnection, sqliteProjection, sqliteRawBatchSQLProjection, sqliteRawSQLProjection, storeProcessorCheckpoint, streamsTable, streamsTableSQL, subscriptionsTable, subscriptionsTableSQL };
|
package/dist/index.js
CHANGED
|
@@ -99,6 +99,45 @@ var rollbackTransaction = (db) => new Promise((resolve, reject) => {
|
|
|
99
99
|
});
|
|
100
100
|
});
|
|
101
101
|
|
|
102
|
+
// src/connection/sqliteConnectionPool.ts
|
|
103
|
+
var SQLiteConnectionPool = (options) => {
|
|
104
|
+
const fileName = options.fileName ?? InMemorySQLiteDatabase;
|
|
105
|
+
const isInMemory = fileName === InMemorySQLiteDatabase || fileName === InMemorySharedCacheSQLiteDatabase;
|
|
106
|
+
const singletonConnection = options.connectionOptions?.connection ?? (isInMemory ? sqliteConnection({
|
|
107
|
+
fileName
|
|
108
|
+
}) : null);
|
|
109
|
+
const isAmbientConnection = options.connectionOptions?.singleton === true && options.connectionOptions?.connection !== void 0;
|
|
110
|
+
const createConnection = () => {
|
|
111
|
+
return singletonConnection ?? sqliteConnection({
|
|
112
|
+
fileName
|
|
113
|
+
});
|
|
114
|
+
};
|
|
115
|
+
const closeConnection = (connection) => {
|
|
116
|
+
if (isInMemory || isAmbientConnection) {
|
|
117
|
+
return;
|
|
118
|
+
}
|
|
119
|
+
connection.close();
|
|
120
|
+
};
|
|
121
|
+
const withConnection = async (handler) => {
|
|
122
|
+
const connection = singletonConnection ?? createConnection();
|
|
123
|
+
try {
|
|
124
|
+
return await handler(connection);
|
|
125
|
+
} finally {
|
|
126
|
+
closeConnection(connection);
|
|
127
|
+
}
|
|
128
|
+
};
|
|
129
|
+
return {
|
|
130
|
+
connection: () => Promise.resolve(createConnection()),
|
|
131
|
+
withConnection,
|
|
132
|
+
close: () => {
|
|
133
|
+
if (singletonConnection && !isAmbientConnection) {
|
|
134
|
+
closeConnection(singletonConnection);
|
|
135
|
+
}
|
|
136
|
+
return Promise.resolve();
|
|
137
|
+
}
|
|
138
|
+
};
|
|
139
|
+
};
|
|
140
|
+
|
|
102
141
|
// ../emmett/dist/chunk-AZDDB5SF.js
|
|
103
142
|
var isNumber = (val) => typeof val === "number" && val === val;
|
|
104
143
|
var isBigint = (val) => typeof val === "bigint" && val === val;
|
|
@@ -565,45 +604,6 @@ var sqliteRawSQLProjection = (options) => {
|
|
|
565
604
|
// src/eventStore/projections/sqliteProjectionSpec.ts
|
|
566
605
|
import { v4 as uuid5 } from "uuid";
|
|
567
606
|
|
|
568
|
-
// src/connection/sqliteConnectionPool.ts
|
|
569
|
-
var SQLiteConnectionPool = (options) => {
|
|
570
|
-
const fileName = options.fileName ?? InMemorySQLiteDatabase;
|
|
571
|
-
const isInMemory = fileName === InMemorySQLiteDatabase || fileName === InMemorySharedCacheSQLiteDatabase;
|
|
572
|
-
const singletonConnection = options.connectionOptions?.connection ?? (isInMemory ? sqliteConnection({
|
|
573
|
-
fileName
|
|
574
|
-
}) : null);
|
|
575
|
-
const isAmbientConnection = options.connectionOptions?.singleton === true && options.connectionOptions?.connection !== void 0;
|
|
576
|
-
const createConnection = () => {
|
|
577
|
-
return singletonConnection ?? sqliteConnection({
|
|
578
|
-
fileName
|
|
579
|
-
});
|
|
580
|
-
};
|
|
581
|
-
const closeConnection = (connection) => {
|
|
582
|
-
if (isInMemory || isAmbientConnection) {
|
|
583
|
-
return;
|
|
584
|
-
}
|
|
585
|
-
connection.close();
|
|
586
|
-
};
|
|
587
|
-
const withConnection = async (handler) => {
|
|
588
|
-
const connection = singletonConnection ?? createConnection();
|
|
589
|
-
try {
|
|
590
|
-
return await handler(connection);
|
|
591
|
-
} finally {
|
|
592
|
-
closeConnection(connection);
|
|
593
|
-
}
|
|
594
|
-
};
|
|
595
|
-
return {
|
|
596
|
-
connection: () => Promise.resolve(createConnection()),
|
|
597
|
-
withConnection,
|
|
598
|
-
close: () => {
|
|
599
|
-
if (singletonConnection && !isAmbientConnection) {
|
|
600
|
-
closeConnection(singletonConnection);
|
|
601
|
-
}
|
|
602
|
-
return Promise.resolve();
|
|
603
|
-
}
|
|
604
|
-
};
|
|
605
|
-
};
|
|
606
|
-
|
|
607
607
|
// src/eventStore/schema/typing.ts
|
|
608
608
|
var emmettPrefix = "emt";
|
|
609
609
|
var globalTag = "global";
|
|
@@ -1573,6 +1573,7 @@ var expectSQL = {
|
|
|
1573
1573
|
export {
|
|
1574
1574
|
InMemorySQLiteDatabase,
|
|
1575
1575
|
InMemorySharedCacheSQLiteDatabase,
|
|
1576
|
+
SQLiteConnectionPool,
|
|
1576
1577
|
SQLiteEventStoreDefaultStreamVersion,
|
|
1577
1578
|
SQLiteProjectionSpec,
|
|
1578
1579
|
appendToStream,
|