@zapier/connectors-sdk 0.1.0-experimental.3 → 0.1.0-experimental.4

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.cjs CHANGED
@@ -926,7 +926,7 @@ async function handleIfScriptMainBody(wrappedScript, connectionResolvers, io) {
926
926
  );
927
927
  return;
928
928
  }
929
- const raw = positional ?? await new Response(io.stdin).text();
929
+ const raw = positional ?? await readStdinInput(io.stdin, wrappedScript.name);
930
930
  if (raw.trim().length === 0) {
931
931
  throw new Error(
932
932
  `Missing JSON input for "${wrappedScript.name}". Pass it as a positional argument or via stdin.`
@@ -938,6 +938,14 @@ async function handleIfScriptMainBody(wrappedScript, connectionResolvers, io) {
938
938
  const result = await wrappedScript.run(input, runOpts);
939
939
  io.stdout.write(JSON.stringify(result, null, 2) + "\n");
940
940
  }
941
+ async function readStdinInput(stdin, scriptName) {
942
+ if (stdin.isTTY) {
943
+ throw new Error(
944
+ `Missing JSON input for "${scriptName}". Pass it as a positional argument or pipe it via stdin.`
945
+ );
946
+ }
947
+ return new Response(stdin).text();
948
+ }
941
949
  function buildHelpText(definition, connectionResolvers, opts = {}) {
942
950
  const lines = [];
943
951
  const description = definition.description.split("\n")[0]?.trim() ?? "";
package/dist/index.js CHANGED
@@ -821,7 +821,7 @@ async function handleIfScriptMainBody(wrappedScript, connectionResolvers, io) {
821
821
  );
822
822
  return;
823
823
  }
824
- const raw = positional ?? await new Response(io.stdin).text();
824
+ const raw = positional ?? await readStdinInput(io.stdin, wrappedScript.name);
825
825
  if (raw.trim().length === 0) {
826
826
  throw new Error(
827
827
  `Missing JSON input for "${wrappedScript.name}". Pass it as a positional argument or via stdin.`
@@ -833,6 +833,14 @@ async function handleIfScriptMainBody(wrappedScript, connectionResolvers, io) {
833
833
  const result = await wrappedScript.run(input, runOpts);
834
834
  io.stdout.write(JSON.stringify(result, null, 2) + "\n");
835
835
  }
836
+ async function readStdinInput(stdin, scriptName) {
837
+ if (stdin.isTTY) {
838
+ throw new Error(
839
+ `Missing JSON input for "${scriptName}". Pass it as a positional argument or pipe it via stdin.`
840
+ );
841
+ }
842
+ return new Response(stdin).text();
843
+ }
836
844
  function buildHelpText(definition, connectionResolvers, opts = {}) {
837
845
  const lines = [];
838
846
  const description = definition.description.split("\n")[0]?.trim() ?? "";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zapier/connectors-sdk",
3
- "version": "0.1.0-experimental.3",
3
+ "version": "0.1.0-experimental.4",
4
4
  "description": "SDK for building Zapier connectors. Provides the authoring primitives and execution surfaces for connector scripts.",
5
5
  "license": "Elastic-2.0",
6
6
  "type": "module",