@runplane/runplane-sdk 1.0.2 → 1.0.3

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.js CHANGED
@@ -73,15 +73,16 @@ var ApprovalPoller = class {
73
73
  try {
74
74
  const response = await this.fetchApprovalStatus(requestId);
75
75
  const elapsed = Date.now() - startTime;
76
+ const normalizedStatus = this.normalizeStatus(response);
76
77
  if (onPoll) {
77
- onPoll(response.status, elapsed);
78
+ onPoll(normalizedStatus, elapsed);
78
79
  }
79
- if (response.status !== "pending") {
80
+ if (normalizedStatus !== "pending") {
80
81
  return {
81
- approved: response.status === "approved",
82
- status: response.status,
83
- comment: response.comment,
84
- resolvedBy: response.resolvedBy
82
+ approved: normalizedStatus === "approved",
83
+ status: normalizedStatus,
84
+ comment: response.comment || response.reason,
85
+ resolvedBy: response.resolvedBy || response.approvedBy
85
86
  };
86
87
  }
87
88
  await this.sleep(interval);
@@ -104,7 +105,7 @@ var ApprovalPoller = class {
104
105
  `${this.baseUrl}/api/approvals/poll/${requestId}`,
105
106
  {
106
107
  headers: {
107
- "Authorization": `Bearer ${this.apiKey}`
108
+ Authorization: `Bearer ${this.apiKey}`
108
109
  }
109
110
  }
110
111
  );
@@ -113,6 +114,26 @@ var ApprovalPoller = class {
113
114
  }
114
115
  return response.json();
115
116
  }
117
+ /**
118
+ * Normalize server response → SDK canonical format
119
+ */
120
+ normalizeStatus(response) {
121
+ const raw = response.status || response.decision || response.decisionOutcome || "";
122
+ const normalized = String(raw).toLowerCase();
123
+ if (normalized === "approved" || normalized === "allow") {
124
+ return "approved";
125
+ }
126
+ if (normalized === "denied" || normalized === "deny" || normalized === "block") {
127
+ return "denied";
128
+ }
129
+ if (normalized === "pending") {
130
+ return "pending";
131
+ }
132
+ if (normalized === "expired") {
133
+ return "expired";
134
+ }
135
+ return "pending";
136
+ }
116
137
  sleep(ms) {
117
138
  return new Promise((resolve) => setTimeout(resolve, ms));
118
139
  }
package/dist/index.mjs CHANGED
@@ -46,15 +46,16 @@ var ApprovalPoller = class {
46
46
  try {
47
47
  const response = await this.fetchApprovalStatus(requestId);
48
48
  const elapsed = Date.now() - startTime;
49
+ const normalizedStatus = this.normalizeStatus(response);
49
50
  if (onPoll) {
50
- onPoll(response.status, elapsed);
51
+ onPoll(normalizedStatus, elapsed);
51
52
  }
52
- if (response.status !== "pending") {
53
+ if (normalizedStatus !== "pending") {
53
54
  return {
54
- approved: response.status === "approved",
55
- status: response.status,
56
- comment: response.comment,
57
- resolvedBy: response.resolvedBy
55
+ approved: normalizedStatus === "approved",
56
+ status: normalizedStatus,
57
+ comment: response.comment || response.reason,
58
+ resolvedBy: response.resolvedBy || response.approvedBy
58
59
  };
59
60
  }
60
61
  await this.sleep(interval);
@@ -77,7 +78,7 @@ var ApprovalPoller = class {
77
78
  `${this.baseUrl}/api/approvals/poll/${requestId}`,
78
79
  {
79
80
  headers: {
80
- "Authorization": `Bearer ${this.apiKey}`
81
+ Authorization: `Bearer ${this.apiKey}`
81
82
  }
82
83
  }
83
84
  );
@@ -86,6 +87,26 @@ var ApprovalPoller = class {
86
87
  }
87
88
  return response.json();
88
89
  }
90
+ /**
91
+ * Normalize server response → SDK canonical format
92
+ */
93
+ normalizeStatus(response) {
94
+ const raw = response.status || response.decision || response.decisionOutcome || "";
95
+ const normalized = String(raw).toLowerCase();
96
+ if (normalized === "approved" || normalized === "allow") {
97
+ return "approved";
98
+ }
99
+ if (normalized === "denied" || normalized === "deny" || normalized === "block") {
100
+ return "denied";
101
+ }
102
+ if (normalized === "pending") {
103
+ return "pending";
104
+ }
105
+ if (normalized === "expired") {
106
+ return "expired";
107
+ }
108
+ return "pending";
109
+ }
89
110
  sleep(ms) {
90
111
  return new Promise((resolve) => setTimeout(resolve, ms));
91
112
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@runplane/runplane-sdk",
3
- "version": "1.0.2",
3
+ "version": "1.0.3",
4
4
  "description": "Official SDK for the Runplane control plane - runtime governance for AI agent actions",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.mjs",
@@ -55,5 +55,3 @@
55
55
  "vitest": "^1.0.0"
56
56
  }
57
57
  }
58
-
59
-