@dudousxd/nestjs-durable 0.46.2 → 0.47.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 CHANGED
@@ -1158,10 +1158,19 @@ var ProxyRunGateway = class {
1158
1158
  tenant: this.tenant
1159
1159
  };
1160
1160
  }
1161
- getRunDetail(runId) {
1161
+ getRunDetail(runId, options) {
1162
1162
  return this.request({
1163
1163
  kind: "getRunDetail",
1164
- runId
1164
+ runId,
1165
+ options
1166
+ });
1167
+ }
1168
+ getFanMembers(runId, group, query) {
1169
+ return this.request({
1170
+ kind: "getFanMembers",
1171
+ runId,
1172
+ group,
1173
+ query
1165
1174
  });
1166
1175
  }
1167
1176
  /** The control plane's `StoreRunGateway` resolves each run's `waiting` descriptor; the reply carries
@@ -1523,8 +1532,8 @@ var RunRequestResponder = class {
1523
1532
  if (body.kind === "waitingFor") {
1524
1533
  const all = await this.gateway.waitingFor(body.runIds);
1525
1534
  const owned = await Promise.all(Object.entries(all).map(async ([runId, waiting]) => {
1526
- const runDetail = await this.gateway.getRunDetail(runId);
1527
- return runDetail && runDetail.run.namespace === msg.tenant ? [
1535
+ const owner = this.gateway.getRun ? await this.gateway.getRun(runId) : (await this.gateway.getRunDetail(runId))?.run;
1536
+ return owner && owner.namespace === msg.tenant ? [
1528
1537
  runId,
1529
1538
  waiting
1530
1539
  ] : void 0;
@@ -1541,8 +1550,9 @@ var RunRequestResponder = class {
1541
1550
  }
1542
1551
  };
1543
1552
  }
1544
- const detail = await this.gateway.getRunDetail(body.runId);
1545
- if (detail && detail.run.namespace !== msg.tenant) {
1553
+ const detail = body.kind === "getRunDetail" || !this.gateway.getRun ? await this.gateway.getRunDetail(body.runId, body.kind === "getRunDetail" ? body.options : void 0) : void 0;
1554
+ const run = detail !== void 0 ? detail?.run ?? null : await this.gateway.getRun?.(body.runId);
1555
+ if (run && run.namespace !== msg.tenant) {
1546
1556
  return {
1547
1557
  requestId: msg.requestId,
1548
1558
  result: {
@@ -1563,6 +1573,16 @@ var RunRequestResponder = class {
1563
1573
  }
1564
1574
  };
1565
1575
  }
1576
+ if (body.kind === "getFanMembers") {
1577
+ const data = run ? await this.gateway.getFanMembers?.(body.runId, body.group, body.query) ?? null : null;
1578
+ return {
1579
+ requestId: msg.requestId,
1580
+ result: {
1581
+ ok: true,
1582
+ data
1583
+ }
1584
+ };
1585
+ }
1566
1586
  try {
1567
1587
  const data = await this.callVerb(body);
1568
1588
  return {
@@ -1644,19 +1664,39 @@ var StoreRunGateway = class {
1644
1664
  role: "control-plane"
1645
1665
  };
1646
1666
  }
1647
- async getRunDetail(runId) {
1667
+ async getRunDetail(runId, options) {
1648
1668
  const run = await this.store.getRun(runId);
1649
1669
  if (!run) return null;
1650
- const [timeline, children] = await Promise.all([
1651
- this.store.listCheckpoints(runId),
1652
- this.engine.getRunChildren(runId)
1653
- ]);
1670
+ const over = options?.summarizeFansOver;
1671
+ if (over === void 0) {
1672
+ const [timeline2, children] = await Promise.all([
1673
+ this.store.listCheckpoints(runId),
1674
+ this.engine.getRunChildren(runId)
1675
+ ]);
1676
+ return {
1677
+ run,
1678
+ timeline: timeline2,
1679
+ children
1680
+ };
1681
+ }
1682
+ const full = await this.store.listCheckpoints(runId);
1683
+ const { timeline, fans } = (0, import_nestjs_durable_core9.summarizeTimeline)(full, over);
1684
+ const ids = (0, import_nestjs_durable_core9.childIdsOf)(full);
1654
1685
  return {
1655
1686
  run,
1656
1687
  timeline,
1657
- children
1688
+ children: ids.slice(0, import_nestjs_durable_core9.SUMMARY_CHILD_LIMIT),
1689
+ fans,
1690
+ childCount: ids.length
1658
1691
  };
1659
1692
  }
1693
+ getRun(runId) {
1694
+ return this.store.getRun(runId);
1695
+ }
1696
+ async getFanMembers(runId, group, query) {
1697
+ if (!await this.store.getRun(runId)) return null;
1698
+ return (0, import_nestjs_durable_core9.pageFan)(await this.store.listCheckpoints(runId), group, query);
1699
+ }
1660
1700
  async listRuns(query) {
1661
1701
  const runs = await this.store.listRuns(query);
1662
1702
  const waiterByRun = (0, import_nestjs_durable_core9.indexWaitersByRun)(await (0, import_nestjs_durable_core9.listSignalWaitersOfRuns)(this.store, runs.filter((run) => run.status === "suspended").map((run) => run.id)));