@event-driven-io/emmett-postgresql 0.36.0 → 0.37.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 +63 -57
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +22 -16
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
package/dist/index.cjs
CHANGED
|
@@ -139,22 +139,6 @@ var deepEquals = (left, right) => {
|
|
|
139
139
|
var isEquatable = (left) => {
|
|
140
140
|
return left && typeof left === "object" && "equals" in left && typeof left["equals"] === "function";
|
|
141
141
|
};
|
|
142
|
-
var asyncRetry = async (fn, opts) => {
|
|
143
|
-
if (opts === void 0 || opts.retries === 0) return fn();
|
|
144
|
-
return _asyncretry2.default.call(void 0,
|
|
145
|
-
async (bail) => {
|
|
146
|
-
try {
|
|
147
|
-
return await fn();
|
|
148
|
-
} catch (error2) {
|
|
149
|
-
if (_optionalChain([opts, 'optionalAccess', _10 => _10.shouldRetryError]) && !opts.shouldRetryError(error2)) {
|
|
150
|
-
bail(error2);
|
|
151
|
-
}
|
|
152
|
-
throw error2;
|
|
153
|
-
}
|
|
154
|
-
},
|
|
155
|
-
_nullishCoalesce(opts, () => ( { retries: 0 }))
|
|
156
|
-
);
|
|
157
|
-
};
|
|
158
142
|
var ParseError = class extends Error {
|
|
159
143
|
constructor(text) {
|
|
160
144
|
super(`Cannot parse! ${text}`);
|
|
@@ -163,19 +147,41 @@ var ParseError = class extends Error {
|
|
|
163
147
|
var JSONParser = {
|
|
164
148
|
stringify: (value, options) => {
|
|
165
149
|
return JSON.stringify(
|
|
166
|
-
_optionalChain([options, 'optionalAccess',
|
|
150
|
+
_optionalChain([options, 'optionalAccess', _10 => _10.map]) ? options.map(value) : value,
|
|
167
151
|
//TODO: Consider adding support to DateTime and adding specific format to mark that's a bigint
|
|
168
152
|
// eslint-disable-next-line @typescript-eslint/no-unsafe-return
|
|
169
153
|
(_, v) => typeof v === "bigint" ? v.toString() : v
|
|
170
154
|
);
|
|
171
155
|
},
|
|
172
156
|
parse: (text, options) => {
|
|
173
|
-
const parsed = JSON.parse(text, _optionalChain([options, 'optionalAccess',
|
|
174
|
-
if (_optionalChain([options, 'optionalAccess',
|
|
157
|
+
const parsed = JSON.parse(text, _optionalChain([options, 'optionalAccess', _11 => _11.reviver]));
|
|
158
|
+
if (_optionalChain([options, 'optionalAccess', _12 => _12.typeCheck]) && !_optionalChain([options, 'optionalAccess', _13 => _13.typeCheck, 'call', _14 => _14(parsed)]))
|
|
175
159
|
throw new ParseError(text);
|
|
176
|
-
return _optionalChain([options, 'optionalAccess',
|
|
160
|
+
return _optionalChain([options, 'optionalAccess', _15 => _15.map]) ? options.map(parsed) : parsed;
|
|
177
161
|
}
|
|
178
162
|
};
|
|
163
|
+
var asyncRetry = async (fn, opts) => {
|
|
164
|
+
if (opts === void 0 || opts.retries === 0) return fn();
|
|
165
|
+
return _asyncretry2.default.call(void 0,
|
|
166
|
+
async (bail) => {
|
|
167
|
+
try {
|
|
168
|
+
const result = await fn();
|
|
169
|
+
if (_optionalChain([opts, 'optionalAccess', _16 => _16.shouldRetryResult]) && opts.shouldRetryResult(result)) {
|
|
170
|
+
throw new EmmettError(
|
|
171
|
+
`Retrying because of result: ${JSONParser.stringify(result)}`
|
|
172
|
+
);
|
|
173
|
+
}
|
|
174
|
+
return result;
|
|
175
|
+
} catch (error2) {
|
|
176
|
+
if (_optionalChain([opts, 'optionalAccess', _17 => _17.shouldRetryError]) && !opts.shouldRetryError(error2)) {
|
|
177
|
+
bail(error2);
|
|
178
|
+
}
|
|
179
|
+
throw error2;
|
|
180
|
+
}
|
|
181
|
+
},
|
|
182
|
+
_nullishCoalesce(opts, () => ( { retries: 0 }))
|
|
183
|
+
);
|
|
184
|
+
};
|
|
179
185
|
var MessageProcessorType = {
|
|
180
186
|
PROJECTOR: "projector",
|
|
181
187
|
REACTOR: "reactor"
|
|
@@ -189,18 +195,18 @@ var reactor = (options) => {
|
|
|
189
195
|
return {
|
|
190
196
|
id: options.processorId,
|
|
191
197
|
type: _nullishCoalesce(options.type, () => ( MessageProcessorType.REACTOR)),
|
|
192
|
-
close: () => _optionalChain([options, 'access',
|
|
198
|
+
close: () => _optionalChain([options, 'access', _18 => _18.hooks, 'optionalAccess', _19 => _19.onClose]) ? _optionalChain([options, 'access', _20 => _20.hooks, 'optionalAccess', _21 => _21.onClose, 'call', _22 => _22()]) : Promise.resolve(),
|
|
193
199
|
start: async (startOptions) => {
|
|
194
200
|
isActive = true;
|
|
195
201
|
return await processingScope(async (context) => {
|
|
196
|
-
if (_optionalChain([options, 'access',
|
|
197
|
-
await _optionalChain([options, 'access',
|
|
202
|
+
if (_optionalChain([options, 'access', _23 => _23.hooks, 'optionalAccess', _24 => _24.onStart])) {
|
|
203
|
+
await _optionalChain([options, 'access', _25 => _25.hooks, 'optionalAccess', _26 => _26.onStart, 'call', _27 => _27(context)]);
|
|
198
204
|
}
|
|
199
205
|
if (options.startFrom !== "CURRENT" && options.startFrom)
|
|
200
206
|
return options.startFrom;
|
|
201
207
|
let lastCheckpoint = null;
|
|
202
208
|
if (checkpoints) {
|
|
203
|
-
const readResult = await _optionalChain([checkpoints, 'optionalAccess',
|
|
209
|
+
const readResult = await _optionalChain([checkpoints, 'optionalAccess', _28 => _28.read, 'call', _29 => _29(
|
|
204
210
|
{
|
|
205
211
|
processorId,
|
|
206
212
|
partition
|
|
@@ -265,12 +271,12 @@ var projector = (options) => {
|
|
|
265
271
|
type: MessageProcessorType.PROJECTOR,
|
|
266
272
|
processorId: _nullishCoalesce(options.processorId, () => ( `projection:${projection2.name}`)),
|
|
267
273
|
hooks: {
|
|
268
|
-
onStart: options.truncateOnStart && options.projection.truncate || _optionalChain([options, 'access',
|
|
274
|
+
onStart: options.truncateOnStart && options.projection.truncate || _optionalChain([options, 'access', _30 => _30.hooks, 'optionalAccess', _31 => _31.onStart]) ? async (context) => {
|
|
269
275
|
if (options.truncateOnStart && options.projection.truncate)
|
|
270
276
|
await options.projection.truncate(context);
|
|
271
|
-
if (_optionalChain([options, 'access',
|
|
277
|
+
if (_optionalChain([options, 'access', _32 => _32.hooks, 'optionalAccess', _33 => _33.onStart])) await _optionalChain([options, 'access', _34 => _34.hooks, 'optionalAccess', _35 => _35.onStart, 'call', _36 => _36(context)]);
|
|
272
278
|
} : void 0,
|
|
273
|
-
onClose: _optionalChain([options, 'access',
|
|
279
|
+
onClose: _optionalChain([options, 'access', _37 => _37.hooks, 'optionalAccess', _38 => _38.onClose])
|
|
274
280
|
},
|
|
275
281
|
eachMessage: async (event2, context) => {
|
|
276
282
|
if (!projection2.canHandle.includes(event2.type)) return;
|
|
@@ -587,7 +593,7 @@ var readLastMessageGlobalPosition = async (execute, options) => {
|
|
|
587
593
|
WHERE partition = %L AND is_archived = FALSE AND transaction_id < pg_snapshot_xmin(pg_current_snapshot())
|
|
588
594
|
ORDER BY transaction_id, global_position
|
|
589
595
|
LIMIT 1`,
|
|
590
|
-
_nullishCoalesce(_optionalChain([options, 'optionalAccess',
|
|
596
|
+
_nullishCoalesce(_optionalChain([options, 'optionalAccess', _39 => _39.partition]), () => ( defaultTag))
|
|
591
597
|
)
|
|
592
598
|
)
|
|
593
599
|
);
|
|
@@ -612,7 +618,7 @@ var readMessagesBatch = async (execute, options) => {
|
|
|
612
618
|
WHERE partition = %L AND is_archived = FALSE AND transaction_id < pg_snapshot_xmin(pg_current_snapshot()) ${fromCondition} ${toCondition}
|
|
613
619
|
ORDER BY transaction_id, global_position
|
|
614
620
|
${limitCondition}`,
|
|
615
|
-
_nullishCoalesce(_optionalChain([options, 'optionalAccess',
|
|
621
|
+
_nullishCoalesce(_optionalChain([options, 'optionalAccess', _40 => _40.partition]), () => ( defaultTag))
|
|
616
622
|
)
|
|
617
623
|
),
|
|
618
624
|
(row) => {
|
|
@@ -676,7 +682,7 @@ var postgreSQLEventStoreMessageBatchPuller = ({
|
|
|
676
682
|
}
|
|
677
683
|
readMessagesOptions.after = currentGlobalPosition;
|
|
678
684
|
await new Promise((resolve) => setTimeout(resolve, waitTime));
|
|
679
|
-
if (_optionalChain([stopWhen, 'optionalAccess',
|
|
685
|
+
if (_optionalChain([stopWhen, 'optionalAccess', _41 => _41.noMessagesLeft]) === true && !areMessagesLeft) {
|
|
680
686
|
isRunning = false;
|
|
681
687
|
break;
|
|
682
688
|
}
|
|
@@ -827,7 +833,7 @@ var appendToStream = (pool, streamName, streamType, messages, options) => pool.w
|
|
|
827
833
|
let appendResult;
|
|
828
834
|
try {
|
|
829
835
|
const expectedStreamVersion = toExpectedVersion(
|
|
830
|
-
_optionalChain([options, 'optionalAccess',
|
|
836
|
+
_optionalChain([options, 'optionalAccess', _42 => _42.expectedStreamVersion])
|
|
831
837
|
);
|
|
832
838
|
const messagesToAppend = messages.map((e, i) => ({
|
|
833
839
|
...e,
|
|
@@ -848,7 +854,7 @@ var appendToStream = (pool, streamName, streamType, messages, options) => pool.w
|
|
|
848
854
|
expectedStreamVersion
|
|
849
855
|
}
|
|
850
856
|
);
|
|
851
|
-
if (_optionalChain([options, 'optionalAccess',
|
|
857
|
+
if (_optionalChain([options, 'optionalAccess', _43 => _43.beforeCommitHook]))
|
|
852
858
|
await options.beforeCommitHook(messagesToAppend, { transaction });
|
|
853
859
|
} catch (error) {
|
|
854
860
|
if (!isOptimisticConcurrencyError(error)) throw error;
|
|
@@ -906,8 +912,8 @@ var appendEventsRaw = (execute, streamId, streamType, messages, options) => _dum
|
|
|
906
912
|
messages.map((e) => _dumbo.sql.call(void 0, "%L", e.kind === "Event" ? "E" : "C")).join(","),
|
|
907
913
|
streamId,
|
|
908
914
|
streamType,
|
|
909
|
-
_nullishCoalesce(_optionalChain([options, 'optionalAccess',
|
|
910
|
-
_nullishCoalesce(_optionalChain([options, 'optionalAccess',
|
|
915
|
+
_nullishCoalesce(_optionalChain([options, 'optionalAccess', _44 => _44.expectedStreamVersion]), () => ( "NULL")),
|
|
916
|
+
_nullishCoalesce(_optionalChain([options, 'optionalAccess', _45 => _45.partition]), () => ( defaultTag))
|
|
911
917
|
)
|
|
912
918
|
)
|
|
913
919
|
);
|
|
@@ -1351,7 +1357,7 @@ var readProcessorCheckpoint = async (execute, options) => {
|
|
|
1351
1357
|
FROM ${subscriptionsTable.name}
|
|
1352
1358
|
WHERE partition = %L AND subscription_id = %L
|
|
1353
1359
|
LIMIT 1`,
|
|
1354
|
-
_nullishCoalesce(_optionalChain([options, 'optionalAccess',
|
|
1360
|
+
_nullishCoalesce(_optionalChain([options, 'optionalAccess', _46 => _46.partition]), () => ( defaultTag)),
|
|
1355
1361
|
options.processorId
|
|
1356
1362
|
)
|
|
1357
1363
|
)
|
|
@@ -1376,7 +1382,7 @@ var readStream = async (execute, streamId, options) => {
|
|
|
1376
1382
|
FROM ${messagesTable.name}
|
|
1377
1383
|
WHERE stream_id = %L AND partition = %L AND is_archived = FALSE ${fromCondition} ${toCondition}`,
|
|
1378
1384
|
streamId,
|
|
1379
|
-
_nullishCoalesce(_optionalChain([options, 'optionalAccess',
|
|
1385
|
+
_nullishCoalesce(_optionalChain([options, 'optionalAccess', _47 => _47.partition]), () => ( defaultTag))
|
|
1380
1386
|
)
|
|
1381
1387
|
),
|
|
1382
1388
|
(row) => {
|
|
@@ -1435,7 +1441,7 @@ var createEventStoreSchema = async (pool) => {
|
|
|
1435
1441
|
var postgreSQLCheckpointer = () => ({
|
|
1436
1442
|
read: async (options, context) => {
|
|
1437
1443
|
const result = await readProcessorCheckpoint(context.execute, options);
|
|
1438
|
-
return { lastCheckpoint: _optionalChain([result, 'optionalAccess',
|
|
1444
|
+
return { lastCheckpoint: _optionalChain([result, 'optionalAccess', _48 => _48.lastProcessedPosition]) };
|
|
1439
1445
|
},
|
|
1440
1446
|
store: async (options, context) => {
|
|
1441
1447
|
const result = await storeProcessorCheckpoint(context.execute, {
|
|
@@ -1452,13 +1458,13 @@ var postgreSQLProcessingScope = (options) => {
|
|
|
1452
1458
|
const processorConnectionString = options.connectionString;
|
|
1453
1459
|
const processorPool = options.pool;
|
|
1454
1460
|
const processingScope = async (handler, partialContext) => {
|
|
1455
|
-
const connection = _optionalChain([partialContext, 'optionalAccess',
|
|
1456
|
-
const connectionString = _nullishCoalesce(processorConnectionString, () => ( _optionalChain([connection, 'optionalAccess',
|
|
1461
|
+
const connection = _optionalChain([partialContext, 'optionalAccess', _49 => _49.connection]);
|
|
1462
|
+
const connectionString = _nullishCoalesce(processorConnectionString, () => ( _optionalChain([connection, 'optionalAccess', _50 => _50.connectionString])));
|
|
1457
1463
|
if (!connectionString)
|
|
1458
1464
|
throw new EmmettError(
|
|
1459
1465
|
`PostgreSQL processor '${options.processorId}' is missing connection string. Ensure that you passed it through options`
|
|
1460
1466
|
);
|
|
1461
|
-
const pool = _nullishCoalesce((!processorConnectionString || connectionString == processorConnectionString ? _optionalChain([connection, 'optionalAccess',
|
|
1467
|
+
const pool = _nullishCoalesce((!processorConnectionString || connectionString == processorConnectionString ? _optionalChain([connection, 'optionalAccess', _51 => _51.pool]) : processorPool), () => ( processorPool));
|
|
1462
1468
|
if (!pool)
|
|
1463
1469
|
throw new EmmettError(
|
|
1464
1470
|
`PostgreSQL processor '${options.processorId}' is missing connection string. Ensure that you passed it through options`
|
|
@@ -1496,9 +1502,9 @@ var getProcessorPool = (options) => {
|
|
|
1496
1502
|
var postgreSQLProjector = (options) => {
|
|
1497
1503
|
const { pool, connectionString, close } = getProcessorPool(options);
|
|
1498
1504
|
const hooks = {
|
|
1499
|
-
onStart: _optionalChain([options, 'access',
|
|
1500
|
-
onClose: _optionalChain([options, 'access',
|
|
1501
|
-
if (_optionalChain([options, 'access',
|
|
1505
|
+
onStart: _optionalChain([options, 'access', _52 => _52.hooks, 'optionalAccess', _53 => _53.onStart]),
|
|
1506
|
+
onClose: _optionalChain([options, 'access', _54 => _54.hooks, 'optionalAccess', _55 => _55.onClose]) || close ? async () => {
|
|
1507
|
+
if (_optionalChain([options, 'access', _56 => _56.hooks, 'optionalAccess', _57 => _57.onClose])) await _optionalChain([options, 'access', _58 => _58.hooks, 'optionalAccess', _59 => _59.onClose, 'call', _60 => _60()]);
|
|
1502
1508
|
if (close) await close();
|
|
1503
1509
|
} : void 0
|
|
1504
1510
|
};
|
|
@@ -1516,9 +1522,9 @@ var postgreSQLProjector = (options) => {
|
|
|
1516
1522
|
var postgreSQLReactor = (options) => {
|
|
1517
1523
|
const { pool, connectionString, close } = getProcessorPool(options);
|
|
1518
1524
|
const hooks = {
|
|
1519
|
-
onStart: _optionalChain([options, 'access',
|
|
1520
|
-
onClose: _optionalChain([options, 'access',
|
|
1521
|
-
if (_optionalChain([options, 'access',
|
|
1525
|
+
onStart: _optionalChain([options, 'access', _61 => _61.hooks, 'optionalAccess', _62 => _62.onStart]),
|
|
1526
|
+
onClose: _optionalChain([options, 'access', _63 => _63.hooks, 'optionalAccess', _64 => _64.onClose]) || close ? async () => {
|
|
1527
|
+
if (_optionalChain([options, 'access', _65 => _65.hooks, 'optionalAccess', _66 => _66.onClose])) await _optionalChain([options, 'access', _67 => _67.hooks, 'optionalAccess', _68 => _68.onClose, 'call', _69 => _69()]);
|
|
1522
1528
|
if (close) await close();
|
|
1523
1529
|
} : void 0
|
|
1524
1530
|
};
|
|
@@ -1568,7 +1574,7 @@ var postgreSQLEventStoreConsumer = (options) => {
|
|
|
1568
1574
|
})
|
|
1569
1575
|
);
|
|
1570
1576
|
return result.some(
|
|
1571
|
-
(r) => r.status === "fulfilled" && _optionalChain([r, 'access',
|
|
1577
|
+
(r) => r.status === "fulfilled" && _optionalChain([r, 'access', _70 => _70.value, 'optionalAccess', _71 => _71.type]) !== "STOP"
|
|
1572
1578
|
) ? void 0 : {
|
|
1573
1579
|
type: "STOP"
|
|
1574
1580
|
};
|
|
@@ -1577,8 +1583,8 @@ var postgreSQLEventStoreConsumer = (options) => {
|
|
|
1577
1583
|
stopWhen: options.stopWhen,
|
|
1578
1584
|
executor: pool.execute,
|
|
1579
1585
|
eachBatch,
|
|
1580
|
-
batchSize: _nullishCoalesce(_optionalChain([pulling, 'optionalAccess',
|
|
1581
|
-
pullingFrequencyInMs: _nullishCoalesce(_optionalChain([pulling, 'optionalAccess',
|
|
1586
|
+
batchSize: _nullishCoalesce(_optionalChain([pulling, 'optionalAccess', _72 => _72.batchSize]), () => ( DefaultPostgreSQLEventStoreProcessorBatchSize)),
|
|
1587
|
+
pullingFrequencyInMs: _nullishCoalesce(_optionalChain([pulling, 'optionalAccess', _73 => _73.pullingFrequencyInMs]), () => ( DefaultPostgreSQLEventStoreProcessorPullingFrequencyInMs))
|
|
1582
1588
|
});
|
|
1583
1589
|
const stop = async () => {
|
|
1584
1590
|
if (!isRunning) return;
|
|
@@ -1891,7 +1897,7 @@ var PostgreSQLProjectionSpec = {
|
|
|
1891
1897
|
const allEvents = [];
|
|
1892
1898
|
const run = async (pool) => {
|
|
1893
1899
|
let globalPosition = 0n;
|
|
1894
|
-
const numberOfTimes = _nullishCoalesce(_optionalChain([options2, 'optionalAccess',
|
|
1900
|
+
const numberOfTimes = _nullishCoalesce(_optionalChain([options2, 'optionalAccess', _74 => _74.numberOfTimes]), () => ( 1));
|
|
1895
1901
|
for (const event of [
|
|
1896
1902
|
...givenEvents,
|
|
1897
1903
|
...Array.from({ length: numberOfTimes }).flatMap(() => events)
|
|
@@ -1948,18 +1954,18 @@ var PostgreSQLProjectionSpec = {
|
|
|
1948
1954
|
if (!isErrorConstructor(args[0])) {
|
|
1949
1955
|
assertTrue(
|
|
1950
1956
|
args[0](error),
|
|
1951
|
-
`Error didn't match the error condition: ${_optionalChain([error, 'optionalAccess',
|
|
1957
|
+
`Error didn't match the error condition: ${_optionalChain([error, 'optionalAccess', _75 => _75.toString, 'call', _76 => _76()])}`
|
|
1952
1958
|
);
|
|
1953
1959
|
return;
|
|
1954
1960
|
}
|
|
1955
1961
|
assertTrue(
|
|
1956
1962
|
error instanceof args[0],
|
|
1957
|
-
`Caught error is not an instance of the expected type: ${_optionalChain([error, 'optionalAccess',
|
|
1963
|
+
`Caught error is not an instance of the expected type: ${_optionalChain([error, 'optionalAccess', _77 => _77.toString, 'call', _78 => _78()])}`
|
|
1958
1964
|
);
|
|
1959
1965
|
if (args[1]) {
|
|
1960
1966
|
assertTrue(
|
|
1961
1967
|
args[1](error),
|
|
1962
|
-
`Error didn't match the error condition: ${_optionalChain([error, 'optionalAccess',
|
|
1968
|
+
`Error didn't match the error condition: ${_optionalChain([error, 'optionalAccess', _79 => _79.toString, 'call', _80 => _80()])}`
|
|
1963
1969
|
);
|
|
1964
1970
|
}
|
|
1965
1971
|
} finally {
|
|
@@ -1978,7 +1984,7 @@ var eventInStream = (streamName, event) => {
|
|
|
1978
1984
|
...event,
|
|
1979
1985
|
metadata: {
|
|
1980
1986
|
..._nullishCoalesce(event.metadata, () => ( {})),
|
|
1981
|
-
streamName: _nullishCoalesce(_optionalChain([event, 'access',
|
|
1987
|
+
streamName: _nullishCoalesce(_optionalChain([event, 'access', _81 => _81.metadata, 'optionalAccess', _82 => _82.streamName]), () => ( streamName))
|
|
1982
1988
|
}
|
|
1983
1989
|
};
|
|
1984
1990
|
};
|
|
@@ -2055,7 +2061,7 @@ var getPostgreSQLEventStore = (connectionString, options = defaultPostgreSQLOpti
|
|
|
2055
2061
|
};
|
|
2056
2062
|
const pool = "dumbo" in poolOptions ? poolOptions.dumbo : _dumbo.dumbo.call(void 0, poolOptions);
|
|
2057
2063
|
let migrateSchema;
|
|
2058
|
-
const autoGenerateSchema = _optionalChain([options, 'access',
|
|
2064
|
+
const autoGenerateSchema = _optionalChain([options, 'access', _83 => _83.schema, 'optionalAccess', _84 => _84.autoMigration]) === void 0 || _optionalChain([options, 'access', _85 => _85.schema, 'optionalAccess', _86 => _86.autoMigration]) !== "None";
|
|
2059
2065
|
const ensureSchemaExists = () => {
|
|
2060
2066
|
if (!autoGenerateSchema) return Promise.resolve();
|
|
2061
2067
|
if (!migrateSchema) {
|
|
@@ -2085,7 +2091,7 @@ var getPostgreSQLEventStore = (connectionString, options = defaultPostgreSQLOpti
|
|
|
2085
2091
|
},
|
|
2086
2092
|
async aggregateStream(streamName, options2) {
|
|
2087
2093
|
const { evolve, initialState, read } = options2;
|
|
2088
|
-
const expectedStreamVersion = _optionalChain([read, 'optionalAccess',
|
|
2094
|
+
const expectedStreamVersion = _optionalChain([read, 'optionalAccess', _87 => _87.expectedStreamVersion]);
|
|
2089
2095
|
let state = initialState();
|
|
2090
2096
|
const result = await this.readStream(streamName, options2.read);
|
|
2091
2097
|
const currentStreamVersion = result.currentStreamVersion;
|
|
@@ -2126,7 +2132,7 @@ var getPostgreSQLEventStore = (connectionString, options = defaultPostgreSQLOpti
|
|
|
2126
2132
|
throw new ExpectedVersionConflictError(
|
|
2127
2133
|
-1n,
|
|
2128
2134
|
//TODO: Return actual version in case of error
|
|
2129
|
-
_nullishCoalesce(_optionalChain([options2, 'optionalAccess',
|
|
2135
|
+
_nullishCoalesce(_optionalChain([options2, 'optionalAccess', _88 => _88.expectedStreamVersion]), () => ( NO_CONCURRENCY_CHECK))
|
|
2130
2136
|
);
|
|
2131
2137
|
return {
|
|
2132
2138
|
nextExpectedStreamVersion: appendResult.nextStreamPosition,
|