@dudousxd/nestjs-durable-store-mikro-orm 0.27.1 → 0.28.1
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 +81 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +6 -1
- package/dist/index.d.ts +6 -1
- package/dist/index.js +81 -0
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
package/dist/index.cjs
CHANGED
|
@@ -514,6 +514,15 @@ function durableEntities(options = {}) {
|
|
|
514
514
|
class: SignalWaiterEntity,
|
|
515
515
|
tableName: "durable_signal_waiters",
|
|
516
516
|
repository: /* @__PURE__ */ __name(() => SignalWaiterRepository, "repository"),
|
|
517
|
+
// A run's waiters: the `ctx.all` join barrier probes them once per settled child.
|
|
518
|
+
indexes: [
|
|
519
|
+
{
|
|
520
|
+
name: "durable_signal_waiters_run_id_idx",
|
|
521
|
+
properties: [
|
|
522
|
+
"runId"
|
|
523
|
+
]
|
|
524
|
+
}
|
|
525
|
+
],
|
|
517
526
|
properties: {
|
|
518
527
|
token: {
|
|
519
528
|
type: "string",
|
|
@@ -1099,6 +1108,18 @@ var MikroOrmStateStore = class _MikroOrmStateStore {
|
|
|
1099
1108
|
await em.upsert(StepCheckpointEntity, toCheckpointEntity(checkpoint));
|
|
1100
1109
|
await em.flush();
|
|
1101
1110
|
}
|
|
1111
|
+
async saveCheckpointIfPending(checkpoint) {
|
|
1112
|
+
const { runId: _runId, seq: _seq, ...data } = toCheckpointEntity(checkpoint);
|
|
1113
|
+
const affected = await this.fork().nativeUpdate(StepCheckpointEntity, {
|
|
1114
|
+
runId: checkpoint.runId,
|
|
1115
|
+
seq: checkpoint.seq,
|
|
1116
|
+
status: "pending"
|
|
1117
|
+
}, {
|
|
1118
|
+
...data,
|
|
1119
|
+
wakeAt: checkpoint.wakeAt != null ? new Date(checkpoint.wakeAt) : null
|
|
1120
|
+
});
|
|
1121
|
+
return affected > 0;
|
|
1122
|
+
}
|
|
1102
1123
|
async transaction(work) {
|
|
1103
1124
|
return this.fork().transactional(async (em) => work({
|
|
1104
1125
|
raw: em,
|
|
@@ -1640,6 +1661,66 @@ var MikroOrmStateStore = class _MikroOrmStateStore {
|
|
|
1640
1661
|
parallelGroup: e.parallelGroup ?? void 0
|
|
1641
1662
|
}));
|
|
1642
1663
|
}
|
|
1664
|
+
async registerChildWaits(entries) {
|
|
1665
|
+
if (entries.length === 0) return;
|
|
1666
|
+
await this.fork().transactional(async (em) => {
|
|
1667
|
+
await em.upsertMany(SignalWaiterEntity, entries.map(({ waiter }) => ({
|
|
1668
|
+
token: waiter.token,
|
|
1669
|
+
runId: waiter.runId,
|
|
1670
|
+
seq: waiter.seq,
|
|
1671
|
+
parallelGroup: waiter.parallelGroup ?? null
|
|
1672
|
+
})));
|
|
1673
|
+
await em.upsertMany(StepCheckpointEntity, entries.map(({ checkpoint }) => toCheckpointEntity(checkpoint)));
|
|
1674
|
+
});
|
|
1675
|
+
}
|
|
1676
|
+
async compactCheckpoints(runId, fromSeq, toSeq, into) {
|
|
1677
|
+
await this.fork().transactional(async (em) => {
|
|
1678
|
+
await em.nativeDelete(StepCheckpointEntity, {
|
|
1679
|
+
runId,
|
|
1680
|
+
seq: {
|
|
1681
|
+
$gte: fromSeq,
|
|
1682
|
+
$lte: toSeq
|
|
1683
|
+
}
|
|
1684
|
+
});
|
|
1685
|
+
await em.upsert(StepCheckpointEntity, toCheckpointEntity(into));
|
|
1686
|
+
});
|
|
1687
|
+
}
|
|
1688
|
+
async listSignalWaitersByRun(runIds) {
|
|
1689
|
+
if (runIds.length === 0) return [];
|
|
1690
|
+
const rows = await this.fork().find(SignalWaiterEntity, {
|
|
1691
|
+
runId: {
|
|
1692
|
+
$in: runIds
|
|
1693
|
+
}
|
|
1694
|
+
});
|
|
1695
|
+
return rows.map((e) => ({
|
|
1696
|
+
token: e.token,
|
|
1697
|
+
runId: e.runId,
|
|
1698
|
+
seq: e.seq,
|
|
1699
|
+
parallelGroup: e.parallelGroup ?? void 0
|
|
1700
|
+
}));
|
|
1701
|
+
}
|
|
1702
|
+
async hasSignalWaiter(runId, tokenPrefix) {
|
|
1703
|
+
const em = this.fork();
|
|
1704
|
+
const where = {
|
|
1705
|
+
runId,
|
|
1706
|
+
token: {
|
|
1707
|
+
$like: `${tokenPrefix}%`
|
|
1708
|
+
}
|
|
1709
|
+
};
|
|
1710
|
+
const first = await em.findOne(SignalWaiterEntity, where, {
|
|
1711
|
+
fields: [
|
|
1712
|
+
"token"
|
|
1713
|
+
]
|
|
1714
|
+
});
|
|
1715
|
+
if (!first) return false;
|
|
1716
|
+
if (first.token.startsWith(tokenPrefix)) return true;
|
|
1717
|
+
const rows = await em.find(SignalWaiterEntity, where, {
|
|
1718
|
+
fields: [
|
|
1719
|
+
"token"
|
|
1720
|
+
]
|
|
1721
|
+
});
|
|
1722
|
+
return rows.some((r) => r.token.startsWith(tokenPrefix));
|
|
1723
|
+
}
|
|
1643
1724
|
async removeSignalWaiter(waiter) {
|
|
1644
1725
|
const em = this.fork();
|
|
1645
1726
|
await em.nativeDelete(SignalWaiterEntity, {
|