@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
@@ -1,126 +0,0 @@
1
- import { Command } from "commander";
2
- import { createZapierSdk } from "@zapier/zapier-sdk";
3
- import { GenerateTypesSchema } from "./schemas";
4
- import { generateTypes } from "./index";
5
- import chalk from "chalk";
6
- import { SchemaParameterResolver } from "../../utils/parameter-resolver";
7
- import {
8
- analyzeZodSchema,
9
- convertCliArgsToSdkParams,
10
- } from "../../utils/cli-generator-utils";
11
-
12
- export function createGenerateTypesCommand(): Command {
13
- const parameters = analyzeZodSchema(GenerateTypesSchema);
14
- const description =
15
- GenerateTypesSchema.description ||
16
- "Generate TypeScript SDK types for a specific app";
17
-
18
- const command = new Command("generate-types").description(description);
19
-
20
- // Add parameters to command using same logic as CLI generator
21
- parameters.forEach((param) => {
22
- // Convert camelCase to kebab-case for CLI display
23
- const kebabName = param.name.replace(/([A-Z])/g, "-$1").toLowerCase();
24
-
25
- if (param.hasResolver && param.required) {
26
- // Required parameters with resolvers become optional positional arguments (resolver handles prompting)
27
- command.argument(
28
- `[${kebabName}]`,
29
- param.description || `${kebabName} parameter`,
30
- );
31
- } else if (param.required) {
32
- // Required parameters without resolvers become required positional arguments
33
- command.argument(
34
- `<${kebabName}>`,
35
- param.description || `${kebabName} parameter`,
36
- );
37
- } else if (param.isPositional) {
38
- // Optional parameters marked as positional become optional positional arguments
39
- command.argument(
40
- `[${kebabName}]`,
41
- param.description || `${kebabName} parameter`,
42
- );
43
- } else {
44
- // Optional parameters become flags (whether they have resolvers or not)
45
- const flags = [`--${kebabName}`];
46
-
47
- if (param.type === "boolean") {
48
- command.option(flags.join(", "), param.description);
49
- } else {
50
- const flagSignature = flags.join(", ") + ` <${param.type}>`;
51
- command.option(
52
- flagSignature,
53
- param.description || "",
54
- param.default as string | boolean | string[] | undefined,
55
- );
56
- }
57
- }
58
- });
59
-
60
- // Add formatting options like other commands
61
- command.option("--json", "Output raw JSON instead of formatted results");
62
-
63
- command.action(async (...args: unknown[]) => {
64
- try {
65
- // The last argument is always the command object with parsed options
66
- const commandObj = args[args.length - 1] as {
67
- opts(): Record<string, unknown>;
68
- };
69
- const options = commandObj.opts();
70
-
71
- // Convert CLI args to SDK method parameters
72
- const rawParams = convertCliArgsToSdkParams(
73
- parameters,
74
- args.slice(0, -1),
75
- options,
76
- );
77
-
78
- // Create SDK instance with manifest path if provided
79
- const sdk = createZapierSdk({
80
- manifestPath: rawParams.lockFilePath as string | undefined,
81
- });
82
- // Resolve missing parameters interactively using schema metadata
83
- const resolver = new SchemaParameterResolver();
84
- const resolvedParams = await resolver.resolveParameters(
85
- GenerateTypesSchema,
86
- rawParams,
87
- sdk,
88
- );
89
-
90
- const params = resolvedParams as Record<string, unknown>;
91
- console.log(
92
- chalk.blue(
93
- `🔧 Generating TypeScript types for ${params.appKey as string}...`,
94
- ),
95
- );
96
-
97
- // Call our implementation
98
- const generateTypesParams = {
99
- appKey: params.appKey as string,
100
- debug: (params.debug as boolean) ?? false,
101
- authenticationId: params.authenticationId as number | undefined,
102
- output: params.output as string | undefined,
103
- sdk,
104
- };
105
- const result = await generateTypes(generateTypesParams);
106
-
107
- if (options.json) {
108
- console.log(JSON.stringify({ result }, null, 2));
109
- } else {
110
- const output =
111
- (params.output as string) ||
112
- `./types/${params.appKey as string}.d.ts`;
113
- console.log(chalk.green("✅ TypeScript types generated successfully!"));
114
- console.log(chalk.gray(`Output written to: ${output}`));
115
- }
116
- } catch (error) {
117
- console.error(
118
- chalk.red("Error:"),
119
- error instanceof Error ? error.message : "Unknown error",
120
- );
121
- process.exit(1);
122
- }
123
- });
124
-
125
- return command;
126
- }
@@ -1,6 +0,0 @@
1
- export { createLoginCommand } from "./login";
2
- export { createLogoutCommand } from "./logout";
3
- export { createConfigPathCommand } from "./configPath";
4
- export { createGenerateTypesCommand } from "./generate-types/cli";
5
- export { createBundleCodeCommand } from "./bundle-code/cli";
6
- export { createMcpCommand } from "./mcp";
@@ -1,34 +0,0 @@
1
- import { Command } from "commander";
2
- import login from "../utils/auth/login";
3
- import { getLoggedInUser } from "@zapier/zapier-sdk-cli-login";
4
-
5
- export function createLoginCommand(): Command {
6
- return new Command("login")
7
- .description("Log in to Zapier to access your account")
8
- .option(
9
- "--timeout <seconds>",
10
- "Login timeout in seconds (default: 300)",
11
- "300",
12
- )
13
- .action(async (options) => {
14
- try {
15
- const timeoutSeconds = parseInt(options.timeout, 10);
16
- if (isNaN(timeoutSeconds) || timeoutSeconds <= 0) {
17
- throw new Error("Timeout must be a positive number");
18
- }
19
- await login(timeoutSeconds * 1000); // Convert to milliseconds
20
- const user = await getLoggedInUser();
21
-
22
- console.log(`✅ Successfully logged in as ${user.email}`);
23
-
24
- // Force immediate exit to prevent hanging (especially in development with tsx)
25
- setTimeout(() => process.exit(0), 100);
26
- } catch (error) {
27
- console.error(
28
- "❌ Login failed:",
29
- error instanceof Error ? error.message : "Unknown error",
30
- );
31
- process.exit(1);
32
- }
33
- });
34
- }
@@ -1,19 +0,0 @@
1
- import { Command } from "commander";
2
- import { logout } from "@zapier/zapier-sdk-cli-login";
3
-
4
- export function createLogoutCommand(): Command {
5
- return new Command("logout")
6
- .description("Log out of your Zapier account")
7
- .action(async () => {
8
- try {
9
- logout();
10
- console.log("✅ Successfully logged out");
11
- } catch (error) {
12
- console.error(
13
- "❌ Logout failed:",
14
- error instanceof Error ? error.message : "Unknown error",
15
- );
16
- process.exit(1);
17
- }
18
- });
19
- }
@@ -1,14 +0,0 @@
1
- import { Command } from "commander";
2
- import { startMcpServerAsProcess } from "@zapier/zapier-sdk-mcp";
3
-
4
- export function createMcpCommand(): Command {
5
- const command = new Command("mcp");
6
-
7
- command
8
- .description("Start MCP server for Zapier SDK")
9
- .option("--debug", "Enable debug logging")
10
- .option("--port <port>", "Port to listen on (for future HTTP transport)")
11
- .action(startMcpServerAsProcess);
12
-
13
- return command;
14
- }