@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.cjs
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 = _nullishCoalesce(options.fileName, () => ( InMemorySQLiteDatabase));
|
|
105
|
+
const isInMemory = fileName === InMemorySQLiteDatabase || fileName === InMemorySharedCacheSQLiteDatabase;
|
|
106
|
+
const singletonConnection = _nullishCoalesce(_optionalChain([options, 'access', _2 => _2.connectionOptions, 'optionalAccess', _3 => _3.connection]), () => ( (isInMemory ? sqliteConnection({
|
|
107
|
+
fileName
|
|
108
|
+
}) : null)));
|
|
109
|
+
const isAmbientConnection = _optionalChain([options, 'access', _4 => _4.connectionOptions, 'optionalAccess', _5 => _5.singleton]) === true && _optionalChain([options, 'access', _6 => _6.connectionOptions, 'optionalAccess', _7 => _7.connection]) !== void 0;
|
|
110
|
+
const createConnection = () => {
|
|
111
|
+
return _nullishCoalesce(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 = _nullishCoalesce(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;
|
|
@@ -140,7 +179,7 @@ var ConcurrencyError = class _ConcurrencyError extends EmmettError {
|
|
|
140
179
|
constructor(current, expected, message) {
|
|
141
180
|
super({
|
|
142
181
|
errorCode: EmmettError.Codes.ConcurrencyError,
|
|
143
|
-
message: _nullishCoalesce(message, () => ( `Expected version ${expected.toString()} does not match current ${_optionalChain([current, 'optionalAccess',
|
|
182
|
+
message: _nullishCoalesce(message, () => ( `Expected version ${expected.toString()} does not match current ${_optionalChain([current, 'optionalAccess', _8 => _8.toString, 'call', _9 => _9()])}`))
|
|
144
183
|
});
|
|
145
184
|
this.current = current;
|
|
146
185
|
this.expected = expected;
|
|
@@ -169,7 +208,7 @@ var assertExpectedVersionMatchesCurrent = (current, expected, defaultVersion) =>
|
|
|
169
208
|
};
|
|
170
209
|
var ExpectedVersionConflictError = class _ExpectedVersionConflictError extends ConcurrencyError {
|
|
171
210
|
constructor(current, expected) {
|
|
172
|
-
super(_optionalChain([current, 'optionalAccess',
|
|
211
|
+
super(_optionalChain([current, 'optionalAccess', _10 => _10.toString, 'call', _11 => _11()]), _optionalChain([expected, 'optionalAccess', _12 => _12.toString, 'call', _13 => _13()]));
|
|
173
212
|
Object.setPrototypeOf(this, _ExpectedVersionConflictError.prototype);
|
|
174
213
|
}
|
|
175
214
|
};
|
|
@@ -382,17 +421,17 @@ var ParseError = class extends Error {
|
|
|
382
421
|
var JSONParser = {
|
|
383
422
|
stringify: (value, options) => {
|
|
384
423
|
return JSON.stringify(
|
|
385
|
-
_optionalChain([options, 'optionalAccess',
|
|
424
|
+
_optionalChain([options, 'optionalAccess', _14 => _14.map]) ? options.map(value) : value,
|
|
386
425
|
//TODO: Consider adding support to DateTime and adding specific format to mark that's a bigint
|
|
387
426
|
// eslint-disable-next-line @typescript-eslint/no-unsafe-return
|
|
388
427
|
(_, v) => typeof v === "bigint" ? v.toString() : v
|
|
389
428
|
);
|
|
390
429
|
},
|
|
391
430
|
parse: (text, options) => {
|
|
392
|
-
const parsed = JSON.parse(text, _optionalChain([options, 'optionalAccess',
|
|
393
|
-
if (_optionalChain([options, 'optionalAccess',
|
|
431
|
+
const parsed = JSON.parse(text, _optionalChain([options, 'optionalAccess', _15 => _15.reviver]));
|
|
432
|
+
if (_optionalChain([options, 'optionalAccess', _16 => _16.typeCheck]) && !_optionalChain([options, 'optionalAccess', _17 => _17.typeCheck, 'call', _18 => _18(parsed)]))
|
|
394
433
|
throw new ParseError(text);
|
|
395
|
-
return _optionalChain([options, 'optionalAccess',
|
|
434
|
+
return _optionalChain([options, 'optionalAccess', _19 => _19.map]) ? options.map(parsed) : parsed;
|
|
396
435
|
}
|
|
397
436
|
};
|
|
398
437
|
var AssertionError = class extends Error {
|
|
@@ -565,45 +604,6 @@ var sqliteRawSQLProjection = (options) => {
|
|
|
565
604
|
// src/eventStore/projections/sqliteProjectionSpec.ts
|
|
566
605
|
|
|
567
606
|
|
|
568
|
-
// src/connection/sqliteConnectionPool.ts
|
|
569
|
-
var SQLiteConnectionPool = (options) => {
|
|
570
|
-
const fileName = _nullishCoalesce(options.fileName, () => ( InMemorySQLiteDatabase));
|
|
571
|
-
const isInMemory = fileName === InMemorySQLiteDatabase || fileName === InMemorySharedCacheSQLiteDatabase;
|
|
572
|
-
const singletonConnection = _nullishCoalesce(_optionalChain([options, 'access', _14 => _14.connectionOptions, 'optionalAccess', _15 => _15.connection]), () => ( (isInMemory ? sqliteConnection({
|
|
573
|
-
fileName
|
|
574
|
-
}) : null)));
|
|
575
|
-
const isAmbientConnection = _optionalChain([options, 'access', _16 => _16.connectionOptions, 'optionalAccess', _17 => _17.singleton]) === true && _optionalChain([options, 'access', _18 => _18.connectionOptions, 'optionalAccess', _19 => _19.connection]) !== void 0;
|
|
576
|
-
const createConnection = () => {
|
|
577
|
-
return _nullishCoalesce(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 = _nullishCoalesce(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";
|
|
@@ -1606,5 +1606,6 @@ var expectSQL = {
|
|
|
1606
1606
|
|
|
1607
1607
|
|
|
1608
1608
|
|
|
1609
|
-
|
|
1609
|
+
|
|
1610
|
+
exports.InMemorySQLiteDatabase = InMemorySQLiteDatabase; exports.InMemorySharedCacheSQLiteDatabase = InMemorySharedCacheSQLiteDatabase; exports.SQLiteConnectionPool = SQLiteConnectionPool; exports.SQLiteEventStoreDefaultStreamVersion = SQLiteEventStoreDefaultStreamVersion; exports.SQLiteProjectionSpec = SQLiteProjectionSpec; exports.appendToStream = appendToStream; exports.assertSQLQueryResultMatches = assertSQLQueryResultMatches; exports.createEventStoreSchema = createEventStoreSchema; exports.defaultTag = defaultTag; exports.emmettPrefix = emmettPrefix; exports.eventInStream = eventInStream; exports.eventsInStream = eventsInStream; exports.expectSQL = expectSQL; exports.getSQLiteEventStore = getSQLiteEventStore; exports.globalNames = globalNames; exports.globalTag = globalTag; exports.handleProjections = handleProjections; exports.isSQLiteError = isSQLiteError; exports.messagesTable = messagesTable; exports.messagesTableSQL = messagesTableSQL; exports.newEventsInStream = newEventsInStream; exports.readLastMessageGlobalPosition = readLastMessageGlobalPosition; exports.readMessagesBatch = readMessagesBatch; exports.readProcessorCheckpoint = readProcessorCheckpoint; exports.readStream = readStream; exports.schemaSQL = schemaSQL; exports.sql = sql; exports.sqliteConnection = sqliteConnection; exports.sqliteProjection = sqliteProjection; exports.sqliteRawBatchSQLProjection = sqliteRawBatchSQLProjection; exports.sqliteRawSQLProjection = sqliteRawSQLProjection; exports.storeProcessorCheckpoint = storeProcessorCheckpoint; exports.streamsTable = streamsTable; exports.streamsTableSQL = streamsTableSQL; exports.subscriptionsTable = subscriptionsTable; exports.subscriptionsTableSQL = subscriptionsTableSQL;
|
|
1610
1611
|
//# sourceMappingURL=index.cjs.map
|