@zapier/zapier-sdk-cli 0.16.0 → 0.16.1

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/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # @zapier/zapier-sdk-cli
2
2
 
3
+ ## 0.16.1
4
+
5
+ ### Patch Changes
6
+
7
+ - e80d094: Fix CLI to extract JSON body from Response objects instead of showing raw Response representation. Adds error handling for invalid JSON responses with helpful error messages.
8
+
3
9
  ## 0.16.0
4
10
 
5
11
  ### Minor Changes
package/dist/cli.cjs CHANGED
@@ -1077,7 +1077,24 @@ function createCommandConfig(cliCommandName, functionInfo, sdk2) {
1077
1077
  return;
1078
1078
  }
1079
1079
  const sdkObj = sdk2;
1080
- const result = await sdkObj[functionInfo.name](resolvedParams);
1080
+ let result = await sdkObj[functionInfo.name](resolvedParams);
1081
+ if (result instanceof Response) {
1082
+ const response = result;
1083
+ let body;
1084
+ try {
1085
+ body = await response.json();
1086
+ } catch {
1087
+ const text = response.bodyUsed ? "[body already consumed]" : await response.text().catch(() => "[unable to read body]");
1088
+ throw new Error(
1089
+ `Failed to parse response as JSON (status: ${response.status}). Body: ${text.slice(0, 200)}`
1090
+ );
1091
+ }
1092
+ result = {
1093
+ statusCode: response.status,
1094
+ headers: Object.fromEntries(response.headers.entries()),
1095
+ body
1096
+ };
1097
+ }
1081
1098
  const items = result?.data ? result.data : result;
1082
1099
  if (shouldUseJson) {
1083
1100
  console.log(JSON.stringify(items, null, 2));
@@ -1628,7 +1645,7 @@ var LoginSchema = zod.z.object({
1628
1645
 
1629
1646
  // package.json
1630
1647
  var package_default = {
1631
- version: "0.16.0"};
1648
+ version: "0.16.1"};
1632
1649
 
1633
1650
  // src/telemetry/builders.ts
1634
1651
  function createCliBaseEvent(context = {}) {
@@ -2907,7 +2924,7 @@ function createZapierCliSdk(options = {}) {
2907
2924
  // package.json with { type: 'json' }
2908
2925
  var package_default2 = {
2909
2926
  name: "@zapier/zapier-sdk-cli",
2910
- version: "0.16.0"};
2927
+ version: "0.16.1"};
2911
2928
  function detectPackageManager(cwd = process.cwd()) {
2912
2929
  const ua = process.env.npm_config_user_agent;
2913
2930
  if (ua) {
package/dist/cli.mjs CHANGED
@@ -1041,7 +1041,24 @@ function createCommandConfig(cliCommandName, functionInfo, sdk2) {
1041
1041
  return;
1042
1042
  }
1043
1043
  const sdkObj = sdk2;
1044
- const result = await sdkObj[functionInfo.name](resolvedParams);
1044
+ let result = await sdkObj[functionInfo.name](resolvedParams);
1045
+ if (result instanceof Response) {
1046
+ const response = result;
1047
+ let body;
1048
+ try {
1049
+ body = await response.json();
1050
+ } catch {
1051
+ const text = response.bodyUsed ? "[body already consumed]" : await response.text().catch(() => "[unable to read body]");
1052
+ throw new Error(
1053
+ `Failed to parse response as JSON (status: ${response.status}). Body: ${text.slice(0, 200)}`
1054
+ );
1055
+ }
1056
+ result = {
1057
+ statusCode: response.status,
1058
+ headers: Object.fromEntries(response.headers.entries()),
1059
+ body
1060
+ };
1061
+ }
1045
1062
  const items = result?.data ? result.data : result;
1046
1063
  if (shouldUseJson) {
1047
1064
  console.log(JSON.stringify(items, null, 2));
@@ -1592,7 +1609,7 @@ var LoginSchema = z.object({
1592
1609
 
1593
1610
  // package.json
1594
1611
  var package_default = {
1595
- version: "0.16.0"};
1612
+ version: "0.16.1"};
1596
1613
 
1597
1614
  // src/telemetry/builders.ts
1598
1615
  function createCliBaseEvent(context = {}) {
@@ -2871,7 +2888,7 @@ function createZapierCliSdk(options = {}) {
2871
2888
  // package.json with { type: 'json' }
2872
2889
  var package_default2 = {
2873
2890
  name: "@zapier/zapier-sdk-cli",
2874
- version: "0.16.0"};
2891
+ version: "0.16.1"};
2875
2892
  function detectPackageManager(cwd = process.cwd()) {
2876
2893
  const ua = process.env.npm_config_user_agent;
2877
2894
  if (ua) {
package/dist/index.cjs CHANGED
@@ -291,7 +291,7 @@ var LoginSchema = zod.z.object({
291
291
 
292
292
  // package.json
293
293
  var package_default = {
294
- version: "0.16.0"};
294
+ version: "0.16.1"};
295
295
 
296
296
  // src/telemetry/builders.ts
297
297
  function createCliBaseEvent(context = {}) {
package/dist/index.mjs CHANGED
@@ -260,7 +260,7 @@ var LoginSchema = z.object({
260
260
 
261
261
  // package.json
262
262
  var package_default = {
263
- version: "0.16.0"};
263
+ version: "0.16.1"};
264
264
 
265
265
  // src/telemetry/builders.ts
266
266
  function createCliBaseEvent(context = {}) {
package/dist/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zapier/zapier-sdk-cli",
3
- "version": "0.16.0",
3
+ "version": "0.16.1",
4
4
  "description": "Command line interface for Zapier SDK",
5
5
  "main": "dist/index.cjs",
6
6
  "module": "dist/index.mjs",
@@ -226,7 +226,27 @@ function createCommandConfig(cliCommandName, functionInfo, sdk) {
226
226
  }
227
227
  // Call the SDK method and handle non-paginated results
228
228
  const sdkObj = sdk;
229
- const result = await sdkObj[functionInfo.name](resolvedParams);
229
+ let result = await sdkObj[functionInfo.name](resolvedParams);
230
+ // Handle Response objects by wrapping in a structured envelope
231
+ if (result instanceof Response) {
232
+ const response = result;
233
+ let body;
234
+ try {
235
+ body = await response.json();
236
+ }
237
+ catch {
238
+ // If JSON parsing fails, try to get text for error context
239
+ const text = response.bodyUsed
240
+ ? "[body already consumed]"
241
+ : await response.text().catch(() => "[unable to read body]");
242
+ throw new Error(`Failed to parse response as JSON (status: ${response.status}). Body: ${text.slice(0, 200)}`);
243
+ }
244
+ result = {
245
+ statusCode: response.status,
246
+ headers: Object.fromEntries(response.headers.entries()),
247
+ body,
248
+ };
249
+ }
230
250
  const items = result?.data
231
251
  ? result.data
232
252
  : result;