@event-driven-io/emmett-postgresql 0.38.0-alpha.5 → 0.38.0-alpha.7
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 +19 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +19 -2
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
package/dist/index.cjs
CHANGED
|
@@ -5,6 +5,7 @@ var _dumbo = require('@event-driven-io/dumbo');
|
|
|
5
5
|
|
|
6
6
|
// ../emmett/dist/chunk-SJ7ERGWB.js
|
|
7
7
|
var isNumber = (val) => typeof val === "number" && val === val;
|
|
8
|
+
var isBigint = (val) => typeof val === "bigint" && val === val;
|
|
8
9
|
var isString = (val) => typeof val === "string";
|
|
9
10
|
var isErrorConstructor = (expect) => {
|
|
10
11
|
return typeof expect === "function" && expect.prototype && // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
|
|
@@ -298,6 +299,19 @@ var NotifyAboutNoActiveReadersStream = (_class = class extends _webstreamspolyfi
|
|
|
298
299
|
}
|
|
299
300
|
}
|
|
300
301
|
}, _class);
|
|
302
|
+
var contextualGetCheckpoint = (context) => "getCheckpoint" in context && context.getCheckpoint && typeof context.getCheckpoint === "function" ? context.getCheckpoint : void 0;
|
|
303
|
+
var getCheckpoint = (message2, context) => {
|
|
304
|
+
const getCheckpoint2 = contextualGetCheckpoint(context);
|
|
305
|
+
return getCheckpoint2 ? getCheckpoint2(message2) : "globalPosition" in message2.metadata && // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
|
|
306
|
+
isBigint(message2.metadata.globalPosition) ? (
|
|
307
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
|
|
308
|
+
message2.metadata.globalPosition
|
|
309
|
+
) : "streamPosition" in message2.metadata && // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
|
|
310
|
+
isBigint(message2.metadata.streamPosition) ? (
|
|
311
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
|
|
312
|
+
message2.metadata.streamPosition
|
|
313
|
+
) : null;
|
|
314
|
+
};
|
|
301
315
|
var MessageProcessorType = {
|
|
302
316
|
PROJECTOR: "projector",
|
|
303
317
|
REACTOR: "reactor"
|
|
@@ -357,7 +371,8 @@ var reactor = (options) => {
|
|
|
357
371
|
version: options.version,
|
|
358
372
|
message: message2,
|
|
359
373
|
lastCheckpoint,
|
|
360
|
-
partition: options.partition
|
|
374
|
+
partition: options.partition,
|
|
375
|
+
getCheckpoint: contextualGetCheckpoint(context)
|
|
361
376
|
},
|
|
362
377
|
context
|
|
363
378
|
);
|
|
@@ -1462,9 +1477,10 @@ var postgreSQLCheckpointer = () => ({
|
|
|
1462
1477
|
return { lastCheckpoint: _optionalChain([result, 'optionalAccess', _48 => _48.lastProcessedPosition]) };
|
|
1463
1478
|
},
|
|
1464
1479
|
store: async (options, context) => {
|
|
1480
|
+
const newPosition = getCheckpoint(options.message, options);
|
|
1465
1481
|
const result = await storeProcessorCheckpoint(context.execute, {
|
|
1466
1482
|
lastProcessedPosition: options.lastCheckpoint,
|
|
1467
|
-
newPosition
|
|
1483
|
+
newPosition,
|
|
1468
1484
|
processorId: options.processorId,
|
|
1469
1485
|
partition: options.partition,
|
|
1470
1486
|
version: options.version
|
|
@@ -1490,6 +1506,7 @@ var postgreSQLProcessingScope = (options) => {
|
|
|
1490
1506
|
return pool.withTransaction(async (transaction) => {
|
|
1491
1507
|
const client = await transaction.connection.open();
|
|
1492
1508
|
return handler({
|
|
1509
|
+
...partialContext,
|
|
1493
1510
|
execute: transaction.execute,
|
|
1494
1511
|
connection: {
|
|
1495
1512
|
connectionString,
|