@happyrobot-ai/sdk 0.1.9 → 0.1.10

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.
@@ -2,9 +2,20 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.triggerAndWaitForNodeOutput = triggerAndWaitForNodeOutput;
4
4
  const errors_1 = require("../core/errors");
5
- const node_output_1 = require("@/shared/constants/node-output");
6
- const RUN_TERMINAL_STATUS_SET = new Set(node_output_1.RUN_TERMINAL_STATUSES);
7
- const NODE_READY_STATUS_SET = new Set(node_output_1.NODE_READY_STATUSES);
5
+ const RUN_TERMINAL_STATUSES = new Set([
6
+ "completed",
7
+ "succeeded",
8
+ "failed",
9
+ "canceled",
10
+ "skipped",
11
+ ]);
12
+ const NODE_READY_STATUSES = new Set([
13
+ "completed",
14
+ "succeeded",
15
+ "failed",
16
+ "canceled",
17
+ "skipped",
18
+ ]);
8
19
  async function triggerAndWaitForNodeOutput(client, options) {
9
20
  const { workflowId, payload, environment = "production", nodePersistentId, timeoutMs = 300_000, pollIntervalMs = 2_000, } = options;
10
21
  const triggerResponse = await client.workflows.triggerRun(workflowId, {
@@ -31,7 +42,7 @@ async function triggerAndWaitForNodeOutput(client, options) {
31
42
  });
32
43
  const matchingNodes = nodes.data.filter((item) => item.node_persistent_id === nodePersistentId);
33
44
  const node = pickLatestNodeExecution(matchingNodes);
34
- if (node?.output_id && node.status && NODE_READY_STATUS_SET.has(node.status)) {
45
+ if (node?.output_id && node.status && NODE_READY_STATUSES.has(node.status)) {
35
46
  const output = await client.runs.getOutput(run_id, node.output_id);
36
47
  return {
37
48
  ok: true,
@@ -46,7 +57,7 @@ async function triggerAndWaitForNodeOutput(client, options) {
46
57
  const run = await client.runs.get(run_id);
47
58
  lastRunStatus = run.status;
48
59
  lastRunCompletedAt = run.completed_at;
49
- if (RUN_TERMINAL_STATUS_SET.has(run.status)) {
60
+ if (RUN_TERMINAL_STATUSES.has(run.status)) {
50
61
  const finalNodes = await client.runs.listNodes(run_id, {
51
62
  node_persistent_id: nodePersistentId,
52
63
  sort: "asc",
@@ -55,7 +66,7 @@ async function triggerAndWaitForNodeOutput(client, options) {
55
66
  const finalNode = pickLatestNodeExecution(finalMatchingNodes);
56
67
  if (finalNode?.output_id &&
57
68
  finalNode.status &&
58
- NODE_READY_STATUS_SET.has(finalNode.status)) {
69
+ NODE_READY_STATUSES.has(finalNode.status)) {
59
70
  const output = await client.runs.getOutput(run_id, finalNode.output_id);
60
71
  return {
61
72
  ok: true,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@happyrobot-ai/sdk",
3
- "version": "0.1.9",
3
+ "version": "0.1.10",
4
4
  "description": "TypeScript SDK for the HappyRobot Public API",
5
5
  "main": "./index.js",
6
6
  "module": "./index.mjs",