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