@zapier/zapier-sdk 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
2
2
 
3
+ ## 0.16.1
4
+
5
+ ### Patch Changes
6
+
7
+ - 142c1ce: Fix CLI UX issues: stdout truncation when piped, nullable schema detection for Zod 4, error body display, and auto Content-Type for JSON bodies
8
+
3
9
  ## 0.16.0
4
10
 
5
11
  ### Minor Changes
package/dist/index.cjs CHANGED
@@ -2840,6 +2840,16 @@ var requestPlugin = ({ context }) => {
2840
2840
  headers[key] = value;
2841
2841
  }
2842
2842
  }
2843
+ const hasContentType = Object.keys(headers).some(
2844
+ (k) => k.toLowerCase() === "content-type"
2845
+ );
2846
+ if (body && !hasContentType) {
2847
+ const bodyStr = typeof body === "string" ? body : JSON.stringify(body);
2848
+ const trimmed = bodyStr.trimStart();
2849
+ if (trimmed.startsWith("{") || trimmed.startsWith("[")) {
2850
+ headers["Content-Type"] = "application/json; charset=utf-8";
2851
+ }
2852
+ }
2843
2853
  if (authenticationId) {
2844
2854
  headers["X-Relay-Authentication-Id"] = authenticationId.toString();
2845
2855
  }
@@ -5008,7 +5018,7 @@ function getCpuTime() {
5008
5018
 
5009
5019
  // package.json
5010
5020
  var package_default = {
5011
- version: "0.16.0"};
5021
+ version: "0.16.1"};
5012
5022
 
5013
5023
  // src/plugins/eventEmission/builders.ts
5014
5024
  function createBaseEvent(context = {}) {
package/dist/index.mjs CHANGED
@@ -2818,6 +2818,16 @@ var requestPlugin = ({ context }) => {
2818
2818
  headers[key] = value;
2819
2819
  }
2820
2820
  }
2821
+ const hasContentType = Object.keys(headers).some(
2822
+ (k) => k.toLowerCase() === "content-type"
2823
+ );
2824
+ if (body && !hasContentType) {
2825
+ const bodyStr = typeof body === "string" ? body : JSON.stringify(body);
2826
+ const trimmed = bodyStr.trimStart();
2827
+ if (trimmed.startsWith("{") || trimmed.startsWith("[")) {
2828
+ headers["Content-Type"] = "application/json; charset=utf-8";
2829
+ }
2830
+ }
2821
2831
  if (authenticationId) {
2822
2832
  headers["X-Relay-Authentication-Id"] = authenticationId.toString();
2823
2833
  }
@@ -4986,7 +4996,7 @@ function getCpuTime() {
4986
4996
 
4987
4997
  // package.json
4988
4998
  var package_default = {
4989
- version: "0.16.0"};
4999
+ version: "0.16.1"};
4990
5000
 
4991
5001
  // src/plugins/eventEmission/builders.ts
4992
5002
  function createBaseEvent(context = {}) {
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/plugins/request/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AACjD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AAC3C,OAAO,EAAE,kBAAkB,EAAE,KAAK,mBAAmB,EAAE,MAAM,WAAW,CAAC;AAEzE,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,kBAAkB,CAAC;AAmB7D,MAAM,WAAW,qBAAqB;IACpC,OAAO,EAAE,CAAC,OAAO,EAAE,mBAAmB,KAAK,OAAO,CAAC,QAAQ,CAAC,CAAC;IAC7D,OAAO,EAAE;QACP,IAAI,EAAE;YACJ,OAAO,EAAE;gBACP,WAAW,EAAE,OAAO,kBAAkB,CAAC;aACxC,CAAC;SACH,CAAC;KACH,CAAC;CACH;AAED,eAAO,MAAM,aAAa,EAAE,MAAM,CAChC,EAAE,EAAE,sBAAsB;AAC1B,AADI,sBAAsB;AAC1B;IAAE,GAAG,EAAE,SAAS,CAAA;CAAE,GAAG,oBAAoB,EAAE,0BAA0B;AACrE,qBAAqB,CA4EtB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/plugins/request/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AACjD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AAC3C,OAAO,EAAE,kBAAkB,EAAE,KAAK,mBAAmB,EAAE,MAAM,WAAW,CAAC;AAEzE,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,kBAAkB,CAAC;AAmB7D,MAAM,WAAW,qBAAqB;IACpC,OAAO,EAAE,CAAC,OAAO,EAAE,mBAAmB,KAAK,OAAO,CAAC,QAAQ,CAAC,CAAC;IAC7D,OAAO,EAAE;QACP,IAAI,EAAE;YACJ,OAAO,EAAE;gBACP,WAAW,EAAE,OAAO,kBAAkB,CAAC;aACxC,CAAC;SACH,CAAC;KACH,CAAC;CACH;AAED,eAAO,MAAM,aAAa,EAAE,MAAM,CAChC,EAAE,EAAE,sBAAsB;AAC1B,AADI,sBAAsB;AAC1B;IAAE,GAAG,EAAE,SAAS,CAAA;CAAE,GAAG,oBAAoB,EAAE,0BAA0B;AACrE,qBAAqB,CAwFtB,CAAC"}
@@ -33,6 +33,15 @@ export const requestPlugin = ({ context }) => {
33
33
  headers[key] = value;
34
34
  }
35
35
  }
36
+ // Auto-set Content-Type for JSON bodies if not already specified
37
+ const hasContentType = Object.keys(headers).some((k) => k.toLowerCase() === "content-type");
38
+ if (body && !hasContentType) {
39
+ const bodyStr = typeof body === "string" ? body : JSON.stringify(body);
40
+ const trimmed = bodyStr.trimStart();
41
+ if (trimmed.startsWith("{") || trimmed.startsWith("[")) {
42
+ headers["Content-Type"] = "application/json; charset=utf-8";
43
+ }
44
+ }
36
45
  // Add Relay-specific headers
37
46
  if (authenticationId) {
38
47
  headers["X-Relay-Authentication-Id"] = authenticationId.toString();
@@ -230,6 +230,73 @@ describe("request plugin", () => {
230
230
  method: "POST",
231
231
  body,
232
232
  });
233
+ expect(mockFetch).toHaveBeenCalledWith("/relay/api.example.com/data", {
234
+ method: "POST",
235
+ body,
236
+ headers: {
237
+ "Content-Type": "application/json; charset=utf-8",
238
+ },
239
+ });
240
+ });
241
+ it("should auto-set Content-Type for JSON object bodies", async () => {
242
+ const sdk = createTestSdk();
243
+ const body = '{"key": "value"}';
244
+ await sdk.request({
245
+ url: "https://api.example.com/data",
246
+ method: "POST",
247
+ body,
248
+ });
249
+ expect(mockFetch).toHaveBeenCalledWith("/relay/api.example.com/data", {
250
+ method: "POST",
251
+ body,
252
+ headers: {
253
+ "Content-Type": "application/json; charset=utf-8",
254
+ },
255
+ });
256
+ });
257
+ it("should auto-set Content-Type for JSON array bodies", async () => {
258
+ const sdk = createTestSdk();
259
+ const body = '[{"id": 1}, {"id": 2}]';
260
+ await sdk.request({
261
+ url: "https://api.example.com/data",
262
+ method: "POST",
263
+ body,
264
+ });
265
+ expect(mockFetch).toHaveBeenCalledWith("/relay/api.example.com/data", {
266
+ method: "POST",
267
+ body,
268
+ headers: {
269
+ "Content-Type": "application/json; charset=utf-8",
270
+ },
271
+ });
272
+ });
273
+ it("should not override explicit Content-Type header", async () => {
274
+ const sdk = createTestSdk();
275
+ const body = '{"key": "value"}';
276
+ await sdk.request({
277
+ url: "https://api.example.com/data",
278
+ method: "POST",
279
+ body,
280
+ headers: {
281
+ "Content-Type": "text/plain",
282
+ },
283
+ });
284
+ expect(mockFetch).toHaveBeenCalledWith("/relay/api.example.com/data", {
285
+ method: "POST",
286
+ body,
287
+ headers: {
288
+ "Content-Type": "text/plain",
289
+ },
290
+ });
291
+ });
292
+ it("should not set Content-Type for non-JSON bodies", async () => {
293
+ const sdk = createTestSdk();
294
+ const body = "plain text body";
295
+ await sdk.request({
296
+ url: "https://api.example.com/data",
297
+ method: "POST",
298
+ body,
299
+ });
233
300
  expect(mockFetch).toHaveBeenCalledWith("/relay/api.example.com/data", {
234
301
  method: "POST",
235
302
  body,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zapier/zapier-sdk",
3
- "version": "0.16.0",
3
+ "version": "0.16.1",
4
4
  "description": "Complete Zapier SDK - combines all Zapier SDK packages",
5
5
  "main": "dist/index.cjs",
6
6
  "module": "dist/index.mjs",
@@ -51,7 +51,7 @@
51
51
  "tsup": "^8.5.0",
52
52
  "typescript": "^5.8.3",
53
53
  "vitest": "^3.2.3",
54
- "@zapier/zapier-sdk-cli-login": "0.3.5"
54
+ "@zapier/zapier-sdk-cli-login": "0.3.6"
55
55
  },
56
56
  "scripts": {
57
57
  "build": "tsup",