@zapier/zapier-sdk-cli 0.6.3 → 0.6.5

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 (95) hide show
  1. package/CHANGELOG.md +15 -0
  2. package/README.md +115 -12
  3. package/bin/{zapier-sdk.js → zapier-sdk.mjs} +1 -1
  4. package/dist/cli.cjs +1715 -0
  5. package/dist/cli.d.mts +1 -0
  6. package/dist/cli.d.ts +1 -0
  7. package/dist/{cli.js → cli.mjs} +221 -469
  8. package/dist/index.cjs +770 -0
  9. package/dist/index.d.mts +12 -0
  10. package/dist/index.d.ts +12 -0
  11. package/dist/index.mjs +739 -0
  12. package/dist/package.json +67 -0
  13. package/dist/src/cli.js +8 -14
  14. package/dist/src/index.d.ts +1 -0
  15. package/dist/src/index.js +1 -1
  16. package/dist/src/plugins/bundleCode/index.d.ts +15 -0
  17. package/dist/src/{commands/bundle-code → plugins/bundleCode}/index.js +19 -1
  18. package/dist/src/{commands/bundle-code → plugins/bundleCode}/schemas.d.ts +8 -8
  19. package/dist/src/{commands/bundle-code → plugins/bundleCode}/schemas.js +4 -4
  20. package/dist/src/plugins/generateTypes/index.d.ts +21 -0
  21. package/dist/src/{commands/generate-types → plugins/generateTypes}/index.js +18 -0
  22. package/dist/src/{commands/generate-types → plugins/generateTypes}/schemas.d.ts +0 -3
  23. package/dist/src/{commands/generate-types → plugins/generateTypes}/schemas.js +1 -2
  24. package/dist/src/plugins/getConfigPath/index.d.ts +15 -0
  25. package/dist/src/plugins/getConfigPath/index.js +19 -0
  26. package/dist/src/plugins/getConfigPath/schemas.d.ts +3 -0
  27. package/dist/src/plugins/getConfigPath/schemas.js +5 -0
  28. package/dist/src/plugins/index.d.ts +6 -0
  29. package/dist/src/plugins/index.js +6 -0
  30. package/dist/src/plugins/login/index.d.ts +15 -0
  31. package/dist/src/plugins/login/index.js +26 -0
  32. package/dist/src/plugins/login/schemas.d.ts +9 -0
  33. package/dist/src/plugins/login/schemas.js +10 -0
  34. package/dist/src/plugins/logout/index.d.ts +15 -0
  35. package/dist/src/plugins/logout/index.js +18 -0
  36. package/dist/src/plugins/logout/schemas.d.ts +3 -0
  37. package/dist/src/plugins/logout/schemas.js +5 -0
  38. package/dist/src/plugins/mcp/index.d.ts +15 -0
  39. package/dist/src/plugins/mcp/index.js +24 -0
  40. package/dist/src/plugins/mcp/schemas.d.ts +9 -0
  41. package/dist/src/plugins/mcp/schemas.js +10 -0
  42. package/dist/src/sdk.d.ts +9 -0
  43. package/dist/src/sdk.js +22 -0
  44. package/dist/src/utils/cli-generator.js +12 -8
  45. package/dist/src/utils/schema-formatter.d.ts +1 -1
  46. package/dist/src/utils/schema-formatter.js +8 -8
  47. package/dist/tsconfig.tsbuildinfo +1 -1
  48. package/package.json +19 -8
  49. package/src/cli.ts +8 -21
  50. package/src/index.ts +2 -0
  51. package/src/{commands/bundle-code → plugins/bundleCode}/index.ts +39 -2
  52. package/src/{commands/bundle-code → plugins/bundleCode}/schemas.ts +4 -4
  53. package/src/{commands/generate-types → plugins/generateTypes}/index.ts +56 -3
  54. package/src/{commands/generate-types → plugins/generateTypes}/schemas.ts +0 -4
  55. package/src/plugins/getConfigPath/index.ts +42 -0
  56. package/src/plugins/getConfigPath/schemas.ts +8 -0
  57. package/src/plugins/index.ts +6 -0
  58. package/src/plugins/login/index.ts +48 -0
  59. package/src/plugins/login/schemas.ts +13 -0
  60. package/src/plugins/logout/index.ts +37 -0
  61. package/src/plugins/logout/schemas.ts +8 -0
  62. package/src/plugins/mcp/index.ts +43 -0
  63. package/src/plugins/mcp/schemas.ts +13 -0
  64. package/src/sdk.ts +43 -0
  65. package/src/utils/cli-generator.test.ts +93 -0
  66. package/src/utils/cli-generator.ts +19 -9
  67. package/src/utils/schema-formatter.ts +13 -7
  68. package/tsconfig.build.json +15 -3
  69. package/tsconfig.json +2 -2
  70. package/tsup.config.ts +10 -4
  71. package/bin/zsdk.js +0 -4
  72. package/dist/index.js +0 -0
  73. package/dist/src/commands/bundle-code/cli.d.ts +0 -2
  74. package/dist/src/commands/bundle-code/cli.js +0 -77
  75. package/dist/src/commands/bundle-code/index.d.ts +0 -5
  76. package/dist/src/commands/configPath.d.ts +0 -2
  77. package/dist/src/commands/configPath.js +0 -9
  78. package/dist/src/commands/generate-types/cli.d.ts +0 -2
  79. package/dist/src/commands/generate-types/cli.js +0 -84
  80. package/dist/src/commands/generate-types/index.d.ts +0 -8
  81. package/dist/src/commands/index.d.ts +0 -6
  82. package/dist/src/commands/index.js +0 -6
  83. package/dist/src/commands/login.d.ts +0 -2
  84. package/dist/src/commands/login.js +0 -25
  85. package/dist/src/commands/logout.d.ts +0 -2
  86. package/dist/src/commands/logout.js +0 -16
  87. package/dist/src/commands/mcp.d.ts +0 -2
  88. package/dist/src/commands/mcp.js +0 -11
  89. package/src/commands/bundle-code/cli.ts +0 -118
  90. package/src/commands/configPath.ts +0 -10
  91. package/src/commands/generate-types/cli.ts +0 -126
  92. package/src/commands/index.ts +0 -6
  93. package/src/commands/login.ts +0 -34
  94. package/src/commands/logout.ts +0 -19
  95. package/src/commands/mcp.ts +0 -14
@@ -0,0 +1,67 @@
1
+ {
2
+ "name": "@zapier/zapier-sdk-cli",
3
+ "version": "0.6.5",
4
+ "description": "Command line interface for Zapier SDK",
5
+ "main": "dist/index.cjs",
6
+ "module": "dist/index.mjs",
7
+ "types": "dist/index.d.ts",
8
+ "exports": {
9
+ ".": {
10
+ "require": {
11
+ "types": "./dist/index.d.ts",
12
+ "default": "./dist/index.cjs"
13
+ },
14
+ "import": {
15
+ "types": "./dist/index.d.mts",
16
+ "default": "./dist/index.mjs"
17
+ }
18
+ }
19
+ },
20
+ "bin": {
21
+ "zapier-sdk": "./bin/zapier-sdk.mjs"
22
+ },
23
+ "scripts": {
24
+ "test": "vitest",
25
+ "build": "tsup",
26
+ "clean": "rm -rf dist",
27
+ "rebuild": "pnpm clean && pnpm build",
28
+ "dev": "tsx src/cli.ts",
29
+ "typecheck": "tsc --project tsconfig.build.json --noEmit",
30
+ "prepublishOnly": "node ../../scripts/check-version.js"
31
+ },
32
+ "keywords": [
33
+ "zapier",
34
+ "cli",
35
+ "sdk"
36
+ ],
37
+ "author": "",
38
+ "license": "ISC",
39
+ "publishConfig": {
40
+ "access": "restricted"
41
+ },
42
+ "dependencies": {
43
+ "@zapier/zapier-sdk": "workspace:*",
44
+ "@zapier/zapier-sdk-cli-login": "workspace:*",
45
+ "@zapier/zapier-sdk-mcp": "workspace:*",
46
+ "chalk": "^5.3.0",
47
+ "cli-table3": "^0.6.5",
48
+ "commander": "^12.0.0",
49
+ "esbuild": "^0.25.5",
50
+ "express": "^5.1.0",
51
+ "inquirer": "^12.6.3",
52
+ "jsonwebtoken": "^9.0.2",
53
+ "open": "^10.2.0",
54
+ "ora": "^8.2.0",
55
+ "pkce-challenge": "^5.0.0",
56
+ "zod": "^3.25.67"
57
+ },
58
+ "devDependencies": {
59
+ "@types/express": "^5.0.3",
60
+ "@types/inquirer": "^9.0.8",
61
+ "@types/jsonwebtoken": "^9.0.10",
62
+ "@types/node": "^24.0.1",
63
+ "tsup": "^8.5.0",
64
+ "typescript": "^5.8.3",
65
+ "vitest": "^3.2.3"
66
+ }
67
+ }
package/dist/src/cli.js CHANGED
@@ -1,28 +1,22 @@
1
1
  #!/usr/bin/env node
2
2
  import { Command } from "commander";
3
- import { createZapierSdk } from "@zapier/zapier-sdk";
4
3
  import { generateCliCommands } from "./utils/cli-generator";
5
- import { createLoginCommand, createLogoutCommand, createConfigPathCommand, createGenerateTypesCommand, createBundleCodeCommand, createMcpCommand, } from "./commands/index";
4
+ import { createZapierCliSdk } from "./sdk";
5
+ import packageJson from "../package.json" with { type: "json" };
6
6
  const program = new Command();
7
7
  program
8
8
  .name("zapier-sdk")
9
9
  .description("CLI for Zapier SDK")
10
- .version("1.0.0")
10
+ .version(packageJson.version, "-v, --version", "display version number")
11
11
  .option("--debug", "Enable debug logging");
12
12
  // Check for debug flag early
13
13
  const isDebugMode = process.env.DEBUG === "true" || process.argv.includes("--debug");
14
- // Create SDK instance - automatically handles token resolution
15
- const sdk = createZapierSdk({
14
+ // Create CLI SDK instance with all plugins
15
+ const sdk = createZapierCliSdk({
16
16
  debug: isDebugMode,
17
17
  });
18
- // Add auth commands before generating SDK commands
19
- program.addCommand(createLoginCommand());
20
- program.addCommand(createLogoutCommand());
21
- // Generate CLI commands from SDK schemas
18
+ // Auth commands now handled by plugins
19
+ // Generate CLI commands from SDK schemas (including CLI plugins)
22
20
  generateCliCommands(program, sdk);
23
- // Add build-time commands (CLI-specific, not from SDK)
24
- program.addCommand(createGenerateTypesCommand());
25
- program.addCommand(createBundleCodeCommand());
26
- program.addCommand(createConfigPathCommand());
27
- program.addCommand(createMcpCommand());
21
+ // MCP command now handled by plugin
28
22
  program.parse();
@@ -0,0 +1 @@
1
+ export { createZapierCliSdk, type ZapierCliSdkOptions } from "./sdk";
package/dist/src/index.js CHANGED
@@ -1,3 +1,3 @@
1
- "use strict";
2
1
  // Main exports for the CLI package
2
+ export { createZapierCliSdk } from "./sdk";
3
3
  // All CLI functionality is now schema-driven via generateCLICommands
@@ -0,0 +1,15 @@
1
+ import type { Plugin } from "@zapier/zapier-sdk";
2
+ import { BundleCodeSchema, type BundleCodeOptions } from "./schemas";
3
+ export interface BundleCodePluginProvides {
4
+ bundleCode: (options: BundleCodeOptions) => Promise<string>;
5
+ context: {
6
+ meta: {
7
+ bundleCode: {
8
+ inputSchema: typeof BundleCodeSchema;
9
+ };
10
+ };
11
+ };
12
+ }
13
+ export declare const bundleCodePlugin: Plugin<{}, // requires no existing SDK methods
14
+ {}, // requires no context
15
+ BundleCodePluginProvides>;
@@ -1,6 +1,24 @@
1
+ import { BundleCodeSchema } from "./schemas";
2
+ import { createFunction } from "@zapier/zapier-sdk";
1
3
  import { buildSync } from "esbuild";
2
4
  import * as fs from "fs";
3
5
  import * as path from "path";
6
+ export const bundleCodePlugin = () => {
7
+ const bundleCodeWithSdk = createFunction(async function bundleCodeWithSdk(options) {
8
+ return await bundleCode(options);
9
+ }, BundleCodeSchema);
10
+ return {
11
+ bundleCode: bundleCodeWithSdk,
12
+ context: {
13
+ meta: {
14
+ bundleCode: {
15
+ categories: ["utility"],
16
+ inputSchema: BundleCodeSchema,
17
+ },
18
+ },
19
+ },
20
+ };
21
+ };
4
22
  class ZapierBundleError extends Error {
5
23
  constructor(message, details, originalError) {
6
24
  super(message);
@@ -13,7 +31,7 @@ class ZapierBundleError extends Error {
13
31
  /**
14
32
  * Bundle TypeScript code into executable JavaScript (CLI version)
15
33
  */
16
- export async function bundleCode(options) {
34
+ async function bundleCode(options) {
17
35
  const { input, output, target = "es2020", cjs = false, minify = false, string: returnString = false, } = options;
18
36
  // Resolve input path
19
37
  const resolvedInput = path.resolve(process.cwd(), input);
@@ -2,17 +2,17 @@ import { z } from "zod";
2
2
  export declare const BundleCodeSchema: z.ZodObject<{
3
3
  input: z.ZodString;
4
4
  output: z.ZodOptional<z.ZodString>;
5
- string: z.ZodDefault<z.ZodBoolean>;
6
- minify: z.ZodDefault<z.ZodBoolean>;
7
- target: z.ZodDefault<z.ZodString>;
8
- cjs: z.ZodDefault<z.ZodBoolean>;
5
+ string: z.ZodOptional<z.ZodBoolean>;
6
+ minify: z.ZodOptional<z.ZodBoolean>;
7
+ target: z.ZodOptional<z.ZodString>;
8
+ cjs: z.ZodOptional<z.ZodBoolean>;
9
9
  }, "strip", z.ZodTypeAny, {
10
- string: boolean;
11
10
  input: string;
12
- minify: boolean;
13
- target: string;
14
- cjs: boolean;
11
+ string?: boolean | undefined;
15
12
  output?: string | undefined;
13
+ minify?: boolean | undefined;
14
+ target?: string | undefined;
15
+ cjs?: boolean | undefined;
16
16
  }, {
17
17
  input: string;
18
18
  string?: boolean | undefined;
@@ -7,13 +7,13 @@ export const BundleCodeSchema = z
7
7
  output: OutputPropertySchema.optional().describe("Output file path (defaults to input with .js extension)"),
8
8
  string: z
9
9
  .boolean()
10
- .default(false)
10
+ .optional()
11
11
  .describe("Return bundled code as string instead of writing to file"),
12
- minify: z.boolean().default(false).describe("Minify the bundled output"),
13
- target: z.string().default("es2017").describe("ECMAScript target version"),
12
+ minify: z.boolean().optional().describe("Minify the bundled output"),
13
+ target: z.string().optional().describe("ECMAScript target version"),
14
14
  cjs: z
15
15
  .boolean()
16
- .default(false)
16
+ .optional()
17
17
  .describe("Output CommonJS format instead of ESM"),
18
18
  })
19
19
  .describe("Bundle TypeScript code into executable JavaScript");
@@ -0,0 +1,21 @@
1
+ import type { Plugin, GetSdkType, ListActionsPluginProvides, ListInputFieldsPluginProvides, ManifestPluginProvides } from "@zapier/zapier-sdk";
2
+ import { GenerateTypesSchema, type GenerateTypesOptions } from "./schemas";
3
+ export interface GenerateTypesPluginProvides {
4
+ generateTypes: (options: GenerateTypesOptions) => Promise<string>;
5
+ context: {
6
+ meta: {
7
+ generateTypes: {
8
+ inputSchema: typeof GenerateTypesSchema;
9
+ };
10
+ };
11
+ };
12
+ }
13
+ export declare const generateTypesPlugin: Plugin<GetSdkType<ListActionsPluginProvides & ListInputFieldsPluginProvides & ManifestPluginProvides>, // requires these SDK methods
14
+ {}, // requires no context
15
+ GenerateTypesPluginProvides>;
16
+ /**
17
+ * Generate TypeScript types for a specific app (CLI version)
18
+ */
19
+ export declare function generateTypes(options: GenerateTypesOptions & {
20
+ sdk: GetSdkType<ListActionsPluginProvides & ListInputFieldsPluginProvides & ManifestPluginProvides>;
21
+ }): Promise<string>;
@@ -1,5 +1,23 @@
1
+ import { GenerateTypesSchema } from "./schemas";
2
+ import { createFunction } from "@zapier/zapier-sdk";
1
3
  import * as fs from "fs";
2
4
  import * as path from "path";
5
+ export const generateTypesPlugin = ({ sdk }) => {
6
+ const generateTypesWithSdk = createFunction(async function generateTypesWithSdk(options) {
7
+ return await generateTypes({ ...options, sdk });
8
+ }, GenerateTypesSchema);
9
+ return {
10
+ generateTypes: generateTypesWithSdk,
11
+ context: {
12
+ meta: {
13
+ generateTypes: {
14
+ categories: ["utility"],
15
+ inputSchema: GenerateTypesSchema,
16
+ },
17
+ },
18
+ },
19
+ };
20
+ };
3
21
  /**
4
22
  * Generate the fetch method signature for app proxies
5
23
  */
@@ -3,11 +3,9 @@ export declare const GenerateTypesSchema: z.ZodObject<{
3
3
  appKey: z.ZodString;
4
4
  authenticationId: z.ZodOptional<z.ZodNumber>;
5
5
  output: z.ZodOptional<z.ZodString>;
6
- debug: z.ZodDefault<z.ZodBoolean>;
7
6
  lockFilePath: z.ZodOptional<z.ZodString>;
8
7
  }, "strip", z.ZodTypeAny, {
9
8
  appKey: string;
10
- debug: boolean;
11
9
  authenticationId?: number | undefined;
12
10
  output?: string | undefined;
13
11
  lockFilePath?: string | undefined;
@@ -15,7 +13,6 @@ export declare const GenerateTypesSchema: z.ZodObject<{
15
13
  appKey: string;
16
14
  authenticationId?: number | undefined;
17
15
  output?: string | undefined;
18
- debug?: boolean | undefined;
19
16
  lockFilePath?: string | undefined;
20
17
  }>;
21
18
  export type GenerateTypesOptions = z.infer<typeof GenerateTypesSchema>;
@@ -1,12 +1,11 @@
1
1
  import { z } from "zod";
2
- import { AppKeyPropertySchema, AuthenticationIdPropertySchema, OutputPropertySchema, DebugPropertySchema, } from "@zapier/zapier-sdk";
2
+ import { AppKeyPropertySchema, AuthenticationIdPropertySchema, OutputPropertySchema, } from "@zapier/zapier-sdk";
3
3
  // Generate types schema - mirrors the original from SDK but for CLI use
4
4
  export const GenerateTypesSchema = z
5
5
  .object({
6
6
  appKey: AppKeyPropertySchema.describe("App key to generate SDK code for"),
7
7
  authenticationId: AuthenticationIdPropertySchema.optional(),
8
8
  output: OutputPropertySchema.optional().describe("Output file path (defaults to generated/<appKey>.ts)"),
9
- debug: DebugPropertySchema.describe("Enable debug logging during generation"),
10
9
  lockFilePath: z
11
10
  .string()
12
11
  .optional()
@@ -0,0 +1,15 @@
1
+ import type { Plugin } from "@zapier/zapier-sdk";
2
+ import { GetConfigPathSchema, type GetConfigPathOptions } from "./schemas";
3
+ export interface GetConfigPathPluginProvides {
4
+ getConfigPath: (options?: GetConfigPathOptions) => Promise<string>;
5
+ context: {
6
+ meta: {
7
+ getConfigPath: {
8
+ inputSchema: typeof GetConfigPathSchema;
9
+ };
10
+ };
11
+ };
12
+ }
13
+ export declare const getConfigPathPlugin: Plugin<{}, // requires no existing SDK methods
14
+ {}, // requires no context
15
+ GetConfigPathPluginProvides>;
@@ -0,0 +1,19 @@
1
+ import { GetConfigPathSchema } from "./schemas";
2
+ import { createFunction } from "@zapier/zapier-sdk";
3
+ import { getConfigPath } from "@zapier/zapier-sdk-cli-login";
4
+ export const getConfigPathPlugin = () => {
5
+ const getConfigPathWithSdk = createFunction(async function getConfigPathWithSdk(_options) {
6
+ return getConfigPath();
7
+ }, GetConfigPathSchema);
8
+ return {
9
+ getConfigPath: getConfigPathWithSdk,
10
+ context: {
11
+ meta: {
12
+ getConfigPath: {
13
+ categories: ["utility"],
14
+ inputSchema: GetConfigPathSchema,
15
+ },
16
+ },
17
+ },
18
+ };
19
+ };
@@ -0,0 +1,3 @@
1
+ import { z } from "zod";
2
+ export declare const GetConfigPathSchema: z.ZodObject<{}, "strip", z.ZodTypeAny, {}, {}>;
3
+ export type GetConfigPathOptions = z.infer<typeof GetConfigPathSchema>;
@@ -0,0 +1,5 @@
1
+ import { z } from "zod";
2
+ // Get config path schema - simple command with no parameters
3
+ export const GetConfigPathSchema = z
4
+ .object({})
5
+ .describe("Show the path to the configuration file");
@@ -0,0 +1,6 @@
1
+ export { loginPlugin } from "./login";
2
+ export { logoutPlugin } from "./logout";
3
+ export { mcpPlugin } from "./mcp";
4
+ export { generateTypesPlugin } from "./generateTypes";
5
+ export { bundleCodePlugin } from "./bundleCode";
6
+ export { getConfigPathPlugin } from "./getConfigPath";
@@ -0,0 +1,6 @@
1
+ export { loginPlugin } from "./login";
2
+ export { logoutPlugin } from "./logout";
3
+ export { mcpPlugin } from "./mcp";
4
+ export { generateTypesPlugin } from "./generateTypes";
5
+ export { bundleCodePlugin } from "./bundleCode";
6
+ export { getConfigPathPlugin } from "./getConfigPath";
@@ -0,0 +1,15 @@
1
+ import type { Plugin } from "@zapier/zapier-sdk";
2
+ import { LoginSchema, type LoginOptions } from "./schemas";
3
+ interface LoginPluginProvides {
4
+ login: (options: LoginOptions) => Promise<void>;
5
+ context: {
6
+ meta: {
7
+ login: {
8
+ inputSchema: typeof LoginSchema;
9
+ categories: string[];
10
+ };
11
+ };
12
+ };
13
+ }
14
+ export declare const loginPlugin: Plugin<{}, {}, LoginPluginProvides>;
15
+ export type { LoginPluginProvides };
@@ -0,0 +1,26 @@
1
+ import { createFunction } from "@zapier/zapier-sdk";
2
+ import login from "../../utils/auth/login";
3
+ import { getLoggedInUser } from "@zapier/zapier-sdk-cli-login";
4
+ import { LoginSchema } from "./schemas";
5
+ const loginWithSdk = createFunction(async function loginWithSdk(options) {
6
+ const timeoutSeconds = options.timeout ? parseInt(options.timeout, 10) : 300;
7
+ if (isNaN(timeoutSeconds) || timeoutSeconds <= 0) {
8
+ throw new Error("Timeout must be a positive number");
9
+ }
10
+ await login(timeoutSeconds * 1000); // Convert to milliseconds
11
+ const user = await getLoggedInUser();
12
+ console.log(`✅ Successfully logged in as ${user.email}`);
13
+ // Force immediate exit to prevent hanging (especially in development with tsx)
14
+ setTimeout(() => process.exit(0), 100);
15
+ }, LoginSchema);
16
+ export const loginPlugin = () => ({
17
+ login: loginWithSdk,
18
+ context: {
19
+ meta: {
20
+ login: {
21
+ categories: ["account"],
22
+ inputSchema: LoginSchema,
23
+ },
24
+ },
25
+ },
26
+ });
@@ -0,0 +1,9 @@
1
+ import { z } from "zod";
2
+ export declare const LoginSchema: z.ZodObject<{
3
+ timeout: z.ZodOptional<z.ZodString>;
4
+ }, "strip", z.ZodTypeAny, {
5
+ timeout?: string | undefined;
6
+ }, {
7
+ timeout?: string | undefined;
8
+ }>;
9
+ export type LoginOptions = z.infer<typeof LoginSchema>;
@@ -0,0 +1,10 @@
1
+ import { z } from "zod";
2
+ // Login schema
3
+ export const LoginSchema = z
4
+ .object({
5
+ timeout: z
6
+ .string()
7
+ .optional()
8
+ .describe("Login timeout in seconds (default: 300)"),
9
+ })
10
+ .describe("Log in to Zapier to access your account");
@@ -0,0 +1,15 @@
1
+ import type { Plugin } from "@zapier/zapier-sdk";
2
+ import { LogoutSchema, type LogoutOptions } from "./schemas";
3
+ interface LogoutPluginProvides {
4
+ logout: (options: LogoutOptions) => Promise<void>;
5
+ context: {
6
+ meta: {
7
+ logout: {
8
+ inputSchema: typeof LogoutSchema;
9
+ categories: string[];
10
+ };
11
+ };
12
+ };
13
+ }
14
+ export declare const logoutPlugin: Plugin<{}, {}, LogoutPluginProvides>;
15
+ export type { LogoutPluginProvides };
@@ -0,0 +1,18 @@
1
+ import { createFunction } from "@zapier/zapier-sdk";
2
+ import { logout } from "@zapier/zapier-sdk-cli-login";
3
+ import { LogoutSchema } from "./schemas";
4
+ const logoutWithSdk = createFunction(async function logoutWithSdk(_options) {
5
+ logout();
6
+ console.log("✅ Successfully logged out");
7
+ }, LogoutSchema);
8
+ export const logoutPlugin = () => ({
9
+ logout: logoutWithSdk,
10
+ context: {
11
+ meta: {
12
+ logout: {
13
+ categories: ["account"],
14
+ inputSchema: LogoutSchema,
15
+ },
16
+ },
17
+ },
18
+ });
@@ -0,0 +1,3 @@
1
+ import { z } from "zod";
2
+ export declare const LogoutSchema: z.ZodObject<{}, "strip", z.ZodTypeAny, {}, {}>;
3
+ export type LogoutOptions = z.infer<typeof LogoutSchema>;
@@ -0,0 +1,5 @@
1
+ import { z } from "zod";
2
+ // Logout schema (no parameters needed)
3
+ export const LogoutSchema = z
4
+ .object({})
5
+ .describe("Log out of your Zapier account");
@@ -0,0 +1,15 @@
1
+ import type { Plugin } from "@zapier/zapier-sdk";
2
+ import { McpSchema, type McpOptions } from "./schemas";
3
+ interface McpPluginProvides {
4
+ mcp: (options: McpOptions) => Promise<void>;
5
+ context: {
6
+ meta: {
7
+ mcp: {
8
+ inputSchema: typeof McpSchema;
9
+ categories: string[];
10
+ };
11
+ };
12
+ };
13
+ }
14
+ export declare const mcpPlugin: Plugin<{}, {}, McpPluginProvides>;
15
+ export type { McpPluginProvides };
@@ -0,0 +1,24 @@
1
+ import { createFunction } from "@zapier/zapier-sdk";
2
+ import { startMcpServerAsProcess } from "@zapier/zapier-sdk-mcp";
3
+ import { McpSchema } from "./schemas";
4
+ export const mcpPlugin = ({ context }) => {
5
+ const mcpWithSdk = createFunction(async function mcpWithSdk(options) {
6
+ // Pass through the SDK's debug option to the MCP server
7
+ const mcpOptions = {
8
+ ...options,
9
+ debug: context.options.debug,
10
+ };
11
+ return await startMcpServerAsProcess(mcpOptions);
12
+ }, McpSchema);
13
+ return {
14
+ mcp: mcpWithSdk,
15
+ context: {
16
+ meta: {
17
+ mcp: {
18
+ categories: ["utility"],
19
+ inputSchema: McpSchema,
20
+ },
21
+ },
22
+ },
23
+ };
24
+ };
@@ -0,0 +1,9 @@
1
+ import { z } from "zod";
2
+ export declare const McpSchema: z.ZodObject<{
3
+ port: z.ZodOptional<z.ZodString>;
4
+ }, "strip", z.ZodTypeAny, {
5
+ port?: string | undefined;
6
+ }, {
7
+ port?: string | undefined;
8
+ }>;
9
+ export type McpOptions = z.infer<typeof McpSchema>;
@@ -0,0 +1,10 @@
1
+ import { z } from "zod";
2
+ // MCP server schema
3
+ export const McpSchema = z
4
+ .object({
5
+ port: z
6
+ .string()
7
+ .optional()
8
+ .describe("Port to listen on (for future HTTP transport)"),
9
+ })
10
+ .describe("Start MCP server for Zapier SDK");
@@ -0,0 +1,9 @@
1
+ import { type ZapierSdk } from "@zapier/zapier-sdk";
2
+ export interface ZapierCliSdkOptions {
3
+ debug?: boolean;
4
+ }
5
+ /**
6
+ * Create a Zapier SDK instance configured specifically for the CLI
7
+ * Includes all CLI-specific plugins in addition to the standard SDK functionality
8
+ */
9
+ export declare function createZapierCliSdk(options?: ZapierCliSdkOptions): ZapierSdk;
@@ -0,0 +1,22 @@
1
+ import { createZapierSdkWithoutRegistry, registryPlugin, } from "@zapier/zapier-sdk";
2
+ import { loginPlugin, logoutPlugin, mcpPlugin, generateTypesPlugin, bundleCodePlugin, getConfigPathPlugin, } from "./plugins/index";
3
+ /**
4
+ * Create a Zapier SDK instance configured specifically for the CLI
5
+ * Includes all CLI-specific plugins in addition to the standard SDK functionality
6
+ */
7
+ export function createZapierCliSdk(options = {}) {
8
+ // Create SDK instance without registry
9
+ let sdk = createZapierSdkWithoutRegistry({
10
+ debug: options.debug,
11
+ });
12
+ // Add CLI-specific plugins before registry
13
+ sdk = sdk.addPlugin(generateTypesPlugin);
14
+ sdk = sdk.addPlugin(bundleCodePlugin);
15
+ sdk = sdk.addPlugin(getConfigPathPlugin);
16
+ sdk = sdk.addPlugin(mcpPlugin);
17
+ sdk = sdk.addPlugin(loginPlugin);
18
+ sdk = sdk.addPlugin(logoutPlugin);
19
+ // Add registry plugin to finalize SDK
20
+ const finalSdk = sdk.addPlugin(registryPlugin);
21
+ return finalSdk;
22
+ }
@@ -9,6 +9,10 @@ import inquirer from "inquirer";
9
9
  // JSON Formatting
10
10
  // ============================================================================
11
11
  function formatJsonOutput(data) {
12
+ // Don't print anything for undefined results (commands that just perform actions)
13
+ if (data === undefined) {
14
+ return;
15
+ }
12
16
  // Show success message for action results
13
17
  if (data &&
14
18
  typeof data === "object" &&
@@ -199,9 +203,9 @@ function createCommandConfig(cliCommandName, sdkMethodName, schema, sdk) {
199
203
  hasPaginationParams &&
200
204
  !shouldUseJson &&
201
205
  !hasUserSpecifiedMaxItems) {
202
- // Get the async iterator directly from the SDK method call
206
+ // Get the async iterable directly from the SDK method call (don't await it! that breaks the next page behavior)
203
207
  const sdkObj = sdk;
204
- const sdkIterator = await sdkObj[sdkMethodName](resolvedParams);
208
+ const sdkIterator = sdkObj[sdkMethodName](resolvedParams);
205
209
  await handlePaginatedListWithAsyncIteration(sdkMethodName, sdkIterator, schema);
206
210
  }
207
211
  else {
@@ -387,10 +391,10 @@ async function handlePaginatedListWithAsyncIteration(sdkMethodName, sdkResult, s
387
391
  }
388
392
  // Format and display items using schema
389
393
  if (schema) {
390
- formatItemsFromSchema(schema, items);
394
+ formatItemsFromSchema(schema, items, totalShown);
391
395
  }
392
396
  else {
393
- formatItemsGeneric(items);
397
+ formatItemsGeneric(items, totalShown);
394
398
  }
395
399
  totalShown += items.length;
396
400
  console.log(chalk.green(`\n✅ Showing ${totalShown} ${itemName} (page ${pageCount})`));
@@ -424,10 +428,10 @@ async function handlePaginatedListWithAsyncIteration(sdkMethodName, sdkResult, s
424
428
  return;
425
429
  }
426
430
  if (schema) {
427
- formatItemsFromSchema(schema, items);
431
+ formatItemsFromSchema(schema, items, 0);
428
432
  }
429
433
  else {
430
- formatItemsGeneric(items);
434
+ formatItemsGeneric(items, 0);
431
435
  }
432
436
  console.log(chalk.green(`\n✅ Showing ${items.length} ${itemName}`));
433
437
  }
@@ -472,12 +476,12 @@ function formatNonPaginatedResults(result, requestedMaxItems, userSpecifiedMaxIt
472
476
  console.log(chalk.gray(`\n📄 All available ${itemName} shown`));
473
477
  }
474
478
  }
475
- function formatItemsGeneric(items) {
479
+ function formatItemsGeneric(items, startingNumber = 0) {
476
480
  // Fallback formatting for items without schema metadata
477
481
  items.forEach((item, index) => {
478
482
  const itemObj = item;
479
483
  const name = itemObj?.name || itemObj?.key || itemObj?.id || "Item";
480
- console.log(`${chalk.gray(`${index + 1}.`)} ${chalk.cyan(String(name))}`);
484
+ console.log(`${chalk.gray(`${startingNumber + index + 1}.`)} ${chalk.cyan(String(name))}`);
481
485
  if (itemObj?.description) {
482
486
  console.log(` ${chalk.dim(String(itemObj.description))}`);
483
487
  }
@@ -1,2 +1,2 @@
1
1
  import { z } from "zod";
2
- export declare function formatItemsFromSchema(inputSchema: z.ZodType, items: unknown[]): void;
2
+ export declare function formatItemsFromSchema(inputSchema: z.ZodType, items: unknown[], startingNumber?: number): void;