@cadraos/sdk 0.3.12 → 0.3.13

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.
@@ -223,6 +223,8 @@ var WebhookDeliveryError = class extends Error {
223
223
  this.retryable = retryable;
224
224
  this.name = "WebhookDeliveryError";
225
225
  }
226
+ status;
227
+ retryable;
226
228
  };
227
229
  async function hmacSign(secret, payload) {
228
230
  const enc = new TextEncoder();
@@ -695,6 +697,10 @@ var HttpAdapterError = class extends Error {
695
697
  this.body = body;
696
698
  this.name = "HttpAdapterError";
697
699
  }
700
+ status;
701
+ method;
702
+ path;
703
+ body;
698
704
  code = "http_adapter_error";
699
705
  };
700
706
  var CapabilitiesNotLoadedError = class extends Error {
@@ -1715,6 +1721,13 @@ function createEngine(options) {
1715
1721
  dispatched: result.dispatched
1716
1722
  };
1717
1723
  }
1724
+ async function dispatchOnEntry(cardId, laneKey, cfg) {
1725
+ const stage = laneByKey(cfg, laneKey);
1726
+ if (hasAutomatedHandler(stage) && dispatchesOnEntry(stage)) {
1727
+ return runStage(cardId, laneKey);
1728
+ }
1729
+ return { dispatched: false };
1730
+ }
1718
1731
  async function transition(cardId, toLane, actor = { type: "user" }) {
1719
1732
  const card = await adapter.getCard(cardId);
1720
1733
  if (!card) throw new Error(`Card not found: ${cardId}`);
@@ -1726,10 +1739,7 @@ function createEngine(options) {
1726
1739
  transitionId: edge.id,
1727
1740
  actor
1728
1741
  });
1729
- const newStage = laneByKey(cfg, moved.lane);
1730
- if (hasAutomatedHandler(newStage) && dispatchesOnEntry(newStage)) {
1731
- await runStage(cardId, moved.lane);
1732
- }
1742
+ await dispatchOnEntry(cardId, moved.lane, cfg);
1733
1743
  return moved;
1734
1744
  }
1735
1745
  async function createCard(boardConfigUuid, input) {
@@ -1745,10 +1755,7 @@ function createEngine(options) {
1745
1755
  initialLane
1746
1756
  });
1747
1757
  pinnedVersions.set(card.id, cfg.version);
1748
- const initialStage = laneByKey(cfg, initialLane);
1749
- if (hasAutomatedHandler(initialStage) && dispatchesOnEntry(initialStage)) {
1750
- await runStage(card.id, initialLane);
1751
- }
1758
+ await dispatchOnEntry(card.id, initialLane, cfg);
1752
1759
  return await adapter.getCard(card.id) ?? card;
1753
1760
  }
1754
1761
  async function onStageComplete(idemKey, completion) {
@@ -1766,6 +1773,21 @@ function createEngine(options) {
1766
1773
  contextPatch: completion.contextPatch,
1767
1774
  actor: completion.actor ?? systemActor
1768
1775
  });
1776
+ if (applied.applied && autoEdge?.toLane) {
1777
+ try {
1778
+ await dispatchOnEntry(cardId, autoEdge.toLane, cfg);
1779
+ } catch (entryErr) {
1780
+ console.error(
1781
+ "[kanban engine] entry-dispatch after auto-advance failed \u2014",
1782
+ "cardId=",
1783
+ cardId,
1784
+ "toLane=",
1785
+ autoEdge.toLane,
1786
+ "error=",
1787
+ entryErr instanceof Error ? entryErr.message : String(entryErr)
1788
+ );
1789
+ }
1790
+ }
1769
1791
  return applied;
1770
1792
  }
1771
1793
  async function onBatchComplete(batchKey, completion) {