@zapier/zapier-sdk-cli 0.44.1 → 0.45.0
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 +12 -0
- package/README.md +381 -29
- package/bin/zapier-sdk-experimental.mjs +14 -0
- package/dist/cli.cjs +585 -37
- package/dist/cli.mjs +584 -36
- package/dist/experimental.cjs +3519 -0
- package/dist/experimental.d.mts +39 -0
- package/dist/experimental.d.ts +39 -0
- package/dist/experimental.mjs +3483 -0
- package/dist/index.cjs +507 -26
- package/dist/index.d.mts +3 -514
- package/dist/index.d.ts +3 -514
- package/dist/index.mjs +505 -24
- package/dist/package.json +14 -2
- package/dist/sdk-B3nKAZdN.d.mts +516 -0
- package/dist/sdk-B3nKAZdN.d.ts +516 -0
- package/dist/src/cli.js +26 -2
- package/dist/src/experimental.d.ts +33 -0
- package/dist/src/experimental.js +83 -0
- package/dist/src/generators/ast-generator.d.ts +2 -2
- package/dist/src/generators/ast-generator.js +1 -1
- package/dist/src/plugins/add/index.d.ts +2 -2
- package/dist/src/plugins/bundleCode/index.js +3 -12
- package/dist/src/plugins/curl/index.js +2 -2
- package/dist/src/plugins/curl/utils.d.ts +11 -1
- package/dist/src/plugins/curl/utils.js +14 -5
- package/dist/src/plugins/drainTriggerInbox/index.d.ts +46 -0
- package/dist/src/plugins/drainTriggerInbox/index.js +178 -0
- package/dist/src/plugins/generateAppTypes/index.d.ts +2 -2
- package/dist/src/plugins/index.d.ts +2 -0
- package/dist/src/plugins/index.js +2 -0
- package/dist/src/plugins/mcp/index.d.ts +1 -0
- package/dist/src/plugins/mcp/index.js +5 -1
- package/dist/src/plugins/watchTriggerInbox/index.d.ts +45 -0
- package/dist/src/plugins/watchTriggerInbox/index.js +157 -0
- package/dist/src/sdk.js +5 -1
- package/dist/src/utils/cli-generator.js +18 -1
- package/dist/src/utils/cli-renderer.d.ts +12 -0
- package/dist/src/utils/cli-renderer.js +22 -1
- package/dist/src/utils/parameter-resolver.d.ts +1 -0
- package/dist/src/utils/parameter-resolver.js +55 -9
- package/dist/src/utils/triggerDrain.d.ts +144 -0
- package/dist/src/utils/triggerDrain.js +351 -0
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +16 -4
package/dist/index.cjs
CHANGED
|
@@ -23,6 +23,7 @@ require('is-installed-globally');
|
|
|
23
23
|
var child_process = require('child_process');
|
|
24
24
|
var Handlebars = require('handlebars');
|
|
25
25
|
var url = require('url');
|
|
26
|
+
require('wrap-ansi');
|
|
26
27
|
|
|
27
28
|
var _documentCurrentScript = typeof document !== 'undefined' ? document.currentScript : null;
|
|
28
29
|
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
@@ -660,6 +661,14 @@ var ZapierCliExitError = class extends ZapierCliError {
|
|
|
660
661
|
this.exitCode = exitCode;
|
|
661
662
|
}
|
|
662
663
|
};
|
|
664
|
+
var ZapierCliValidationError = class extends ZapierCliError {
|
|
665
|
+
constructor(message) {
|
|
666
|
+
super(message);
|
|
667
|
+
this.name = "ZapierCliValidationError";
|
|
668
|
+
this.code = "ZAPIER_CLI_VALIDATION_ERROR";
|
|
669
|
+
this.exitCode = 1;
|
|
670
|
+
}
|
|
671
|
+
};
|
|
663
672
|
|
|
664
673
|
// src/utils/spinner.ts
|
|
665
674
|
var spinPromise = async (promise, text) => {
|
|
@@ -996,7 +1005,8 @@ var mcpPlugin = zapierSdk.definePlugin(
|
|
|
996
1005
|
await zapierSdkMcp.startMcpServer({
|
|
997
1006
|
...options,
|
|
998
1007
|
debug: sdk2.context.options?.debug,
|
|
999
|
-
extensions: sdk2.context.extensions
|
|
1008
|
+
extensions: sdk2.context.extensions,
|
|
1009
|
+
experimental: sdk2.context.experimental
|
|
1000
1010
|
});
|
|
1001
1011
|
}
|
|
1002
1012
|
})
|
|
@@ -1019,15 +1029,6 @@ var bundleCodePlugin = zapierSdk.definePlugin(
|
|
|
1019
1029
|
handler: async ({ options }) => bundleCode(options)
|
|
1020
1030
|
})
|
|
1021
1031
|
);
|
|
1022
|
-
var ZapierBundleError = class extends Error {
|
|
1023
|
-
constructor(message, details, originalError) {
|
|
1024
|
-
super(message);
|
|
1025
|
-
this.code = "ZAPIER_BUNDLE_ERROR";
|
|
1026
|
-
this.name = "ZapierBundleError";
|
|
1027
|
-
this.details = details;
|
|
1028
|
-
this.originalError = originalError;
|
|
1029
|
-
}
|
|
1030
|
-
};
|
|
1031
1032
|
async function bundleCode(options) {
|
|
1032
1033
|
const {
|
|
1033
1034
|
input,
|
|
@@ -1055,14 +1056,14 @@ async function bundleCode(options) {
|
|
|
1055
1056
|
});
|
|
1056
1057
|
if (result.errors.length > 0) {
|
|
1057
1058
|
const errorMessages = result.errors.map((e) => e.text);
|
|
1058
|
-
throw new ZapierBundleError(
|
|
1059
|
+
throw new zapierSdk.ZapierBundleError(
|
|
1059
1060
|
`Bundle failed: ${errorMessages.join(", ")}`,
|
|
1060
|
-
errorMessages
|
|
1061
|
+
{ buildErrors: errorMessages }
|
|
1061
1062
|
);
|
|
1062
1063
|
}
|
|
1063
1064
|
const bundledCode = result.outputFiles?.[0]?.text;
|
|
1064
1065
|
if (!bundledCode) {
|
|
1065
|
-
throw new ZapierBundleError("No output generated");
|
|
1066
|
+
throw new zapierSdk.ZapierBundleError("No output generated");
|
|
1066
1067
|
}
|
|
1067
1068
|
let finalOutput = bundledCode;
|
|
1068
1069
|
if (returnString) {
|
|
@@ -1074,13 +1075,12 @@ async function bundleCode(options) {
|
|
|
1074
1075
|
}
|
|
1075
1076
|
return finalOutput;
|
|
1076
1077
|
} catch (error) {
|
|
1077
|
-
if (error instanceof ZapierBundleError) {
|
|
1078
|
+
if (error instanceof zapierSdk.ZapierBundleError) {
|
|
1078
1079
|
throw error;
|
|
1079
1080
|
}
|
|
1080
|
-
throw new ZapierBundleError(
|
|
1081
|
+
throw new zapierSdk.ZapierBundleError(
|
|
1081
1082
|
`Bundle failed: ${error instanceof Error ? error.message : "Unknown error"}`,
|
|
1082
|
-
void 0
|
|
1083
|
-
error instanceof Error ? error : void 0
|
|
1083
|
+
{ cause: error instanceof Error ? error : void 0 }
|
|
1084
1084
|
);
|
|
1085
1085
|
}
|
|
1086
1086
|
}
|
|
@@ -1255,7 +1255,7 @@ var AstTypeGenerator = class {
|
|
|
1255
1255
|
const actions = actionsResult.data;
|
|
1256
1256
|
const actionsWithFields = [];
|
|
1257
1257
|
const inputFieldsTasks = actions.map(
|
|
1258
|
-
(action) => () => sdk.
|
|
1258
|
+
(action) => () => sdk.listActionInputFields({
|
|
1259
1259
|
appKey: app.implementation_id,
|
|
1260
1260
|
actionKey: action.key,
|
|
1261
1261
|
actionType: action.action_type,
|
|
@@ -2132,11 +2132,12 @@ var CurlSchema = zod.z.object({
|
|
|
2132
2132
|
/** @deprecated Use `connection` instead. */
|
|
2133
2133
|
connectionId: zod.z.union([zod.z.string(), zod.z.number()]).optional().meta({ deprecated: true })
|
|
2134
2134
|
}).describe("Make HTTP requests through Zapier Relay with curl-like options");
|
|
2135
|
-
var
|
|
2135
|
+
var ZapierCurlExitError = class extends zapierSdk.ZapierError {
|
|
2136
2136
|
constructor(message, exitCode) {
|
|
2137
2137
|
super(message);
|
|
2138
|
+
this.name = "ZapierCurlExitError";
|
|
2139
|
+
this.code = "ZAPIER_CURL_EXIT_ERROR";
|
|
2138
2140
|
this.exitCode = exitCode;
|
|
2139
|
-
this.name = "CurlExitError";
|
|
2140
2141
|
}
|
|
2141
2142
|
};
|
|
2142
2143
|
function parseHeaderLine(input) {
|
|
@@ -2228,7 +2229,7 @@ async function resolveDataArgBinary(raw) {
|
|
|
2228
2229
|
}
|
|
2229
2230
|
async function buildFormData(formArgs, formStringArgs) {
|
|
2230
2231
|
if (typeof FormData === "undefined") {
|
|
2231
|
-
throw new
|
|
2232
|
+
throw new ZapierCurlExitError(
|
|
2232
2233
|
"FormData is not available in this runtime; cannot use --form.",
|
|
2233
2234
|
2
|
|
2234
2235
|
);
|
|
@@ -2237,7 +2238,7 @@ async function buildFormData(formArgs, formStringArgs) {
|
|
|
2237
2238
|
const addField = async (item, forceString) => {
|
|
2238
2239
|
const idx = item.indexOf("=");
|
|
2239
2240
|
if (idx === -1) {
|
|
2240
|
-
throw new
|
|
2241
|
+
throw new ZapierCurlExitError(
|
|
2241
2242
|
`Invalid form field: '${item}'. Expected 'name=value' or 'name=@file'.`,
|
|
2242
2243
|
2
|
|
2243
2244
|
);
|
|
@@ -2245,7 +2246,7 @@ async function buildFormData(formArgs, formStringArgs) {
|
|
|
2245
2246
|
const name = item.slice(0, idx);
|
|
2246
2247
|
const value = item.slice(idx + 1);
|
|
2247
2248
|
if (!name) {
|
|
2248
|
-
throw new
|
|
2249
|
+
throw new ZapierCurlExitError(
|
|
2249
2250
|
`Invalid form field: '${item}'. Field name cannot be empty.`,
|
|
2250
2251
|
2
|
|
2251
2252
|
);
|
|
@@ -2482,7 +2483,7 @@ ${Array.from(
|
|
|
2482
2483
|
`
|
|
2483
2484
|
);
|
|
2484
2485
|
}
|
|
2485
|
-
throw new
|
|
2486
|
+
throw new ZapierCurlExitError("HTTP request failed", 22);
|
|
2486
2487
|
}
|
|
2487
2488
|
return void 0;
|
|
2488
2489
|
}
|
|
@@ -3001,11 +3002,491 @@ var initPlugin = zapierSdk.definePlugin(
|
|
|
3001
3002
|
}
|
|
3002
3003
|
})
|
|
3003
3004
|
);
|
|
3005
|
+
function jsonReplacer(_key, value) {
|
|
3006
|
+
if (value instanceof Error) {
|
|
3007
|
+
return {
|
|
3008
|
+
name: value.name,
|
|
3009
|
+
message: value.message,
|
|
3010
|
+
...value.stack ? { stack: value.stack } : {}
|
|
3011
|
+
};
|
|
3012
|
+
}
|
|
3013
|
+
return value;
|
|
3014
|
+
}
|
|
3015
|
+
var CliSkipLeaseExpireError = class extends Error {
|
|
3016
|
+
constructor() {
|
|
3017
|
+
super("user skipped (let lease expire)");
|
|
3018
|
+
this.name = "CliSkipLeaseExpireError";
|
|
3019
|
+
}
|
|
3020
|
+
};
|
|
3021
|
+
function createInteractiveCallback() {
|
|
3022
|
+
let messageNumber = 0;
|
|
3023
|
+
return async (message) => {
|
|
3024
|
+
messageNumber++;
|
|
3025
|
+
const attrs = message.message_attributes;
|
|
3026
|
+
console.log(
|
|
3027
|
+
`
|
|
3028
|
+
${chalk3__default.default.bold(`Message #${messageNumber}`)} ${chalk3__default.default.dim(message.id)} ${chalk3__default.default.dim(`(lease #${attrs.lease_count})`)}`
|
|
3029
|
+
);
|
|
3030
|
+
if (attrs.error_message) {
|
|
3031
|
+
console.log(chalk3__default.default.yellow(` upstream error: ${attrs.error_message}`));
|
|
3032
|
+
}
|
|
3033
|
+
if (attrs.possible_duplicate_data) {
|
|
3034
|
+
console.log(chalk3__default.default.yellow(" possible duplicate data"));
|
|
3035
|
+
}
|
|
3036
|
+
while (true) {
|
|
3037
|
+
let action;
|
|
3038
|
+
try {
|
|
3039
|
+
const answer = await inquirer__default.default.prompt([
|
|
3040
|
+
{
|
|
3041
|
+
type: "list",
|
|
3042
|
+
name: "action",
|
|
3043
|
+
message: "Action?",
|
|
3044
|
+
choices: [
|
|
3045
|
+
{ name: "Ack (remove from inbox)", value: "ack" },
|
|
3046
|
+
{
|
|
3047
|
+
name: "Skip (release after draining)",
|
|
3048
|
+
value: "skip-release"
|
|
3049
|
+
},
|
|
3050
|
+
{ name: "Skip (let lease expire)", value: "skip-expire" },
|
|
3051
|
+
{ name: "View payload", value: "view" },
|
|
3052
|
+
{ name: "Quit", value: "quit" }
|
|
3053
|
+
]
|
|
3054
|
+
}
|
|
3055
|
+
]);
|
|
3056
|
+
action = answer.action;
|
|
3057
|
+
} catch (error) {
|
|
3058
|
+
if (error instanceof Error && error.name === "ExitPromptError") {
|
|
3059
|
+
throw new zapierSdk.ZapierAbortDrainSignal("user pressed Ctrl-C");
|
|
3060
|
+
}
|
|
3061
|
+
throw error;
|
|
3062
|
+
}
|
|
3063
|
+
if (action === "view") {
|
|
3064
|
+
console.log(chalk3__default.default.dim(JSON.stringify(message.payload, null, 2)));
|
|
3065
|
+
continue;
|
|
3066
|
+
}
|
|
3067
|
+
if (action === "ack") {
|
|
3068
|
+
return;
|
|
3069
|
+
}
|
|
3070
|
+
if (action === "skip-release") {
|
|
3071
|
+
throw new zapierSdk.ZapierReleaseTriggerMessageSignal("user skipped (release)");
|
|
3072
|
+
}
|
|
3073
|
+
if (action === "skip-expire") {
|
|
3074
|
+
throw new CliSkipLeaseExpireError();
|
|
3075
|
+
}
|
|
3076
|
+
if (action === "quit") {
|
|
3077
|
+
throw new zapierSdk.ZapierAbortDrainSignal("user requested quit");
|
|
3078
|
+
}
|
|
3079
|
+
}
|
|
3080
|
+
};
|
|
3081
|
+
}
|
|
3082
|
+
function createNdjsonCallback() {
|
|
3083
|
+
return (message) => new Promise((resolve4, reject) => {
|
|
3084
|
+
process.stdout.write(JSON.stringify(message) + "\n", (err) => {
|
|
3085
|
+
if (err) reject(err);
|
|
3086
|
+
else resolve4();
|
|
3087
|
+
});
|
|
3088
|
+
});
|
|
3089
|
+
}
|
|
3090
|
+
function runSubprocess(options) {
|
|
3091
|
+
const { command, args, shell, label, message, signal } = options;
|
|
3092
|
+
return new Promise((resolve4, reject) => {
|
|
3093
|
+
const child = child_process.spawn(command, args, {
|
|
3094
|
+
shell,
|
|
3095
|
+
stdio: ["pipe", "inherit", "inherit"]
|
|
3096
|
+
});
|
|
3097
|
+
let abortListener;
|
|
3098
|
+
if (signal) {
|
|
3099
|
+
if (signal.aborted) {
|
|
3100
|
+
child.kill();
|
|
3101
|
+
} else {
|
|
3102
|
+
abortListener = () => {
|
|
3103
|
+
child.kill();
|
|
3104
|
+
};
|
|
3105
|
+
signal.addEventListener("abort", abortListener, { once: true });
|
|
3106
|
+
}
|
|
3107
|
+
}
|
|
3108
|
+
child.on("error", (err) => {
|
|
3109
|
+
if (signal && abortListener) {
|
|
3110
|
+
signal.removeEventListener("abort", abortListener);
|
|
3111
|
+
}
|
|
3112
|
+
reject(err);
|
|
3113
|
+
});
|
|
3114
|
+
child.on("close", (code) => {
|
|
3115
|
+
if (signal && abortListener) {
|
|
3116
|
+
signal.removeEventListener("abort", abortListener);
|
|
3117
|
+
}
|
|
3118
|
+
if (signal?.aborted) {
|
|
3119
|
+
reject(new zapierSdk.ZapierAbortDrainSignal(`${label} aborted`));
|
|
3120
|
+
return;
|
|
3121
|
+
}
|
|
3122
|
+
if (code === 0) resolve4();
|
|
3123
|
+
else
|
|
3124
|
+
reject(
|
|
3125
|
+
new Error(
|
|
3126
|
+
`${label} exited with code ${code} for message ${message.id}`
|
|
3127
|
+
)
|
|
3128
|
+
);
|
|
3129
|
+
});
|
|
3130
|
+
child.stdin.on("error", (err) => {
|
|
3131
|
+
if (err.code !== "EPIPE") reject(err);
|
|
3132
|
+
});
|
|
3133
|
+
child.stdin.end(JSON.stringify(message) + "\n");
|
|
3134
|
+
});
|
|
3135
|
+
}
|
|
3136
|
+
function runShellCommand(command, message, signal) {
|
|
3137
|
+
return runSubprocess({
|
|
3138
|
+
command,
|
|
3139
|
+
args: [],
|
|
3140
|
+
shell: true,
|
|
3141
|
+
label: "exec-shell",
|
|
3142
|
+
message,
|
|
3143
|
+
signal
|
|
3144
|
+
});
|
|
3145
|
+
}
|
|
3146
|
+
function runExecCommand(argv, message, signal) {
|
|
3147
|
+
if (argv.length === 0) {
|
|
3148
|
+
return Promise.reject(
|
|
3149
|
+
new Error("exec requires at least one element (the binary)")
|
|
3150
|
+
);
|
|
3151
|
+
}
|
|
3152
|
+
const [command, ...args] = argv;
|
|
3153
|
+
return runSubprocess({
|
|
3154
|
+
command,
|
|
3155
|
+
args,
|
|
3156
|
+
shell: false,
|
|
3157
|
+
label: "exec",
|
|
3158
|
+
message,
|
|
3159
|
+
signal
|
|
3160
|
+
});
|
|
3161
|
+
}
|
|
3162
|
+
function describeReason(reason) {
|
|
3163
|
+
return reason instanceof Error ? reason.message : String(reason);
|
|
3164
|
+
}
|
|
3165
|
+
function printDrainError(reason, message) {
|
|
3166
|
+
console.error(
|
|
3167
|
+
chalk3__default.default.red(`Error processing ${message.id}: ${describeReason(reason)}`)
|
|
3168
|
+
);
|
|
3169
|
+
}
|
|
3170
|
+
function printDrainSummary(counts) {
|
|
3171
|
+
const skipped = counts.skipped ?? 0;
|
|
3172
|
+
const total = counts.fulfilled + counts.rejected + skipped;
|
|
3173
|
+
const parts = [`${counts.fulfilled} fulfilled`];
|
|
3174
|
+
if (skipped > 0) parts.push(`${skipped} skipped`);
|
|
3175
|
+
parts.push(`${counts.rejected} rejected`);
|
|
3176
|
+
console.log(
|
|
3177
|
+
chalk3__default.default.dim(
|
|
3178
|
+
`
|
|
3179
|
+
Processed ${total} message${total === 1 ? "" : "s"} (${parts.join(", ")}).`
|
|
3180
|
+
)
|
|
3181
|
+
);
|
|
3182
|
+
}
|
|
3183
|
+
function warnInteractiveContinueOnErrorOverride() {
|
|
3184
|
+
console.warn(
|
|
3185
|
+
chalk3__default.default.yellow(
|
|
3186
|
+
'Note: continueOnError=false is overridden to true in interactive mode (the "Skip (let lease expire)" choice would otherwise terminate the drain).'
|
|
3187
|
+
)
|
|
3188
|
+
);
|
|
3189
|
+
}
|
|
3190
|
+
function requireInteractiveTty(commandName) {
|
|
3191
|
+
if (!process.stdin.isTTY || !process.stdout.isTTY) {
|
|
3192
|
+
throw new ZapierCliValidationError(
|
|
3193
|
+
`${commandName} needs an interactive terminal by default. Pass --exec '<bin>' (with optional \`-- args...\`) or --exec-shell '<cmd>' to run a script per message, or --json for non-interactive output.`
|
|
3194
|
+
);
|
|
3195
|
+
}
|
|
3196
|
+
}
|
|
3197
|
+
function rejectExecJsonMutex(opts) {
|
|
3198
|
+
const picked = [
|
|
3199
|
+
opts.exec ? "--exec" : null,
|
|
3200
|
+
opts.execShell ? "--exec-shell" : null,
|
|
3201
|
+
opts.json ? "--json" : null
|
|
3202
|
+
].filter((x) => x !== null);
|
|
3203
|
+
if (picked.length > 1) {
|
|
3204
|
+
throw new ZapierCliValidationError(
|
|
3205
|
+
`${picked.join(", ")} are mutually exclusive. Pick one.`
|
|
3206
|
+
);
|
|
3207
|
+
}
|
|
3208
|
+
}
|
|
3209
|
+
function getPostDashArgs(argv = process.argv) {
|
|
3210
|
+
const idx = argv.indexOf("--");
|
|
3211
|
+
if (idx === -1) return [];
|
|
3212
|
+
return argv.slice(idx + 1);
|
|
3213
|
+
}
|
|
3214
|
+
function combineSignals(a, b) {
|
|
3215
|
+
if (!a) {
|
|
3216
|
+
return { signal: b, dispose: () => void 0 };
|
|
3217
|
+
}
|
|
3218
|
+
const controller = new AbortController();
|
|
3219
|
+
const onAbort = () => controller.abort();
|
|
3220
|
+
if (a.aborted || b.aborted) controller.abort();
|
|
3221
|
+
else {
|
|
3222
|
+
a.addEventListener("abort", onAbort, { once: true });
|
|
3223
|
+
b.addEventListener("abort", onAbort, { once: true });
|
|
3224
|
+
}
|
|
3225
|
+
return {
|
|
3226
|
+
signal: controller.signal,
|
|
3227
|
+
dispose: () => {
|
|
3228
|
+
a.removeEventListener("abort", onAbort);
|
|
3229
|
+
b.removeEventListener("abort", onAbort);
|
|
3230
|
+
}
|
|
3231
|
+
};
|
|
3232
|
+
}
|
|
3233
|
+
|
|
3234
|
+
// src/plugins/drainTriggerInbox/index.ts
|
|
3235
|
+
var JsonProperty = zod.z.boolean().optional().describe(
|
|
3236
|
+
"Format the drained result as a JSON object on stdout: { data, errors }. Use for scripts or piping. Mutually exclusive with --exec / --exec-shell and the interactive default."
|
|
3237
|
+
);
|
|
3238
|
+
var ExecCliProperty = zod.z.string().optional().describe(
|
|
3239
|
+
"Run a binary per message with no shell interpretation. Message JSON is piped to stdin; exit code 0 acks, non-zero records the error per the same rules as a thrown handler. Pass extra argv after `--` (e.g. `--exec ./handler -- --verbose`). Mutually exclusive with --exec-shell and --json."
|
|
3240
|
+
);
|
|
3241
|
+
var ExecShellCliProperty = zod.z.string().optional().describe(
|
|
3242
|
+
"Run a shell command per message. Message JSON is piped to the subprocess on stdin; exit code 0 acks, non-zero records the error per the same rules as a thrown handler. Interpreted by the platform's default shell (sh on POSIX, cmd.exe on Windows). Mutually exclusive with --exec and --json."
|
|
3243
|
+
);
|
|
3244
|
+
zapierSdk.definePlugin(
|
|
3245
|
+
(sdk) => {
|
|
3246
|
+
const original = sdk.drainTriggerInbox;
|
|
3247
|
+
const existingMeta = sdk.context.meta.drainTriggerInbox;
|
|
3248
|
+
const baseInputSchema = existingMeta.inputSchema;
|
|
3249
|
+
const extendedInputSchema = baseInputSchema ? baseInputSchema.extend({
|
|
3250
|
+
exec: ExecCliProperty,
|
|
3251
|
+
execShell: ExecShellCliProperty,
|
|
3252
|
+
json: JsonProperty
|
|
3253
|
+
}) : zod.z.object({
|
|
3254
|
+
exec: ExecCliProperty,
|
|
3255
|
+
execShell: ExecShellCliProperty,
|
|
3256
|
+
json: JsonProperty
|
|
3257
|
+
});
|
|
3258
|
+
return {
|
|
3259
|
+
drainTriggerInbox: async (options) => {
|
|
3260
|
+
const { json, exec, execShell, ...sdkArgs } = options;
|
|
3261
|
+
rejectExecJsonMutex({ exec, execShell, json });
|
|
3262
|
+
if (!exec && !execShell && !json) {
|
|
3263
|
+
requireInteractiveTty("drain-trigger-inbox");
|
|
3264
|
+
}
|
|
3265
|
+
const sigintController = new AbortController();
|
|
3266
|
+
const onSigint = () => sigintController.abort();
|
|
3267
|
+
process.on("SIGINT", onSigint);
|
|
3268
|
+
const combined = combineSignals(
|
|
3269
|
+
sdkArgs.signal,
|
|
3270
|
+
sigintController.signal
|
|
3271
|
+
);
|
|
3272
|
+
let fulfilled = 0;
|
|
3273
|
+
let rejected = 0;
|
|
3274
|
+
let skipped = 0;
|
|
3275
|
+
const liveOnError = (reason, message) => {
|
|
3276
|
+
rejected++;
|
|
3277
|
+
printDrainError(reason, message);
|
|
3278
|
+
};
|
|
3279
|
+
try {
|
|
3280
|
+
if (exec) {
|
|
3281
|
+
const execArgv = [exec, ...getPostDashArgs()];
|
|
3282
|
+
await original({
|
|
3283
|
+
...sdkArgs,
|
|
3284
|
+
signal: combined.signal,
|
|
3285
|
+
onMessage: async (message) => {
|
|
3286
|
+
await runExecCommand(execArgv, message, combined.signal);
|
|
3287
|
+
fulfilled++;
|
|
3288
|
+
},
|
|
3289
|
+
onError: liveOnError
|
|
3290
|
+
});
|
|
3291
|
+
return;
|
|
3292
|
+
}
|
|
3293
|
+
if (execShell) {
|
|
3294
|
+
await original({
|
|
3295
|
+
...sdkArgs,
|
|
3296
|
+
signal: combined.signal,
|
|
3297
|
+
onMessage: async (message) => {
|
|
3298
|
+
await runShellCommand(execShell, message, combined.signal);
|
|
3299
|
+
fulfilled++;
|
|
3300
|
+
},
|
|
3301
|
+
onError: liveOnError
|
|
3302
|
+
});
|
|
3303
|
+
return;
|
|
3304
|
+
}
|
|
3305
|
+
if (json) {
|
|
3306
|
+
const data = [];
|
|
3307
|
+
const errors = [];
|
|
3308
|
+
await original({
|
|
3309
|
+
...sdkArgs,
|
|
3310
|
+
signal: combined.signal,
|
|
3311
|
+
continueOnError: true,
|
|
3312
|
+
onMessage: (message) => {
|
|
3313
|
+
data.push(message);
|
|
3314
|
+
},
|
|
3315
|
+
onError: (reason, message) => {
|
|
3316
|
+
errors.push({ reason, message });
|
|
3317
|
+
}
|
|
3318
|
+
});
|
|
3319
|
+
process.stdout.write(
|
|
3320
|
+
JSON.stringify({ data, errors }, jsonReplacer, 2) + "\n"
|
|
3321
|
+
);
|
|
3322
|
+
return;
|
|
3323
|
+
}
|
|
3324
|
+
if (sdkArgs.continueOnError === false) {
|
|
3325
|
+
warnInteractiveContinueOnErrorOverride();
|
|
3326
|
+
}
|
|
3327
|
+
const interactive = createInteractiveCallback();
|
|
3328
|
+
await original({
|
|
3329
|
+
...sdkArgs,
|
|
3330
|
+
signal: combined.signal,
|
|
3331
|
+
concurrency: 1,
|
|
3332
|
+
continueOnError: true,
|
|
3333
|
+
onMessage: async (message) => {
|
|
3334
|
+
try {
|
|
3335
|
+
await interactive(message);
|
|
3336
|
+
fulfilled++;
|
|
3337
|
+
} catch (err) {
|
|
3338
|
+
if (err instanceof zapierSdk.ZapierReleaseTriggerMessageSignal || err instanceof CliSkipLeaseExpireError) {
|
|
3339
|
+
skipped++;
|
|
3340
|
+
}
|
|
3341
|
+
throw err;
|
|
3342
|
+
}
|
|
3343
|
+
}
|
|
3344
|
+
});
|
|
3345
|
+
} finally {
|
|
3346
|
+
process.off("SIGINT", onSigint);
|
|
3347
|
+
combined.dispose();
|
|
3348
|
+
if (!json) {
|
|
3349
|
+
printDrainSummary({ fulfilled, rejected, skipped });
|
|
3350
|
+
}
|
|
3351
|
+
}
|
|
3352
|
+
},
|
|
3353
|
+
context: {
|
|
3354
|
+
meta: {
|
|
3355
|
+
drainTriggerInbox: {
|
|
3356
|
+
...existingMeta,
|
|
3357
|
+
inputSchema: extendedInputSchema,
|
|
3358
|
+
packages: void 0
|
|
3359
|
+
}
|
|
3360
|
+
}
|
|
3361
|
+
}
|
|
3362
|
+
};
|
|
3363
|
+
}
|
|
3364
|
+
);
|
|
3365
|
+
var JsonProperty2 = zod.z.boolean().optional().describe(
|
|
3366
|
+
"Stream each message as JSON to stdout (one record per line, NDJSON), acking as each write completes. Use for piping to other tools. Mutually exclusive with --exec / --exec-shell and the interactive default."
|
|
3367
|
+
);
|
|
3368
|
+
var ExecCliProperty2 = zod.z.string().optional().describe(
|
|
3369
|
+
"Run a binary per message with no shell interpretation. Message JSON is piped to stdin; exit code 0 acks, non-zero records the error per the same rules as a thrown handler. Pass extra argv after `--` (e.g. `--exec ./handler -- --verbose`). Mutually exclusive with --exec-shell and --json."
|
|
3370
|
+
);
|
|
3371
|
+
var ExecShellCliProperty2 = zod.z.string().optional().describe(
|
|
3372
|
+
"Run a shell command per message. Message JSON is piped to the subprocess on stdin; exit code 0 acks, non-zero records the error per the same rules as a thrown handler. Interpreted by the platform's default shell (sh on POSIX, cmd.exe on Windows). Mutually exclusive with --exec and --json."
|
|
3373
|
+
);
|
|
3374
|
+
zapierSdk.definePlugin(
|
|
3375
|
+
(sdk) => {
|
|
3376
|
+
const original = sdk.watchTriggerInbox;
|
|
3377
|
+
const existingMeta = sdk.context.meta.watchTriggerInbox;
|
|
3378
|
+
const baseInputSchema = existingMeta.inputSchema;
|
|
3379
|
+
const extendedInputSchema = baseInputSchema ? baseInputSchema.extend({
|
|
3380
|
+
exec: ExecCliProperty2,
|
|
3381
|
+
execShell: ExecShellCliProperty2,
|
|
3382
|
+
json: JsonProperty2
|
|
3383
|
+
}) : zod.z.object({
|
|
3384
|
+
exec: ExecCliProperty2,
|
|
3385
|
+
execShell: ExecShellCliProperty2,
|
|
3386
|
+
json: JsonProperty2
|
|
3387
|
+
});
|
|
3388
|
+
return {
|
|
3389
|
+
watchTriggerInbox: async (options) => {
|
|
3390
|
+
const { json, exec, execShell, ...sdkArgs } = options;
|
|
3391
|
+
rejectExecJsonMutex({ exec, execShell, json });
|
|
3392
|
+
if (!exec && !execShell && !json) {
|
|
3393
|
+
requireInteractiveTty("watch-trigger-inbox");
|
|
3394
|
+
}
|
|
3395
|
+
const sigintController = new AbortController();
|
|
3396
|
+
const onSigint = () => sigintController.abort();
|
|
3397
|
+
process.on("SIGINT", onSigint);
|
|
3398
|
+
const combined = combineSignals(
|
|
3399
|
+
sdkArgs.signal,
|
|
3400
|
+
sigintController.signal
|
|
3401
|
+
);
|
|
3402
|
+
let fulfilled = 0;
|
|
3403
|
+
let rejected = 0;
|
|
3404
|
+
let skipped = 0;
|
|
3405
|
+
const liveOnError = (reason, message) => {
|
|
3406
|
+
rejected++;
|
|
3407
|
+
printDrainError(reason, message);
|
|
3408
|
+
};
|
|
3409
|
+
try {
|
|
3410
|
+
if (exec) {
|
|
3411
|
+
const execArgv = [exec, ...getPostDashArgs()];
|
|
3412
|
+
await original({
|
|
3413
|
+
...sdkArgs,
|
|
3414
|
+
signal: combined.signal,
|
|
3415
|
+
onMessage: async (message) => {
|
|
3416
|
+
await runExecCommand(execArgv, message, combined.signal);
|
|
3417
|
+
fulfilled++;
|
|
3418
|
+
},
|
|
3419
|
+
onError: liveOnError
|
|
3420
|
+
});
|
|
3421
|
+
} else if (execShell) {
|
|
3422
|
+
await original({
|
|
3423
|
+
...sdkArgs,
|
|
3424
|
+
signal: combined.signal,
|
|
3425
|
+
onMessage: async (message) => {
|
|
3426
|
+
await runShellCommand(execShell, message, combined.signal);
|
|
3427
|
+
fulfilled++;
|
|
3428
|
+
},
|
|
3429
|
+
onError: liveOnError
|
|
3430
|
+
});
|
|
3431
|
+
} else if (json) {
|
|
3432
|
+
const ndjson = createNdjsonCallback();
|
|
3433
|
+
await original({
|
|
3434
|
+
...sdkArgs,
|
|
3435
|
+
signal: combined.signal,
|
|
3436
|
+
onMessage: async (message) => {
|
|
3437
|
+
await ndjson(message);
|
|
3438
|
+
fulfilled++;
|
|
3439
|
+
},
|
|
3440
|
+
onError: liveOnError
|
|
3441
|
+
});
|
|
3442
|
+
} else {
|
|
3443
|
+
if (sdkArgs.continueOnError === false) {
|
|
3444
|
+
warnInteractiveContinueOnErrorOverride();
|
|
3445
|
+
}
|
|
3446
|
+
const interactive = createInteractiveCallback();
|
|
3447
|
+
await original({
|
|
3448
|
+
...sdkArgs,
|
|
3449
|
+
signal: combined.signal,
|
|
3450
|
+
concurrency: 1,
|
|
3451
|
+
continueOnError: true,
|
|
3452
|
+
onMessage: async (message) => {
|
|
3453
|
+
try {
|
|
3454
|
+
await interactive(message);
|
|
3455
|
+
fulfilled++;
|
|
3456
|
+
} catch (err) {
|
|
3457
|
+
if (err instanceof zapierSdk.ZapierReleaseTriggerMessageSignal || err instanceof CliSkipLeaseExpireError) {
|
|
3458
|
+
skipped++;
|
|
3459
|
+
}
|
|
3460
|
+
throw err;
|
|
3461
|
+
}
|
|
3462
|
+
}
|
|
3463
|
+
});
|
|
3464
|
+
}
|
|
3465
|
+
} finally {
|
|
3466
|
+
process.off("SIGINT", onSigint);
|
|
3467
|
+
combined.dispose();
|
|
3468
|
+
if (!json) {
|
|
3469
|
+
printDrainSummary({ fulfilled, rejected, skipped });
|
|
3470
|
+
}
|
|
3471
|
+
}
|
|
3472
|
+
},
|
|
3473
|
+
context: {
|
|
3474
|
+
meta: {
|
|
3475
|
+
watchTriggerInbox: {
|
|
3476
|
+
...existingMeta,
|
|
3477
|
+
inputSchema: extendedInputSchema,
|
|
3478
|
+
packages: void 0
|
|
3479
|
+
}
|
|
3480
|
+
}
|
|
3481
|
+
}
|
|
3482
|
+
};
|
|
3483
|
+
}
|
|
3484
|
+
);
|
|
3004
3485
|
|
|
3005
3486
|
// package.json with { type: 'json' }
|
|
3006
3487
|
var package_default = {
|
|
3007
3488
|
name: "@zapier/zapier-sdk-cli",
|
|
3008
|
-
version: "0.
|
|
3489
|
+
version: "0.45.0"};
|
|
3009
3490
|
|
|
3010
3491
|
// src/sdk.ts
|
|
3011
3492
|
zapierSdk.injectCliLogin(login_exports);
|
|
@@ -3033,7 +3514,7 @@ function createZapierCliSdk(options = {}) {
|
|
|
3033
3514
|
|
|
3034
3515
|
// package.json
|
|
3035
3516
|
var package_default2 = {
|
|
3036
|
-
version: "0.
|
|
3517
|
+
version: "0.45.0"};
|
|
3037
3518
|
|
|
3038
3519
|
// src/telemetry/builders.ts
|
|
3039
3520
|
function createCliBaseEvent(context = {}) {
|