@zapier/zapier-sdk-cli 0.43.0 → 0.43.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.
Files changed (34) hide show
  1. package/CHANGELOG.md +9 -0
  2. package/dist/cli.cjs +434 -519
  3. package/dist/cli.mjs +437 -522
  4. package/dist/index.cjs +436 -521
  5. package/dist/index.d.mts +395 -23
  6. package/dist/index.d.ts +395 -23
  7. package/dist/index.mjs +440 -525
  8. package/dist/package.json +1 -1
  9. package/dist/src/plugins/add/index.d.ts +250 -11
  10. package/dist/src/plugins/add/index.js +8 -16
  11. package/dist/src/plugins/buildManifest/index.d.ts +116 -9
  12. package/dist/src/plugins/buildManifest/index.js +14 -23
  13. package/dist/src/plugins/bundleCode/index.d.ts +19 -10
  14. package/dist/src/plugins/bundleCode/index.js +7 -17
  15. package/dist/src/plugins/cliOverrides/index.d.ts +12 -10
  16. package/dist/src/plugins/cliOverrides/index.js +16 -20
  17. package/dist/src/plugins/curl/index.d.ts +69 -10
  18. package/dist/src/plugins/curl/index.js +3 -2
  19. package/dist/src/plugins/feedback/index.d.ts +18 -13
  20. package/dist/src/plugins/feedback/index.js +17 -25
  21. package/dist/src/plugins/generateAppTypes/index.d.ts +261 -9
  22. package/dist/src/plugins/generateAppTypes/index.js +17 -45
  23. package/dist/src/plugins/getLoginConfigPath/index.d.ts +12 -10
  24. package/dist/src/plugins/getLoginConfigPath/index.js +8 -18
  25. package/dist/src/plugins/init/index.d.ts +15 -11
  26. package/dist/src/plugins/init/index.js +9 -17
  27. package/dist/src/plugins/login/index.d.ts +18 -13
  28. package/dist/src/plugins/login/index.js +9 -17
  29. package/dist/src/plugins/logout/index.d.ts +12 -11
  30. package/dist/src/plugins/logout/index.js +10 -16
  31. package/dist/src/plugins/mcp/index.d.ts +18 -15
  32. package/dist/src/plugins/mcp/index.js +9 -21
  33. package/dist/tsconfig.tsbuildinfo +1 -1
  34. package/package.json +3 -3
package/dist/cli.mjs CHANGED
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env node
2
2
  import { Command, CommanderError, Option } from 'commander';
3
3
  import { z } from 'zod';
4
- import { createFunction, OutputPropertySchema, DEFAULT_CONFIG_PATH, injectCliLogin, BaseSdkOptionsSchema, createZapierSdk, ZapierError, ZapierValidationError, ZapierUnknownError, batch, toSnakeCase, buildApplicationLifecycleEvent, isCredentialsObject, isPositional, runWithTelemetryContext, buildCapabilityMessage, formatErrorMessage, getOsInfo, getPlatformVersions, getCiPlatform, isCi, getReleaseId, getCurrentTimestamp, generateEventId } from '@zapier/zapier-sdk';
4
+ import { definePlugin, createPluginMethod, buildApplicationLifecycleEvent, OutputPropertySchema, DEFAULT_CONFIG_PATH, ZapierValidationError, ZapierUnknownError, injectCliLogin, BaseSdkOptionsSchema, isCredentialsObject, batch, toSnakeCase, createZapierSdk, ZapierError, isPositional, runWithTelemetryContext, buildCapabilityMessage, formatErrorMessage, getOsInfo, getPlatformVersions, getCiPlatform, isCi, getReleaseId, getCurrentTimestamp, generateEventId } from '@zapier/zapier-sdk';
5
5
  import inquirer from 'inquirer';
6
6
  import chalk7 from 'chalk';
7
7
  import ora from 'ora';
@@ -9,9 +9,9 @@ import util from 'util';
9
9
  import wrapAnsi from 'wrap-ansi';
10
10
  import Conf from 'conf';
11
11
  import * as fs from 'fs';
12
- import { existsSync, promises, createWriteStream, readdirSync, rmSync, mkdirSync, writeFileSync, copyFileSync, readFileSync } from 'fs';
12
+ import { promises, createWriteStream, existsSync, readdirSync, rmSync, mkdirSync, writeFileSync, copyFileSync, readFileSync } from 'fs';
13
13
  import * as jwt from 'jsonwebtoken';
14
- import { setPassword, getKeyring, getPassword, deletePassword } from 'cross-keychain';
14
+ import { getPassword, getKeyring, setPassword, deletePassword } from 'cross-keychain';
15
15
  import crypto, { createHash } from 'crypto';
16
16
  import * as path from 'path';
17
17
  import { resolve, join, dirname, basename, relative, extname } from 'path';
@@ -1072,7 +1072,7 @@ var SHARED_COMMAND_CLI_OPTIONS = [
1072
1072
 
1073
1073
  // package.json
1074
1074
  var package_default = {
1075
- version: "0.43.0"};
1075
+ version: "0.43.1"};
1076
1076
 
1077
1077
  // src/telemetry/builders.ts
1078
1078
  function createCliBaseEvent(context = {}) {
@@ -3057,85 +3057,65 @@ function toPkceCredentials(credentials2) {
3057
3057
  }
3058
3058
  return void 0;
3059
3059
  }
3060
- var loginPlugin = (sdk2) => {
3061
- const loginFn = async (options) => {
3062
- const timeoutSeconds = options.timeout ? parseInt(options.timeout, 10) : 300;
3063
- if (isNaN(timeoutSeconds) || timeoutSeconds <= 0) {
3064
- throw new Error("Timeout must be a positive number");
3065
- }
3066
- const resolvedCredentials = await sdk2.context.resolveCredentials();
3067
- const pkceCredentials = toPkceCredentials(resolvedCredentials);
3068
- await login_default({
3069
- timeoutMs: timeoutSeconds * 1e3,
3070
- credentials: pkceCredentials
3071
- });
3072
- const user = await getLoggedInUser();
3073
- sdk2.context.eventEmission.emit(
3074
- "platform.sdk.ApplicationLifecycleEvent",
3075
- buildApplicationLifecycleEvent(
3076
- { lifecycle_event_type: "login_success" },
3077
- { customuser_id: user.customUserId, account_id: user.accountId }
3078
- )
3079
- );
3080
- console.log(`\u2705 Successfully logged in as ${user.email}`);
3081
- };
3082
- return {
3083
- login: loginFn,
3084
- context: {
3085
- meta: {
3086
- login: {
3087
- categories: ["account"],
3088
- inputSchema: LoginSchema,
3089
- supportsJsonOutput: false
3090
- }
3060
+ var loginPlugin = definePlugin(
3061
+ (sdk2) => createPluginMethod(sdk2, {
3062
+ name: "login",
3063
+ categories: ["account"],
3064
+ inputSchema: LoginSchema,
3065
+ supportsJsonOutput: false,
3066
+ handler: async ({ sdk: sdk3, options }) => {
3067
+ const timeoutSeconds = options.timeout ? parseInt(options.timeout, 10) : 300;
3068
+ if (isNaN(timeoutSeconds) || timeoutSeconds <= 0) {
3069
+ throw new Error("Timeout must be a positive number");
3091
3070
  }
3071
+ const resolvedCredentials = await sdk3.context.resolveCredentials();
3072
+ const pkceCredentials = toPkceCredentials(resolvedCredentials);
3073
+ await login_default({
3074
+ timeoutMs: timeoutSeconds * 1e3,
3075
+ credentials: pkceCredentials
3076
+ });
3077
+ const user = await getLoggedInUser();
3078
+ sdk3.context.eventEmission.emit(
3079
+ "platform.sdk.ApplicationLifecycleEvent",
3080
+ buildApplicationLifecycleEvent(
3081
+ { lifecycle_event_type: "login_success" },
3082
+ { customuser_id: user.customUserId, account_id: user.accountId }
3083
+ )
3084
+ );
3085
+ console.log(`\u2705 Successfully logged in as ${user.email}`);
3092
3086
  }
3093
- };
3094
- };
3087
+ })
3088
+ );
3095
3089
  var LogoutSchema = z.object({}).describe("Log out of your Zapier account");
3096
3090
 
3097
3091
  // src/plugins/logout/index.ts
3098
- var logoutWithSdk = createFunction(async function logoutWithSdk2(_options) {
3099
- await logout();
3100
- console.log("\u2705 Successfully logged out");
3101
- }, LogoutSchema);
3102
- var logoutPlugin = () => ({
3103
- logout: logoutWithSdk,
3104
- context: {
3105
- meta: {
3106
- logout: {
3107
- categories: ["account"],
3108
- inputSchema: LogoutSchema,
3109
- supportsJsonOutput: false
3110
- }
3092
+ var logoutPlugin = definePlugin(
3093
+ (sdk2) => createPluginMethod(sdk2, {
3094
+ name: "logout",
3095
+ categories: ["account"],
3096
+ inputSchema: LogoutSchema,
3097
+ supportsJsonOutput: false,
3098
+ handler: async () => {
3099
+ await logout();
3100
+ console.log("\u2705 Successfully logged out");
3111
3101
  }
3112
- }
3113
- });
3102
+ })
3103
+ );
3114
3104
  var McpSchema = z.object({
3115
3105
  port: z.string().optional().describe("Port to listen on (for future HTTP transport)")
3116
3106
  }).describe("Start MCP server for Zapier SDK");
3117
3107
 
3118
3108
  // src/plugins/mcp/index.ts
3119
- var mcpPlugin = (sdk2) => {
3120
- const mcpWithSdk = createFunction(async function mcpWithSdk2(options) {
3121
- const mcpOptions = {
3122
- ...options,
3123
- debug: sdk2.context.options?.debug
3124
- };
3125
- return await startMcpServer(mcpOptions);
3126
- }, McpSchema);
3127
- return {
3128
- mcp: mcpWithSdk,
3129
- context: {
3130
- meta: {
3131
- mcp: {
3132
- categories: ["utility"],
3133
- inputSchema: McpSchema
3134
- }
3135
- }
3109
+ var mcpPlugin = definePlugin(
3110
+ (sdk2) => createPluginMethod(sdk2, {
3111
+ name: "mcp",
3112
+ categories: ["utility"],
3113
+ inputSchema: McpSchema,
3114
+ handler: async ({ sdk: sdk3, options }) => {
3115
+ await startMcpServer({ ...options, debug: sdk3.context.options?.debug });
3136
3116
  }
3137
- };
3138
- };
3117
+ })
3118
+ );
3139
3119
  var BundleCodeSchema = z.object({
3140
3120
  input: z.string().min(1).describe("Input TypeScript file path to bundle"),
3141
3121
  output: OutputPropertySchema.optional().describe(
@@ -3146,22 +3126,14 @@ var BundleCodeSchema = z.object({
3146
3126
  target: z.string().optional().describe("ECMAScript target version"),
3147
3127
  cjs: z.boolean().optional().describe("Output CommonJS format instead of ESM")
3148
3128
  }).describe("Bundle TypeScript code into executable JavaScript");
3149
- var bundleCodePlugin = () => {
3150
- const bundleCodeWithSdk = createFunction(async function bundleCodeWithSdk2(options) {
3151
- return await bundleCode(options);
3152
- }, BundleCodeSchema);
3153
- return {
3154
- bundleCode: bundleCodeWithSdk,
3155
- context: {
3156
- meta: {
3157
- bundleCode: {
3158
- categories: ["utility", "deprecated"],
3159
- inputSchema: BundleCodeSchema
3160
- }
3161
- }
3162
- }
3163
- };
3164
- };
3129
+ var bundleCodePlugin = definePlugin(
3130
+ (sdk2) => createPluginMethod(sdk2, {
3131
+ name: "bundleCode",
3132
+ categories: ["utility", "deprecated"],
3133
+ inputSchema: BundleCodeSchema,
3134
+ handler: async ({ options }) => bundleCode(options)
3135
+ })
3136
+ );
3165
3137
  var ZapierBundleError = class extends Error {
3166
3138
  constructor(message, details, originalError) {
3167
3139
  super(message);
@@ -3228,25 +3200,14 @@ async function bundleCode(options) {
3228
3200
  }
3229
3201
  }
3230
3202
  var GetLoginConfigPathSchema = z.object({}).describe("Show the path to the login configuration file");
3231
- var getLoginConfigPathPlugin = () => {
3232
- const getLoginConfigPathWithSdk = createFunction(
3233
- async function getLoginConfigPathWithSdk2(_options) {
3234
- return getConfigPath();
3235
- },
3236
- GetLoginConfigPathSchema
3237
- );
3238
- return {
3239
- getLoginConfigPath: getLoginConfigPathWithSdk,
3240
- context: {
3241
- meta: {
3242
- getLoginConfigPath: {
3243
- categories: ["utility"],
3244
- inputSchema: GetLoginConfigPathSchema
3245
- }
3246
- }
3247
- }
3248
- };
3249
- };
3203
+ var getLoginConfigPathPlugin = definePlugin(
3204
+ (sdk2) => createPluginMethod(sdk2, {
3205
+ name: "getLoginConfigPath",
3206
+ categories: ["utility"],
3207
+ inputSchema: GetLoginConfigPathSchema,
3208
+ handler: async () => getConfigPath()
3209
+ })
3210
+ );
3250
3211
  var AddSchema = z.object({
3251
3212
  apps: z.array(z.string().min(1, "App key cannot be empty")).min(1, "At least one app key is required").describe(
3252
3213
  "One or more app keys to add (e.g., 'slack', 'github', 'trello')"
@@ -3274,111 +3235,105 @@ async function detectTypesOutputDirectory() {
3274
3235
  }
3275
3236
  return "./zapier/apps/";
3276
3237
  }
3277
- var addPlugin = (sdk2) => {
3278
- const add = createFunction(async function add2(options) {
3279
- const {
3280
- apps: appKeys,
3281
- connections: connectionIds,
3282
- configPath,
3283
- typesOutput = await detectTypesOutputDirectory()
3284
- } = options;
3285
- const resolvedTypesOutput = resolve(typesOutput);
3286
- console.log(`\u{1F4E6} Adding ${appKeys.length} app(s)...`);
3287
- const appSlugAndKeyMap = /* @__PURE__ */ new Map();
3288
- const handleManifestProgress = (event) => {
3289
- switch (event.type) {
3290
- case "apps_lookup_start":
3291
- console.log(`\u{1F4E6} Looking up ${event.count} app(s)...`);
3292
- break;
3293
- case "app_found":
3294
- const displayName = event.app.slug ? `${event.app.slug} (${event.app.key})` : event.app.key;
3295
- appSlugAndKeyMap.set(event.app.key, displayName);
3296
- break;
3297
- case "apps_lookup_complete":
3298
- if (event.count === 0) {
3299
- console.warn("\u26A0\uFE0F No apps found");
3300
- }
3301
- break;
3302
- case "app_processing_start":
3303
- const appName = event.slug ? `${event.slug} (${event.app})` : event.app;
3304
- console.log(`\u{1F4E6} Adding ${appName}...`);
3305
- break;
3306
- case "manifest_updated":
3307
- const appDisplay = appSlugAndKeyMap.get(event.app) || event.app;
3308
- console.log(
3309
- `\u{1F4DD} Locked ${appDisplay} to ${event.app}@${event.version} using key '${event.manifestKey}'`
3310
- );
3311
- break;
3312
- case "app_processing_error":
3313
- const errorApp = appSlugAndKeyMap.get(event.app) || event.app;
3314
- console.warn(`\u26A0\uFE0F ${event.error} for ${errorApp}`);
3315
- break;
3316
- }
3317
- };
3318
- const handleTypesProgress = (event) => {
3319
- switch (event.type) {
3320
- case "connections_lookup_start":
3321
- console.log(`\u{1F510} Looking up ${event.count} connection(s)...`);
3322
- break;
3323
- case "connections_lookup_complete":
3324
- console.log(`\u{1F510} Found ${event.count} connection(s)`);
3325
- break;
3326
- case "connection_matched":
3327
- const appWithConnection = appSlugAndKeyMap.get(event.app) || event.app;
3328
- console.log(
3329
- `\u{1F510} Using connection ${event.connectionId} (${event.connectionTitle}) for ${appWithConnection}`
3330
- );
3331
- break;
3332
- case "connection_not_matched":
3333
- const appWithoutConnection = appSlugAndKeyMap.get(event.app) || event.app;
3334
- console.warn(
3335
- `\u26A0\uFE0F No matching connection found for ${appWithoutConnection}`
3336
- );
3337
- break;
3338
- case "file_written":
3339
- console.log(
3340
- `\u{1F527} Generated types for ${event.manifestKey} at ${event.filePath}`
3341
- );
3342
- break;
3343
- case "app_processing_error":
3344
- const errorApp = appSlugAndKeyMap.get(event.app) || event.app;
3345
- console.warn(`\u26A0\uFE0F ${event.error} for ${errorApp}`);
3346
- break;
3347
- }
3348
- };
3349
- const manifestResult = await sdk2.buildManifest({
3350
- apps: appKeys,
3351
- skipWrite: false,
3352
- configPath,
3353
- onProgress: handleManifestProgress
3354
- });
3355
- const typesResult = await sdk2.generateAppTypes({
3356
- apps: appKeys,
3357
- connections: connectionIds,
3358
- skipWrite: false,
3359
- typesOutputDirectory: resolvedTypesOutput,
3360
- onProgress: handleTypesProgress
3361
- });
3362
- const results = manifestResult.manifest?.apps || {};
3363
- const successfulApps = Object.keys(results).filter(
3364
- (manifestKey) => typesResult.writtenFiles?.[manifestKey]
3365
- );
3366
- if (successfulApps.length > 0) {
3367
- console.log(`\u2705 Added ${successfulApps.length} app(s) to manifest`);
3368
- }
3369
- }, AddSchema);
3370
- return {
3371
- add,
3372
- context: {
3373
- meta: {
3374
- add: {
3375
- categories: ["utility"],
3376
- inputSchema: AddSchema
3238
+ var addPlugin = definePlugin(
3239
+ (sdk2) => createPluginMethod(sdk2, {
3240
+ name: "add",
3241
+ categories: ["utility"],
3242
+ inputSchema: AddSchema,
3243
+ handler: async ({ sdk: sdk3, options }) => {
3244
+ const {
3245
+ apps: appKeys,
3246
+ connections: connectionIds,
3247
+ configPath,
3248
+ typesOutput = await detectTypesOutputDirectory()
3249
+ } = options;
3250
+ const resolvedTypesOutput = resolve(typesOutput);
3251
+ console.log(`\u{1F4E6} Adding ${appKeys.length} app(s)...`);
3252
+ const appSlugAndKeyMap = /* @__PURE__ */ new Map();
3253
+ const handleManifestProgress = (event) => {
3254
+ switch (event.type) {
3255
+ case "apps_lookup_start":
3256
+ console.log(`\u{1F4E6} Looking up ${event.count} app(s)...`);
3257
+ break;
3258
+ case "app_found":
3259
+ const displayName = event.app.slug ? `${event.app.slug} (${event.app.key})` : event.app.key;
3260
+ appSlugAndKeyMap.set(event.app.key, displayName);
3261
+ break;
3262
+ case "apps_lookup_complete":
3263
+ if (event.count === 0) {
3264
+ console.warn("\u26A0\uFE0F No apps found");
3265
+ }
3266
+ break;
3267
+ case "app_processing_start":
3268
+ const appName = event.slug ? `${event.slug} (${event.app})` : event.app;
3269
+ console.log(`\u{1F4E6} Adding ${appName}...`);
3270
+ break;
3271
+ case "manifest_updated":
3272
+ const appDisplay = appSlugAndKeyMap.get(event.app) || event.app;
3273
+ console.log(
3274
+ `\u{1F4DD} Locked ${appDisplay} to ${event.app}@${event.version} using key '${event.manifestKey}'`
3275
+ );
3276
+ break;
3277
+ case "app_processing_error":
3278
+ const errorApp = appSlugAndKeyMap.get(event.app) || event.app;
3279
+ console.warn(`\u26A0\uFE0F ${event.error} for ${errorApp}`);
3280
+ break;
3281
+ }
3282
+ };
3283
+ const handleTypesProgress = (event) => {
3284
+ switch (event.type) {
3285
+ case "connections_lookup_start":
3286
+ console.log(`\u{1F510} Looking up ${event.count} connection(s)...`);
3287
+ break;
3288
+ case "connections_lookup_complete":
3289
+ console.log(`\u{1F510} Found ${event.count} connection(s)`);
3290
+ break;
3291
+ case "connection_matched":
3292
+ const appWithConnection = appSlugAndKeyMap.get(event.app) || event.app;
3293
+ console.log(
3294
+ `\u{1F510} Using connection ${event.connectionId} (${event.connectionTitle}) for ${appWithConnection}`
3295
+ );
3296
+ break;
3297
+ case "connection_not_matched":
3298
+ const appWithoutConnection = appSlugAndKeyMap.get(event.app) || event.app;
3299
+ console.warn(
3300
+ `\u26A0\uFE0F No matching connection found for ${appWithoutConnection}`
3301
+ );
3302
+ break;
3303
+ case "file_written":
3304
+ console.log(
3305
+ `\u{1F527} Generated types for ${event.manifestKey} at ${event.filePath}`
3306
+ );
3307
+ break;
3308
+ case "app_processing_error":
3309
+ const errorApp = appSlugAndKeyMap.get(event.app) || event.app;
3310
+ console.warn(`\u26A0\uFE0F ${event.error} for ${errorApp}`);
3311
+ break;
3377
3312
  }
3313
+ };
3314
+ const manifestResult = await sdk3.buildManifest({
3315
+ apps: appKeys,
3316
+ skipWrite: false,
3317
+ configPath,
3318
+ onProgress: handleManifestProgress
3319
+ });
3320
+ const typesResult = await sdk3.generateAppTypes({
3321
+ apps: appKeys,
3322
+ connections: connectionIds,
3323
+ skipWrite: false,
3324
+ typesOutputDirectory: resolvedTypesOutput,
3325
+ onProgress: handleTypesProgress
3326
+ });
3327
+ const results = manifestResult.manifest?.apps || {};
3328
+ const successfulApps = Object.keys(results).filter(
3329
+ (manifestKey) => typesResult.writtenFiles?.[manifestKey]
3330
+ );
3331
+ if (successfulApps.length > 0) {
3332
+ console.log(`\u2705 Added ${successfulApps.length} app(s) to manifest`);
3378
3333
  }
3379
3334
  }
3380
- };
3381
- };
3335
+ })
3336
+ );
3382
3337
  var GenerateAppTypesSchema = z.object({
3383
3338
  apps: z.array(z.string().min(1, "App key cannot be empty")).min(1, "At least one app key is required").describe(
3384
3339
  "One or more app keys to generate types for (e.g., 'slack', 'github', 'trello')"
@@ -3985,150 +3940,133 @@ function createManifestEntry(app) {
3985
3940
  version: app.version
3986
3941
  };
3987
3942
  }
3988
- var generateAppTypesPlugin = (sdk2) => {
3989
- const generateAppTypes = createFunction(async function generateAppTypes2(options) {
3990
- const {
3991
- apps: appKeys,
3992
- connections: connectionIds,
3993
- skipWrite = false,
3994
- typesOutputDirectory = await detectTypesOutputDirectory(),
3995
- onProgress
3996
- } = options;
3997
- const resolvedTypesOutput = resolve(typesOutputDirectory);
3998
- const result = {
3999
- typeDefinitions: {}
4000
- };
4001
- onProgress?.({ type: "apps_lookup_start", count: appKeys.length });
4002
- const appsIterable = sdk2.listApps({ apps: appKeys }).items();
4003
- const apps = [];
4004
- for await (const app of appsIterable) {
4005
- apps.push(app);
4006
- onProgress?.({ type: "app_found", app });
4007
- }
4008
- onProgress?.({ type: "apps_lookup_complete", count: apps.length });
4009
- if (apps.length === 0) {
4010
- return result;
4011
- }
4012
- const connections = [];
4013
- if (connectionIds && connectionIds.length > 0) {
4014
- onProgress?.({
4015
- type: "connections_lookup_start",
4016
- count: connectionIds.length
4017
- });
4018
- const connectionsIterable = sdk2.listConnections({ connections: connectionIds }).items();
4019
- for await (const connection of connectionsIterable) {
4020
- connections.push(connection);
3943
+ var generateAppTypesPlugin = definePlugin(
3944
+ (sdk2) => createPluginMethod(sdk2, {
3945
+ name: "generateAppTypes",
3946
+ categories: ["utility"],
3947
+ // Cast: schema validates JSON fields only; GenerateAppTypesOptions adds
3948
+ // the runtime-only `onProgress` callback (passthrough via createFunction).
3949
+ inputSchema: GenerateAppTypesSchema,
3950
+ handler: async ({ sdk: sdk3, options }) => {
3951
+ const {
3952
+ apps: appKeys,
3953
+ connections: connectionIds,
3954
+ skipWrite = false,
3955
+ typesOutputDirectory = await detectTypesOutputDirectory(),
3956
+ onProgress
3957
+ } = options;
3958
+ const resolvedTypesOutput = resolve(typesOutputDirectory);
3959
+ const result = { typeDefinitions: {} };
3960
+ onProgress?.({ type: "apps_lookup_start", count: appKeys.length });
3961
+ const appsIterable = sdk3.listApps({ apps: appKeys }).items();
3962
+ const apps = [];
3963
+ for await (const app of appsIterable) {
3964
+ apps.push(app);
3965
+ onProgress?.({ type: "app_found", app });
4021
3966
  }
4022
- onProgress?.({
4023
- type: "connections_lookup_complete",
4024
- count: connections.length
4025
- });
4026
- }
4027
- if (!skipWrite && resolvedTypesOutput) {
4028
- await mkdir(resolvedTypesOutput, { recursive: true });
4029
- }
4030
- if (!skipWrite) {
4031
- result.writtenFiles = {};
4032
- }
4033
- for (const app of apps) {
4034
- onProgress?.({
4035
- type: "app_processing_start",
4036
- app: app.key,
4037
- slug: app.slug
4038
- });
4039
- try {
4040
- if (!app.version) {
4041
- const errorMessage = `Invalid implementation ID format: ${app.implementation_id}. Expected format: <implementationName>@<version>`;
4042
- onProgress?.({
4043
- type: "app_processing_error",
4044
- app: app.key,
4045
- error: errorMessage
4046
- });
4047
- throw new ZapierValidationError(errorMessage, {
4048
- details: {
4049
- appKey: app.key,
4050
- implementationId: app.implementation_id
4051
- }
4052
- });
3967
+ onProgress?.({ type: "apps_lookup_complete", count: apps.length });
3968
+ if (apps.length === 0) {
3969
+ return result;
3970
+ }
3971
+ const connections = [];
3972
+ if (connectionIds && connectionIds.length > 0) {
3973
+ onProgress?.({
3974
+ type: "connections_lookup_start",
3975
+ count: connectionIds.length
3976
+ });
3977
+ const connectionsIterable = sdk3.listConnections({ connections: connectionIds }).items();
3978
+ for await (const connection of connectionsIterable) {
3979
+ connections.push(connection);
4053
3980
  }
4054
- let connectionId;
4055
- if (connections.length > 0) {
4056
- const matchingConnection = connections.find((conn) => {
4057
- return conn.app_key === app.key;
4058
- });
4059
- if (matchingConnection) {
4060
- connectionId = matchingConnection.id;
3981
+ onProgress?.({
3982
+ type: "connections_lookup_complete",
3983
+ count: connections.length
3984
+ });
3985
+ }
3986
+ if (!skipWrite && resolvedTypesOutput) {
3987
+ await mkdir(resolvedTypesOutput, { recursive: true });
3988
+ }
3989
+ if (!skipWrite) {
3990
+ result.writtenFiles = {};
3991
+ }
3992
+ for (const app of apps) {
3993
+ onProgress?.({
3994
+ type: "app_processing_start",
3995
+ app: app.key,
3996
+ slug: app.slug
3997
+ });
3998
+ try {
3999
+ if (!app.version) {
4000
+ const errorMessage = `Invalid implementation ID format: ${app.implementation_id}. Expected format: <implementationName>@<version>`;
4061
4001
  onProgress?.({
4062
- type: "connection_matched",
4002
+ type: "app_processing_error",
4063
4003
  app: app.key,
4064
- connectionId: matchingConnection.id,
4065
- connectionTitle: matchingConnection.title || ""
4004
+ error: errorMessage
4066
4005
  });
4067
- } else {
4068
- onProgress?.({
4069
- type: "connection_not_matched",
4070
- app: app.key
4006
+ throw new ZapierValidationError(errorMessage, {
4007
+ details: {
4008
+ appKey: app.key,
4009
+ implementationId: app.implementation_id
4010
+ }
4071
4011
  });
4072
4012
  }
4073
- }
4074
- const manifestKey = getManifestKey(app);
4075
- const generator = new AstTypeGenerator();
4076
- const typeDefinitionString = await generator.generateTypes({
4077
- app,
4078
- connectionId,
4079
- sdk: sdk2
4080
- });
4081
- result.typeDefinitions[manifestKey] = typeDefinitionString;
4082
- onProgress?.({
4083
- type: "type_generated",
4084
- manifestKey,
4085
- sizeBytes: typeDefinitionString.length
4086
- });
4087
- if (!skipWrite && resolvedTypesOutput && result.writtenFiles) {
4088
- const filePath = join(resolvedTypesOutput, `${manifestKey}.d.ts`);
4089
- await writeFile(filePath, typeDefinitionString, "utf8");
4090
- result.writtenFiles[manifestKey] = filePath;
4013
+ let connectionId;
4014
+ if (connections.length > 0) {
4015
+ const matchingConnection = connections.find(
4016
+ (conn) => conn.app_key === app.key
4017
+ );
4018
+ if (matchingConnection) {
4019
+ connectionId = matchingConnection.id;
4020
+ onProgress?.({
4021
+ type: "connection_matched",
4022
+ app: app.key,
4023
+ connectionId: matchingConnection.id,
4024
+ connectionTitle: matchingConnection.title || ""
4025
+ });
4026
+ } else {
4027
+ onProgress?.({
4028
+ type: "connection_not_matched",
4029
+ app: app.key
4030
+ });
4031
+ }
4032
+ }
4033
+ const manifestKey = getManifestKey(app);
4034
+ const generator = new AstTypeGenerator();
4035
+ const typeDefinitionString = await generator.generateTypes({
4036
+ app,
4037
+ connectionId,
4038
+ sdk: sdk3
4039
+ });
4040
+ result.typeDefinitions[manifestKey] = typeDefinitionString;
4091
4041
  onProgress?.({
4092
- type: "file_written",
4042
+ type: "type_generated",
4093
4043
  manifestKey,
4094
- filePath
4044
+ sizeBytes: typeDefinitionString.length
4095
4045
  });
4096
- }
4097
- onProgress?.({
4098
- type: "app_processing_complete",
4099
- app: app.key
4100
- });
4101
- } catch (error) {
4102
- const errorMessage = `Failed to process app ${app.key}: ${error instanceof Error ? error.message : String(error)}`;
4103
- onProgress?.({
4104
- type: "app_processing_error",
4105
- app: app.key,
4106
- error: errorMessage
4107
- });
4108
- if (error instanceof ZapierValidationError) {
4109
- throw error;
4110
- } else {
4111
- throw new ZapierUnknownError(errorMessage, {
4112
- cause: error
4113
- // Works for both Error and non-Error
4046
+ if (!skipWrite && resolvedTypesOutput && result.writtenFiles) {
4047
+ const filePath = join(resolvedTypesOutput, `${manifestKey}.d.ts`);
4048
+ await writeFile(filePath, typeDefinitionString, "utf8");
4049
+ result.writtenFiles[manifestKey] = filePath;
4050
+ onProgress?.({ type: "file_written", manifestKey, filePath });
4051
+ }
4052
+ onProgress?.({ type: "app_processing_complete", app: app.key });
4053
+ } catch (error) {
4054
+ const errorMessage = `Failed to process app ${app.key}: ${error instanceof Error ? error.message : String(error)}`;
4055
+ onProgress?.({
4056
+ type: "app_processing_error",
4057
+ app: app.key,
4058
+ error: errorMessage
4114
4059
  });
4060
+ if (error instanceof ZapierValidationError) {
4061
+ throw error;
4062
+ }
4063
+ throw new ZapierUnknownError(errorMessage, { cause: error });
4115
4064
  }
4116
4065
  }
4066
+ return result;
4117
4067
  }
4118
- return result;
4119
- }, GenerateAppTypesSchema);
4120
- return {
4121
- generateAppTypes,
4122
- context: {
4123
- meta: {
4124
- generateAppTypes: {
4125
- categories: ["utility"],
4126
- inputSchema: GenerateAppTypesSchema
4127
- }
4128
- }
4129
- }
4130
- };
4131
- };
4068
+ })
4069
+ );
4132
4070
  var BuildManifestSchema = z.object({
4133
4071
  apps: z.array(z.string().min(1, "App key cannot be empty")).min(1, "At least one app key is required").describe(
4134
4072
  "One or more app keys to build manifest entries for (e.g., 'slack', 'github', 'trello')"
@@ -4144,86 +4082,80 @@ var BuildManifestSchema = z.object({
4144
4082
  );
4145
4083
 
4146
4084
  // src/plugins/buildManifest/index.ts
4147
- var buildManifestPlugin = (sdk2) => {
4148
- const buildManifest = createFunction(async function buildManifest2(options) {
4149
- const {
4150
- apps: appKeys,
4151
- skipWrite = false,
4152
- configPath,
4153
- onProgress
4154
- } = options;
4155
- onProgress?.({ type: "apps_lookup_start", count: appKeys.length });
4156
- const appsIterable = sdk2.listApps({ apps: appKeys }).items();
4157
- const apps = [];
4158
- for await (const app of appsIterable) {
4159
- apps.push(app);
4160
- onProgress?.({ type: "app_found", app });
4161
- }
4162
- onProgress?.({ type: "apps_lookup_complete", count: apps.length });
4163
- if (apps.length === 0) {
4164
- return {};
4165
- }
4166
- let updatedManifest;
4167
- for (const app of apps) {
4168
- onProgress?.({
4169
- type: "app_processing_start",
4170
- app: app.key,
4171
- slug: app.slug
4172
- });
4173
- try {
4174
- const manifestEntry = createManifestEntry(app);
4175
- onProgress?.({
4176
- type: "manifest_entry_built",
4177
- app: app.key,
4178
- manifestKey: manifestEntry.implementationName,
4179
- version: manifestEntry.version || ""
4180
- });
4181
- const { key: updatedManifestKey, manifest } = await sdk2.context.updateManifestEntry({
4182
- appKey: app.key,
4183
- entry: manifestEntry,
4184
- configPath,
4185
- skipWrite,
4186
- manifest: updatedManifest
4187
- });
4188
- updatedManifest = manifest;
4189
- onProgress?.({
4190
- type: "manifest_updated",
4191
- app: app.key,
4192
- manifestKey: updatedManifestKey,
4193
- version: manifestEntry.version || ""
4194
- });
4195
- onProgress?.({ type: "app_processing_complete", app: app.key });
4196
- } catch (error) {
4197
- const errorMessage = `Failed to process app ${app.key}: ${error instanceof Error ? error.message : String(error)}`;
4085
+ var buildManifestPlugin = definePlugin(
4086
+ (sdk2) => createPluginMethod(sdk2, {
4087
+ name: "buildManifest",
4088
+ categories: ["utility"],
4089
+ // Cast: BuildManifestSchema validates JSON-serializable fields only.
4090
+ // BuildManifestOptions adds an `onProgress` callback that rides through
4091
+ // `createFunction`'s passthrough spread at runtime; this widens TInput
4092
+ // so the handler can read it.
4093
+ inputSchema: BuildManifestSchema,
4094
+ handler: async ({ sdk: sdk3, options }) => {
4095
+ const {
4096
+ apps: appKeys,
4097
+ skipWrite = false,
4098
+ configPath,
4099
+ onProgress
4100
+ } = options;
4101
+ onProgress?.({ type: "apps_lookup_start", count: appKeys.length });
4102
+ const appsIterable = sdk3.listApps({ apps: appKeys }).items();
4103
+ const apps = [];
4104
+ for await (const app of appsIterable) {
4105
+ apps.push(app);
4106
+ onProgress?.({ type: "app_found", app });
4107
+ }
4108
+ onProgress?.({ type: "apps_lookup_complete", count: apps.length });
4109
+ if (apps.length === 0) {
4110
+ return {};
4111
+ }
4112
+ let updatedManifest;
4113
+ for (const app of apps) {
4198
4114
  onProgress?.({
4199
- type: "app_processing_error",
4115
+ type: "app_processing_start",
4200
4116
  app: app.key,
4201
- error: errorMessage
4117
+ slug: app.slug
4202
4118
  });
4203
- if (error instanceof ZapierValidationError) {
4204
- throw error;
4205
- } else {
4206
- throw new ZapierUnknownError(errorMessage, {
4207
- cause: error
4208
- // Works for both Error and non-Error
4119
+ try {
4120
+ const manifestEntry = createManifestEntry(app);
4121
+ onProgress?.({
4122
+ type: "manifest_entry_built",
4123
+ app: app.key,
4124
+ manifestKey: manifestEntry.implementationName,
4125
+ version: manifestEntry.version || ""
4209
4126
  });
4127
+ const { key: updatedManifestKey, manifest } = await sdk3.context.updateManifestEntry({
4128
+ appKey: app.key,
4129
+ entry: manifestEntry,
4130
+ configPath,
4131
+ skipWrite,
4132
+ manifest: updatedManifest
4133
+ });
4134
+ updatedManifest = manifest;
4135
+ onProgress?.({
4136
+ type: "manifest_updated",
4137
+ app: app.key,
4138
+ manifestKey: updatedManifestKey,
4139
+ version: manifestEntry.version || ""
4140
+ });
4141
+ onProgress?.({ type: "app_processing_complete", app: app.key });
4142
+ } catch (error) {
4143
+ const errorMessage = `Failed to process app ${app.key}: ${error instanceof Error ? error.message : String(error)}`;
4144
+ onProgress?.({
4145
+ type: "app_processing_error",
4146
+ app: app.key,
4147
+ error: errorMessage
4148
+ });
4149
+ if (error instanceof ZapierValidationError) {
4150
+ throw error;
4151
+ }
4152
+ throw new ZapierUnknownError(errorMessage, { cause: error });
4210
4153
  }
4211
4154
  }
4155
+ return { manifest: updatedManifest };
4212
4156
  }
4213
- return { manifest: updatedManifest };
4214
- }, BuildManifestSchema);
4215
- return {
4216
- buildManifest,
4217
- context: {
4218
- meta: {
4219
- buildManifest: {
4220
- categories: ["utility"],
4221
- inputSchema: BuildManifestSchema
4222
- }
4223
- }
4224
- }
4225
- };
4226
- };
4157
+ })
4158
+ );
4227
4159
  var FeedbackSchema = z.object({
4228
4160
  feedback: z.string().describe(
4229
4161
  "Your feedback on the Zapier SDK. Describe what worked well, what was frustrating, or any suggestions."
@@ -4257,37 +4189,31 @@ async function postWithRetry({
4257
4189
  }
4258
4190
  return response;
4259
4191
  }
4260
- var feedbackPlugin = (sdk2) => {
4261
- const debug = sdk2.context.options?.debug;
4262
- const feedbackWithSdk = createFunction(async function feedback(options) {
4263
- const user = await getLoggedInUser();
4264
- const body = JSON.stringify({
4265
- email: user.email,
4266
- customuser_id: user.customUserId,
4267
- feedback: options.feedback
4268
- });
4269
- const response = await postWithRetry({ body, attemptsLeft: MAX_RETRIES });
4270
- if (debug) {
4271
- const text = await response.text();
4272
- console.error("[debug] Webhook response:", text);
4273
- }
4274
- return "Thank you for your feedback!";
4275
- }, FeedbackSchema);
4276
- return {
4277
- feedback: feedbackWithSdk,
4278
- context: {
4279
- meta: {
4280
- feedback: {
4281
- categories: ["utility"],
4282
- inputSchema: FeedbackSchema,
4283
- resolvers: {
4284
- feedback: feedbackResolver
4285
- }
4286
- }
4192
+ var feedbackPlugin = definePlugin(
4193
+ (sdk2) => createPluginMethod(sdk2, {
4194
+ name: "feedback",
4195
+ categories: ["utility"],
4196
+ inputSchema: FeedbackSchema,
4197
+ resolvers: { feedback: feedbackResolver },
4198
+ handler: async ({ sdk: sdk3, options }) => {
4199
+ const user = await getLoggedInUser();
4200
+ const body = JSON.stringify({
4201
+ email: user.email,
4202
+ customuser_id: user.customUserId,
4203
+ feedback: options.feedback
4204
+ });
4205
+ const response = await postWithRetry({
4206
+ body,
4207
+ attemptsLeft: MAX_RETRIES
4208
+ });
4209
+ if (sdk3.context.options?.debug) {
4210
+ const text = await response.text();
4211
+ console.error("[debug] Webhook response:", text);
4287
4212
  }
4213
+ return "Thank you for your feedback!";
4288
4214
  }
4289
- };
4290
- };
4215
+ })
4216
+ );
4291
4217
  var CurlSchema = z.object({
4292
4218
  url: z.string().describe("Request URL"),
4293
4219
  request: z.enum(["GET", "POST", "PUT", "DELETE", "PATCH", "HEAD", "OPTIONS"]).optional().describe("HTTP method (defaults to GET, or POST if data is provided)"),
@@ -4463,7 +4389,7 @@ async function buildFormData(formArgs, formStringArgs) {
4463
4389
  }
4464
4390
 
4465
4391
  // src/plugins/curl/index.ts
4466
- var curlPlugin = (sdk2) => {
4392
+ var curlPlugin = definePlugin((sdk2) => {
4467
4393
  async function curl(options) {
4468
4394
  const {
4469
4395
  url: rawUrl,
@@ -4706,30 +4632,25 @@ ${Array.from(
4706
4632
  }
4707
4633
  }
4708
4634
  };
4709
- };
4710
-
4711
- // src/plugins/cliOverrides/index.ts
4712
- var cliOverridesPlugin = (sdk2) => {
4713
- if (!sdk2.context.meta.fetch) {
4714
- return { context: { meta: {} } };
4715
- }
4716
- return {
4717
- context: {
4718
- meta: {
4719
- fetch: {
4720
- ...sdk2.context.meta.fetch,
4721
- categories: [
4722
- ...sdk2.context.meta.fetch.categories || [],
4723
- "deprecated"
4724
- ],
4725
- deprecation: {
4726
- message: "This command is deprecated and will be removed soon. Use `curl` instead. Learn more: https://docs.zapier.com/sdk/cli-reference#curl"
4727
- }
4635
+ });
4636
+ var cliOverridesPlugin = definePlugin(
4637
+ (sdk2) => {
4638
+ const meta = {};
4639
+ if (sdk2.context.meta.fetch) {
4640
+ meta.fetch = {
4641
+ ...sdk2.context.meta.fetch,
4642
+ categories: [
4643
+ ...sdk2.context.meta.fetch.categories || [],
4644
+ "deprecated"
4645
+ ],
4646
+ deprecation: {
4647
+ message: "This command is deprecated and will be removed soon. Use `curl` instead. Learn more: https://docs.zapier.com/sdk/cli-reference#curl"
4728
4648
  }
4729
- }
4649
+ };
4730
4650
  }
4731
- };
4732
- };
4651
+ return { context: { meta } };
4652
+ }
4653
+ );
4733
4654
  var TEMPLATES = ["basic"];
4734
4655
  var InitSchema = z.object({
4735
4656
  projectName: z.string().min(1).describe("Name of the project directory to create"),
@@ -5168,71 +5089,65 @@ function displaySummaryAndNextSteps({
5168
5089
  }
5169
5090
 
5170
5091
  // src/plugins/init/index.ts
5171
- var initPlugin = () => {
5172
- const init = createFunction(async function init2(options) {
5173
- const { projectName: rawName, skipPrompts = false } = options;
5174
- const cwd = process.cwd();
5175
- const { projectName, projectDir } = validateInitOptions({ rawName, cwd });
5176
- const displayHooks = createConsoleDisplayHooks();
5177
- const packageManagerInfo = detectPackageManager(cwd);
5178
- if (packageManagerInfo.name === "unknown") {
5179
- displayHooks.onWarn(
5180
- "Could not detect package manager, defaulting to npm."
5181
- );
5182
- }
5183
- const packageManager = packageManagerInfo.name === "unknown" ? "npm" : packageManagerInfo.name;
5184
- const steps = getInitSteps({
5185
- projectDir,
5186
- projectName,
5187
- packageManager,
5188
- displayHooks
5189
- });
5190
- const completedSetupStepIds = [];
5191
- for (let i = 0; i < steps.length; i++) {
5192
- const step = steps[i];
5193
- const succeeded = await withInterruptCleanup(
5194
- step.cleanup,
5195
- () => runStep({
5196
- step,
5197
- stepNumber: i + 1,
5198
- totalSteps: steps.length,
5199
- skipPrompts,
5200
- displayHooks
5201
- })
5202
- );
5203
- if (!succeeded) break;
5204
- completedSetupStepIds.push(step.id);
5205
- }
5206
- if (completedSetupStepIds.length === 0) {
5207
- throw new ZapierCliExitError(
5208
- "Project setup failed \u2014 no steps completed."
5209
- );
5210
- }
5211
- displaySummaryAndNextSteps({
5212
- projectName,
5213
- steps,
5214
- completedSetupStepIds,
5215
- packageManager
5216
- });
5217
- }, InitSchema);
5218
- return {
5219
- init,
5220
- context: {
5221
- meta: {
5222
- init: {
5223
- categories: ["utility"],
5224
- inputSchema: InitSchema,
5225
- supportsJsonOutput: false
5226
- }
5092
+ var initPlugin = definePlugin(
5093
+ (sdk2) => createPluginMethod(sdk2, {
5094
+ name: "init",
5095
+ categories: ["utility"],
5096
+ inputSchema: InitSchema,
5097
+ supportsJsonOutput: false,
5098
+ handler: async ({ options }) => {
5099
+ const { projectName: rawName, skipPrompts = false } = options;
5100
+ const cwd = process.cwd();
5101
+ const { projectName, projectDir } = validateInitOptions({ rawName, cwd });
5102
+ const displayHooks = createConsoleDisplayHooks();
5103
+ const packageManagerInfo = detectPackageManager(cwd);
5104
+ if (packageManagerInfo.name === "unknown") {
5105
+ displayHooks.onWarn(
5106
+ "Could not detect package manager, defaulting to npm."
5107
+ );
5108
+ }
5109
+ const packageManager = packageManagerInfo.name === "unknown" ? "npm" : packageManagerInfo.name;
5110
+ const steps = getInitSteps({
5111
+ projectDir,
5112
+ projectName,
5113
+ packageManager,
5114
+ displayHooks
5115
+ });
5116
+ const completedSetupStepIds = [];
5117
+ for (let i = 0; i < steps.length; i++) {
5118
+ const step = steps[i];
5119
+ const succeeded = await withInterruptCleanup(
5120
+ step.cleanup,
5121
+ () => runStep({
5122
+ step,
5123
+ stepNumber: i + 1,
5124
+ totalSteps: steps.length,
5125
+ skipPrompts,
5126
+ displayHooks
5127
+ })
5128
+ );
5129
+ if (!succeeded) break;
5130
+ completedSetupStepIds.push(step.id);
5227
5131
  }
5132
+ if (completedSetupStepIds.length === 0) {
5133
+ throw new ZapierCliExitError(
5134
+ "Project setup failed \u2014 no steps completed."
5135
+ );
5136
+ }
5137
+ displaySummaryAndNextSteps({
5138
+ projectName,
5139
+ steps,
5140
+ completedSetupStepIds,
5141
+ packageManager
5142
+ });
5228
5143
  }
5229
- };
5230
- };
5144
+ })
5145
+ );
5231
5146
 
5232
5147
  // package.json with { type: 'json' }
5233
5148
  var package_default2 = {
5234
5149
  name: "@zapier/zapier-sdk-cli",
5235
- version: "0.43.0"};
5150
+ version: "0.43.1"};
5236
5151
 
5237
5152
  // src/sdk.ts
5238
5153
  injectCliLogin(login_exports);