@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 +6 -0
- package/dist/cli.cjs +20 -3
- package/dist/cli.mjs +20 -3
- package/dist/index.cjs +1 -1
- package/dist/index.mjs +1 -1
- package/dist/package.json +1 -1
- package/dist/src/utils/cli-generator.js +21 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +2 -2
- package/src/utils/cli-generator.test.ts +152 -0
- package/src/utils/cli-generator.ts +24 -1
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
|
-
|
|
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.
|
|
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.
|
|
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
|
-
|
|
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.
|
|
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.
|
|
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
package/dist/index.mjs
CHANGED
package/dist/package.json
CHANGED
|
@@ -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
|
-
|
|
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;
|