@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.
- package/CHANGELOG.md +15 -0
- package/README.md +115 -12
- package/bin/{zapier-sdk.js → zapier-sdk.mjs} +1 -1
- package/dist/cli.cjs +1715 -0
- package/dist/cli.d.mts +1 -0
- package/dist/cli.d.ts +1 -0
- package/dist/{cli.js → cli.mjs} +221 -469
- package/dist/index.cjs +770 -0
- package/dist/index.d.mts +12 -0
- package/dist/index.d.ts +12 -0
- package/dist/index.mjs +739 -0
- package/dist/package.json +67 -0
- package/dist/src/cli.js +8 -14
- package/dist/src/index.d.ts +1 -0
- package/dist/src/index.js +1 -1
- package/dist/src/plugins/bundleCode/index.d.ts +15 -0
- package/dist/src/{commands/bundle-code → plugins/bundleCode}/index.js +19 -1
- package/dist/src/{commands/bundle-code → plugins/bundleCode}/schemas.d.ts +8 -8
- package/dist/src/{commands/bundle-code → plugins/bundleCode}/schemas.js +4 -4
- package/dist/src/plugins/generateTypes/index.d.ts +21 -0
- package/dist/src/{commands/generate-types → plugins/generateTypes}/index.js +18 -0
- package/dist/src/{commands/generate-types → plugins/generateTypes}/schemas.d.ts +0 -3
- package/dist/src/{commands/generate-types → plugins/generateTypes}/schemas.js +1 -2
- package/dist/src/plugins/getConfigPath/index.d.ts +15 -0
- package/dist/src/plugins/getConfigPath/index.js +19 -0
- package/dist/src/plugins/getConfigPath/schemas.d.ts +3 -0
- package/dist/src/plugins/getConfigPath/schemas.js +5 -0
- package/dist/src/plugins/index.d.ts +6 -0
- package/dist/src/plugins/index.js +6 -0
- package/dist/src/plugins/login/index.d.ts +15 -0
- package/dist/src/plugins/login/index.js +26 -0
- package/dist/src/plugins/login/schemas.d.ts +9 -0
- package/dist/src/plugins/login/schemas.js +10 -0
- package/dist/src/plugins/logout/index.d.ts +15 -0
- package/dist/src/plugins/logout/index.js +18 -0
- package/dist/src/plugins/logout/schemas.d.ts +3 -0
- package/dist/src/plugins/logout/schemas.js +5 -0
- package/dist/src/plugins/mcp/index.d.ts +15 -0
- package/dist/src/plugins/mcp/index.js +24 -0
- package/dist/src/plugins/mcp/schemas.d.ts +9 -0
- package/dist/src/plugins/mcp/schemas.js +10 -0
- package/dist/src/sdk.d.ts +9 -0
- package/dist/src/sdk.js +22 -0
- package/dist/src/utils/cli-generator.js +12 -8
- package/dist/src/utils/schema-formatter.d.ts +1 -1
- package/dist/src/utils/schema-formatter.js +8 -8
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +19 -8
- package/src/cli.ts +8 -21
- package/src/index.ts +2 -0
- package/src/{commands/bundle-code → plugins/bundleCode}/index.ts +39 -2
- package/src/{commands/bundle-code → plugins/bundleCode}/schemas.ts +4 -4
- package/src/{commands/generate-types → plugins/generateTypes}/index.ts +56 -3
- package/src/{commands/generate-types → plugins/generateTypes}/schemas.ts +0 -4
- package/src/plugins/getConfigPath/index.ts +42 -0
- package/src/plugins/getConfigPath/schemas.ts +8 -0
- package/src/plugins/index.ts +6 -0
- package/src/plugins/login/index.ts +48 -0
- package/src/plugins/login/schemas.ts +13 -0
- package/src/plugins/logout/index.ts +37 -0
- package/src/plugins/logout/schemas.ts +8 -0
- package/src/plugins/mcp/index.ts +43 -0
- package/src/plugins/mcp/schemas.ts +13 -0
- package/src/sdk.ts +43 -0
- package/src/utils/cli-generator.test.ts +93 -0
- package/src/utils/cli-generator.ts +19 -9
- package/src/utils/schema-formatter.ts +13 -7
- package/tsconfig.build.json +15 -3
- package/tsconfig.json +2 -2
- package/tsup.config.ts +10 -4
- package/bin/zsdk.js +0 -4
- package/dist/index.js +0 -0
- package/dist/src/commands/bundle-code/cli.d.ts +0 -2
- package/dist/src/commands/bundle-code/cli.js +0 -77
- package/dist/src/commands/bundle-code/index.d.ts +0 -5
- package/dist/src/commands/configPath.d.ts +0 -2
- package/dist/src/commands/configPath.js +0 -9
- package/dist/src/commands/generate-types/cli.d.ts +0 -2
- package/dist/src/commands/generate-types/cli.js +0 -84
- package/dist/src/commands/generate-types/index.d.ts +0 -8
- package/dist/src/commands/index.d.ts +0 -6
- package/dist/src/commands/index.js +0 -6
- package/dist/src/commands/login.d.ts +0 -2
- package/dist/src/commands/login.js +0 -25
- package/dist/src/commands/logout.d.ts +0 -2
- package/dist/src/commands/logout.js +0 -16
- package/dist/src/commands/mcp.d.ts +0 -2
- package/dist/src/commands/mcp.js +0 -11
- package/src/commands/bundle-code/cli.ts +0 -118
- package/src/commands/configPath.ts +0 -10
- package/src/commands/generate-types/cli.ts +0 -126
- package/src/commands/index.ts +0 -6
- package/src/commands/login.ts +0 -34
- package/src/commands/logout.ts +0 -19
- package/src/commands/mcp.ts +0 -14
|
@@ -18,6 +18,11 @@ import inquirer from "inquirer";
|
|
|
18
18
|
// ============================================================================
|
|
19
19
|
|
|
20
20
|
function formatJsonOutput(data: unknown): void {
|
|
21
|
+
// Don't print anything for undefined results (commands that just perform actions)
|
|
22
|
+
if (data === undefined) {
|
|
23
|
+
return;
|
|
24
|
+
}
|
|
25
|
+
|
|
21
26
|
// Show success message for action results
|
|
22
27
|
if (
|
|
23
28
|
data &&
|
|
@@ -302,12 +307,12 @@ function createCommandConfig(
|
|
|
302
307
|
!shouldUseJson &&
|
|
303
308
|
!hasUserSpecifiedMaxItems
|
|
304
309
|
) {
|
|
305
|
-
// Get the async
|
|
310
|
+
// Get the async iterable directly from the SDK method call (don't await it! that breaks the next page behavior)
|
|
306
311
|
const sdkObj = sdk as unknown as Record<
|
|
307
312
|
string,
|
|
308
|
-
(params: unknown) => Promise<unknown>
|
|
313
|
+
(params: unknown) => Promise<unknown> & AsyncIterable<unknown>
|
|
309
314
|
>;
|
|
310
|
-
const sdkIterator =
|
|
315
|
+
const sdkIterator = sdkObj[sdkMethodName](resolvedParams);
|
|
311
316
|
await handlePaginatedListWithAsyncIteration(
|
|
312
317
|
sdkMethodName,
|
|
313
318
|
sdkIterator,
|
|
@@ -572,9 +577,9 @@ async function handlePaginatedListWithAsyncIteration(
|
|
|
572
577
|
|
|
573
578
|
// Format and display items using schema
|
|
574
579
|
if (schema) {
|
|
575
|
-
formatItemsFromSchema(schema as z.ZodType, items);
|
|
580
|
+
formatItemsFromSchema(schema as z.ZodType, items, totalShown);
|
|
576
581
|
} else {
|
|
577
|
-
formatItemsGeneric(items);
|
|
582
|
+
formatItemsGeneric(items, totalShown);
|
|
578
583
|
}
|
|
579
584
|
|
|
580
585
|
totalShown += items.length;
|
|
@@ -615,9 +620,9 @@ async function handlePaginatedListWithAsyncIteration(
|
|
|
615
620
|
}
|
|
616
621
|
|
|
617
622
|
if (schema) {
|
|
618
|
-
formatItemsFromSchema(schema as z.ZodType, items);
|
|
623
|
+
formatItemsFromSchema(schema as z.ZodType, items, 0);
|
|
619
624
|
} else {
|
|
620
|
-
formatItemsGeneric(items);
|
|
625
|
+
formatItemsGeneric(items, 0);
|
|
621
626
|
}
|
|
622
627
|
|
|
623
628
|
console.log(chalk.green(`\n✅ Showing ${items.length} ${itemName}`));
|
|
@@ -678,12 +683,17 @@ function formatNonPaginatedResults(
|
|
|
678
683
|
}
|
|
679
684
|
}
|
|
680
685
|
|
|
681
|
-
function formatItemsGeneric(
|
|
686
|
+
function formatItemsGeneric(
|
|
687
|
+
items: unknown[],
|
|
688
|
+
startingNumber: number = 0,
|
|
689
|
+
): void {
|
|
682
690
|
// Fallback formatting for items without schema metadata
|
|
683
691
|
items.forEach((item, index) => {
|
|
684
692
|
const itemObj = item as Record<string, unknown>;
|
|
685
693
|
const name = itemObj?.name || itemObj?.key || itemObj?.id || "Item";
|
|
686
|
-
console.log(
|
|
694
|
+
console.log(
|
|
695
|
+
`${chalk.gray(`${startingNumber + index + 1}.`)} ${chalk.cyan(String(name))}`,
|
|
696
|
+
);
|
|
687
697
|
if (itemObj?.description) {
|
|
688
698
|
console.log(` ${chalk.dim(String(itemObj.description))}`);
|
|
689
699
|
}
|
|
@@ -32,38 +32,39 @@ function getOutputSchema(schema: unknown): unknown {
|
|
|
32
32
|
export function formatItemsFromSchema(
|
|
33
33
|
inputSchema: z.ZodType,
|
|
34
34
|
items: unknown[],
|
|
35
|
+
startingNumber: number = 0,
|
|
35
36
|
): void {
|
|
36
37
|
// Get the output schema and its format metadata
|
|
37
38
|
const outputSchema = getOutputSchema(inputSchema);
|
|
38
39
|
if (!outputSchema) {
|
|
39
40
|
// Fallback to generic formatting if no output schema
|
|
40
|
-
formatItemsGeneric(items);
|
|
41
|
+
formatItemsGeneric(items, startingNumber);
|
|
41
42
|
return;
|
|
42
43
|
}
|
|
43
44
|
|
|
44
45
|
const formatMeta = getFormatMetadata(outputSchema);
|
|
45
46
|
if (!formatMeta) {
|
|
46
47
|
// Fallback to generic formatting if no format metadata
|
|
47
|
-
formatItemsGeneric(items);
|
|
48
|
+
formatItemsGeneric(items, startingNumber);
|
|
48
49
|
return;
|
|
49
50
|
}
|
|
50
51
|
|
|
51
52
|
// Format each item using the schema metadata
|
|
52
53
|
items.forEach((item, index) => {
|
|
53
|
-
formatSingleItem(item, index, formatMeta);
|
|
54
|
+
formatSingleItem(item, startingNumber + index, formatMeta);
|
|
54
55
|
});
|
|
55
56
|
}
|
|
56
57
|
|
|
57
58
|
function formatSingleItem(
|
|
58
59
|
item: unknown,
|
|
59
|
-
|
|
60
|
+
itemNumber: number,
|
|
60
61
|
formatMeta: FormatMetadata,
|
|
61
62
|
): void {
|
|
62
63
|
// Get the formatted item from the format function
|
|
63
64
|
const formatted = formatMeta.format(item);
|
|
64
65
|
|
|
65
66
|
// Build the main title line
|
|
66
|
-
let titleLine = `${chalk.gray(`${
|
|
67
|
+
let titleLine = `${chalk.gray(`${itemNumber + 1}.`)} ${chalk.cyan(formatted.title)}`;
|
|
67
68
|
if (formatted.subtitle) {
|
|
68
69
|
titleLine += ` ${chalk.gray(formatted.subtitle)}`;
|
|
69
70
|
}
|
|
@@ -94,7 +95,10 @@ function applyStyle(value: string, style: string): string {
|
|
|
94
95
|
}
|
|
95
96
|
}
|
|
96
97
|
|
|
97
|
-
function formatItemsGeneric(
|
|
98
|
+
function formatItemsGeneric(
|
|
99
|
+
items: unknown[],
|
|
100
|
+
startingNumber: number = 0,
|
|
101
|
+
): void {
|
|
98
102
|
// Fallback formatting for items without schema metadata
|
|
99
103
|
items.forEach((item, index) => {
|
|
100
104
|
const itemObj = item as {
|
|
@@ -106,7 +110,9 @@ function formatItemsGeneric(items: unknown[]): void {
|
|
|
106
110
|
};
|
|
107
111
|
const name =
|
|
108
112
|
itemObj.title || itemObj.name || itemObj.key || itemObj.id || "Item";
|
|
109
|
-
console.log(
|
|
113
|
+
console.log(
|
|
114
|
+
`${chalk.gray(`${startingNumber + index + 1}.`)} ${chalk.cyan(name)}`,
|
|
115
|
+
);
|
|
110
116
|
if (itemObj.description) {
|
|
111
117
|
console.log(` ${chalk.dim(itemObj.description)}`);
|
|
112
118
|
}
|
package/tsconfig.build.json
CHANGED
|
@@ -1,6 +1,18 @@
|
|
|
1
1
|
{
|
|
2
|
-
"extends": "./tsconfig.json",
|
|
3
2
|
"compilerOptions": {
|
|
4
|
-
"
|
|
5
|
-
|
|
3
|
+
"target": "ES2020",
|
|
4
|
+
"module": "esnext",
|
|
5
|
+
"declaration": true,
|
|
6
|
+
"outDir": "./dist",
|
|
7
|
+
"rootDir": "./src",
|
|
8
|
+
"strict": true,
|
|
9
|
+
"noUnusedLocals": true,
|
|
10
|
+
"noUnusedParameters": true,
|
|
11
|
+
"esModuleInterop": true,
|
|
12
|
+
"skipLibCheck": true,
|
|
13
|
+
"forceConsistentCasingInFileNames": true,
|
|
14
|
+
"moduleResolution": "bundler"
|
|
15
|
+
},
|
|
16
|
+
"include": ["src/**/*"],
|
|
17
|
+
"exclude": ["dist", "node_modules", "src/**/*.test.ts", "src/**/*.spec.ts"]
|
|
6
18
|
}
|
package/tsconfig.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"compilerOptions": {
|
|
3
3
|
"target": "ES2020",
|
|
4
|
-
"module": "
|
|
4
|
+
"module": "esnext",
|
|
5
5
|
"moduleResolution": "bundler",
|
|
6
6
|
"strict": true,
|
|
7
7
|
"noUnusedLocals": true,
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
"outDir": "./dist",
|
|
14
14
|
"composite": true
|
|
15
15
|
},
|
|
16
|
-
"include": ["src/**/*"],
|
|
16
|
+
"include": ["src/**/*", "package.json"],
|
|
17
17
|
"exclude": ["node_modules", "dist", "**/*.test.ts"],
|
|
18
18
|
"references": [{ "path": "../zapier-sdk" }]
|
|
19
19
|
}
|
package/tsup.config.ts
CHANGED
|
@@ -2,16 +2,22 @@ import { defineConfig } from "tsup";
|
|
|
2
2
|
|
|
3
3
|
export default defineConfig({
|
|
4
4
|
entry: ["src/index.ts", "src/cli.ts"],
|
|
5
|
-
format: ["esm"],
|
|
6
|
-
dts:
|
|
5
|
+
format: ["cjs", "esm"],
|
|
6
|
+
dts: true,
|
|
7
7
|
clean: true,
|
|
8
8
|
splitting: false,
|
|
9
9
|
sourcemap: false,
|
|
10
|
+
// Preserve tree shaking by maintaining individual module exports
|
|
11
|
+
treeshake: true,
|
|
12
|
+
// Output to separate directories for each format
|
|
10
13
|
outDir: "dist",
|
|
11
|
-
// Keep as .js for Node.js compatibility since package.json has type: module
|
|
12
14
|
outExtension({ format }) {
|
|
13
15
|
return {
|
|
14
|
-
js: ".
|
|
16
|
+
js: format === "cjs" ? ".cjs" : ".mjs",
|
|
15
17
|
};
|
|
16
18
|
},
|
|
19
|
+
// Make the optional CLI login package external so it doesn't cause build issues
|
|
20
|
+
external: ["@zapier/zapier-sdk-cli-login"],
|
|
21
|
+
// Use the build-specific tsconfig for tsup
|
|
22
|
+
tsconfig: "tsconfig.build.json",
|
|
17
23
|
});
|
package/bin/zsdk.js
DELETED
package/dist/index.js
DELETED
|
File without changes
|
|
@@ -1,77 +0,0 @@
|
|
|
1
|
-
import { Command } from "commander";
|
|
2
|
-
import { BundleCodeSchema } from "./schemas";
|
|
3
|
-
import { bundleCode } from "./index";
|
|
4
|
-
import chalk from "chalk";
|
|
5
|
-
import { analyzeZodSchema, convertCliArgsToSdkParams, } from "../../utils/cli-generator-utils";
|
|
6
|
-
export function createBundleCodeCommand() {
|
|
7
|
-
const parameters = analyzeZodSchema(BundleCodeSchema);
|
|
8
|
-
const description = BundleCodeSchema.description ||
|
|
9
|
-
"Bundle TypeScript code into executable JavaScript";
|
|
10
|
-
const command = new Command("bundle-code").description(description);
|
|
11
|
-
// Add parameters to command using same logic as CLI generator
|
|
12
|
-
parameters.forEach((param) => {
|
|
13
|
-
// Convert camelCase to kebab-case for CLI display
|
|
14
|
-
const kebabName = param.name.replace(/([A-Z])/g, "-$1").toLowerCase();
|
|
15
|
-
if (param.hasResolver && param.required) {
|
|
16
|
-
// Required parameters with resolvers become optional positional arguments (resolver handles prompting)
|
|
17
|
-
command.argument(`[${kebabName}]`, param.description || `${kebabName} parameter`);
|
|
18
|
-
}
|
|
19
|
-
else if (param.required) {
|
|
20
|
-
// Required parameters without resolvers become required positional arguments
|
|
21
|
-
command.argument(`<${kebabName}>`, param.description || `${kebabName} parameter`);
|
|
22
|
-
}
|
|
23
|
-
else if (param.isPositional) {
|
|
24
|
-
// Optional parameters marked as positional become optional positional arguments
|
|
25
|
-
command.argument(`[${kebabName}]`, param.description || `${kebabName} parameter`);
|
|
26
|
-
}
|
|
27
|
-
else {
|
|
28
|
-
// Optional parameters become flags (whether they have resolvers or not)
|
|
29
|
-
const flags = [`--${kebabName}`];
|
|
30
|
-
if (param.type === "boolean") {
|
|
31
|
-
command.option(flags.join(", "), param.description);
|
|
32
|
-
}
|
|
33
|
-
else {
|
|
34
|
-
const flagSignature = flags.join(", ") + ` <${param.type}>`;
|
|
35
|
-
command.option(flagSignature, param.description || "", param.default);
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
});
|
|
39
|
-
// Add formatting options like other commands
|
|
40
|
-
command.option("--json", "Output raw JSON instead of formatted results");
|
|
41
|
-
command.action(async (...args) => {
|
|
42
|
-
try {
|
|
43
|
-
// The last argument is always the command object with parsed options
|
|
44
|
-
const commandObj = args[args.length - 1];
|
|
45
|
-
const options = commandObj.opts();
|
|
46
|
-
// Convert CLI args to SDK method parameters
|
|
47
|
-
const rawParams = convertCliArgsToSdkParams(parameters, args.slice(0, -1), options);
|
|
48
|
-
// No parameter resolution needed for bundle-code since it doesn't use SDK
|
|
49
|
-
if (!rawParams.input) {
|
|
50
|
-
throw new Error("Input file path is required");
|
|
51
|
-
}
|
|
52
|
-
console.log(chalk.blue(`📦 Bundling ${rawParams.input}...`));
|
|
53
|
-
// Call our implementation
|
|
54
|
-
const result = await bundleCode(rawParams);
|
|
55
|
-
if (options.json) {
|
|
56
|
-
console.log(JSON.stringify({ result }, null, 2));
|
|
57
|
-
}
|
|
58
|
-
else if (rawParams.output && !rawParams.string) {
|
|
59
|
-
console.log(chalk.green("✅ Bundle created successfully!"));
|
|
60
|
-
console.log(chalk.gray(`Output written to: ${rawParams.output}`));
|
|
61
|
-
}
|
|
62
|
-
else if (rawParams.string) {
|
|
63
|
-
console.log(chalk.green("✅ Bundle generated as string!"));
|
|
64
|
-
console.log("\n" + result);
|
|
65
|
-
}
|
|
66
|
-
else {
|
|
67
|
-
console.log(chalk.green("✅ Bundle completed!"));
|
|
68
|
-
console.log("\n" + result);
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
catch (error) {
|
|
72
|
-
console.error(chalk.red("Error:"), error instanceof Error ? error.message : "Unknown error");
|
|
73
|
-
process.exit(1);
|
|
74
|
-
}
|
|
75
|
-
});
|
|
76
|
-
return command;
|
|
77
|
-
}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { Command } from "commander";
|
|
2
|
-
import { getConfigPath } from "@zapier/zapier-sdk-cli-login";
|
|
3
|
-
export function createConfigPathCommand() {
|
|
4
|
-
return new Command("get-config-path")
|
|
5
|
-
.description("Show the path to the configuration file")
|
|
6
|
-
.action(async () => {
|
|
7
|
-
console.log(`Configuration file: ${getConfigPath()}`);
|
|
8
|
-
});
|
|
9
|
-
}
|
|
@@ -1,84 +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 { analyzeZodSchema, convertCliArgsToSdkParams, } from "../../utils/cli-generator-utils";
|
|
8
|
-
export function createGenerateTypesCommand() {
|
|
9
|
-
const parameters = analyzeZodSchema(GenerateTypesSchema);
|
|
10
|
-
const description = GenerateTypesSchema.description ||
|
|
11
|
-
"Generate TypeScript SDK types for a specific app";
|
|
12
|
-
const command = new Command("generate-types").description(description);
|
|
13
|
-
// Add parameters to command using same logic as CLI generator
|
|
14
|
-
parameters.forEach((param) => {
|
|
15
|
-
// Convert camelCase to kebab-case for CLI display
|
|
16
|
-
const kebabName = param.name.replace(/([A-Z])/g, "-$1").toLowerCase();
|
|
17
|
-
if (param.hasResolver && param.required) {
|
|
18
|
-
// Required parameters with resolvers become optional positional arguments (resolver handles prompting)
|
|
19
|
-
command.argument(`[${kebabName}]`, param.description || `${kebabName} parameter`);
|
|
20
|
-
}
|
|
21
|
-
else if (param.required) {
|
|
22
|
-
// Required parameters without resolvers become required positional arguments
|
|
23
|
-
command.argument(`<${kebabName}>`, param.description || `${kebabName} parameter`);
|
|
24
|
-
}
|
|
25
|
-
else if (param.isPositional) {
|
|
26
|
-
// Optional parameters marked as positional become optional positional arguments
|
|
27
|
-
command.argument(`[${kebabName}]`, param.description || `${kebabName} parameter`);
|
|
28
|
-
}
|
|
29
|
-
else {
|
|
30
|
-
// Optional parameters become flags (whether they have resolvers or not)
|
|
31
|
-
const flags = [`--${kebabName}`];
|
|
32
|
-
if (param.type === "boolean") {
|
|
33
|
-
command.option(flags.join(", "), param.description);
|
|
34
|
-
}
|
|
35
|
-
else {
|
|
36
|
-
const flagSignature = flags.join(", ") + ` <${param.type}>`;
|
|
37
|
-
command.option(flagSignature, param.description || "", param.default);
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
});
|
|
41
|
-
// Add formatting options like other commands
|
|
42
|
-
command.option("--json", "Output raw JSON instead of formatted results");
|
|
43
|
-
command.action(async (...args) => {
|
|
44
|
-
try {
|
|
45
|
-
// The last argument is always the command object with parsed options
|
|
46
|
-
const commandObj = args[args.length - 1];
|
|
47
|
-
const options = commandObj.opts();
|
|
48
|
-
// Convert CLI args to SDK method parameters
|
|
49
|
-
const rawParams = convertCliArgsToSdkParams(parameters, args.slice(0, -1), options);
|
|
50
|
-
// Create SDK instance with manifest path if provided
|
|
51
|
-
const sdk = createZapierSdk({
|
|
52
|
-
manifestPath: rawParams.lockFilePath,
|
|
53
|
-
});
|
|
54
|
-
// Resolve missing parameters interactively using schema metadata
|
|
55
|
-
const resolver = new SchemaParameterResolver();
|
|
56
|
-
const resolvedParams = await resolver.resolveParameters(GenerateTypesSchema, rawParams, sdk);
|
|
57
|
-
const params = resolvedParams;
|
|
58
|
-
console.log(chalk.blue(`🔧 Generating TypeScript types for ${params.appKey}...`));
|
|
59
|
-
// Call our implementation
|
|
60
|
-
const generateTypesParams = {
|
|
61
|
-
appKey: params.appKey,
|
|
62
|
-
debug: params.debug ?? false,
|
|
63
|
-
authenticationId: params.authenticationId,
|
|
64
|
-
output: params.output,
|
|
65
|
-
sdk,
|
|
66
|
-
};
|
|
67
|
-
const result = await generateTypes(generateTypesParams);
|
|
68
|
-
if (options.json) {
|
|
69
|
-
console.log(JSON.stringify({ result }, null, 2));
|
|
70
|
-
}
|
|
71
|
-
else {
|
|
72
|
-
const output = params.output ||
|
|
73
|
-
`./types/${params.appKey}.d.ts`;
|
|
74
|
-
console.log(chalk.green("✅ TypeScript types generated successfully!"));
|
|
75
|
-
console.log(chalk.gray(`Output written to: ${output}`));
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
catch (error) {
|
|
79
|
-
console.error(chalk.red("Error:"), error instanceof Error ? error.message : "Unknown error");
|
|
80
|
-
process.exit(1);
|
|
81
|
-
}
|
|
82
|
-
});
|
|
83
|
-
return command;
|
|
84
|
-
}
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import type { createZapierSdk } from "@zapier/zapier-sdk";
|
|
2
|
-
import type { GenerateTypesOptions } from "./schemas";
|
|
3
|
-
/**
|
|
4
|
-
* Generate TypeScript types for a specific app (CLI version)
|
|
5
|
-
*/
|
|
6
|
-
export declare function generateTypes(options: GenerateTypesOptions & {
|
|
7
|
-
sdk: ReturnType<typeof createZapierSdk>;
|
|
8
|
-
}): Promise<string>;
|
|
@@ -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,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,25 +0,0 @@
|
|
|
1
|
-
import { Command } from "commander";
|
|
2
|
-
import login from "../utils/auth/login";
|
|
3
|
-
import { getLoggedInUser } from "@zapier/zapier-sdk-cli-login";
|
|
4
|
-
export function createLoginCommand() {
|
|
5
|
-
return new Command("login")
|
|
6
|
-
.description("Log in to Zapier to access your account")
|
|
7
|
-
.option("--timeout <seconds>", "Login timeout in seconds (default: 300)", "300")
|
|
8
|
-
.action(async (options) => {
|
|
9
|
-
try {
|
|
10
|
-
const timeoutSeconds = parseInt(options.timeout, 10);
|
|
11
|
-
if (isNaN(timeoutSeconds) || timeoutSeconds <= 0) {
|
|
12
|
-
throw new Error("Timeout must be a positive number");
|
|
13
|
-
}
|
|
14
|
-
await login(timeoutSeconds * 1000); // Convert to milliseconds
|
|
15
|
-
const user = await getLoggedInUser();
|
|
16
|
-
console.log(`✅ Successfully logged in as ${user.email}`);
|
|
17
|
-
// Force immediate exit to prevent hanging (especially in development with tsx)
|
|
18
|
-
setTimeout(() => process.exit(0), 100);
|
|
19
|
-
}
|
|
20
|
-
catch (error) {
|
|
21
|
-
console.error("❌ Login failed:", error instanceof Error ? error.message : "Unknown error");
|
|
22
|
-
process.exit(1);
|
|
23
|
-
}
|
|
24
|
-
});
|
|
25
|
-
}
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { Command } from "commander";
|
|
2
|
-
import { logout } from "@zapier/zapier-sdk-cli-login";
|
|
3
|
-
export function createLogoutCommand() {
|
|
4
|
-
return new Command("logout")
|
|
5
|
-
.description("Log out of your Zapier account")
|
|
6
|
-
.action(async () => {
|
|
7
|
-
try {
|
|
8
|
-
logout();
|
|
9
|
-
console.log("✅ Successfully logged out");
|
|
10
|
-
}
|
|
11
|
-
catch (error) {
|
|
12
|
-
console.error("❌ Logout failed:", error instanceof Error ? error.message : "Unknown error");
|
|
13
|
-
process.exit(1);
|
|
14
|
-
}
|
|
15
|
-
});
|
|
16
|
-
}
|
package/dist/src/commands/mcp.js
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { Command } from "commander";
|
|
2
|
-
import { startMcpServerAsProcess } from "@zapier/zapier-sdk-mcp";
|
|
3
|
-
export function createMcpCommand() {
|
|
4
|
-
const command = new Command("mcp");
|
|
5
|
-
command
|
|
6
|
-
.description("Start MCP server for Zapier SDK")
|
|
7
|
-
.option("--debug", "Enable debug logging")
|
|
8
|
-
.option("--port <port>", "Port to listen on (for future HTTP transport)")
|
|
9
|
-
.action(startMcpServerAsProcess);
|
|
10
|
-
return command;
|
|
11
|
-
}
|
|
@@ -1,118 +0,0 @@
|
|
|
1
|
-
import { Command } from "commander";
|
|
2
|
-
import { BundleCodeSchema } from "./schemas";
|
|
3
|
-
import { bundleCode } from "./index";
|
|
4
|
-
import chalk from "chalk";
|
|
5
|
-
import {
|
|
6
|
-
analyzeZodSchema,
|
|
7
|
-
convertCliArgsToSdkParams,
|
|
8
|
-
} from "../../utils/cli-generator-utils";
|
|
9
|
-
|
|
10
|
-
export function createBundleCodeCommand(): Command {
|
|
11
|
-
const parameters = analyzeZodSchema(BundleCodeSchema);
|
|
12
|
-
const description =
|
|
13
|
-
BundleCodeSchema.description ||
|
|
14
|
-
"Bundle TypeScript code into executable JavaScript";
|
|
15
|
-
|
|
16
|
-
const command = new Command("bundle-code").description(description);
|
|
17
|
-
|
|
18
|
-
// Add parameters to command using same logic as CLI generator
|
|
19
|
-
parameters.forEach((param) => {
|
|
20
|
-
// Convert camelCase to kebab-case for CLI display
|
|
21
|
-
const kebabName = param.name.replace(/([A-Z])/g, "-$1").toLowerCase();
|
|
22
|
-
|
|
23
|
-
if (param.hasResolver && param.required) {
|
|
24
|
-
// Required parameters with resolvers become optional positional arguments (resolver handles prompting)
|
|
25
|
-
command.argument(
|
|
26
|
-
`[${kebabName}]`,
|
|
27
|
-
param.description || `${kebabName} parameter`,
|
|
28
|
-
);
|
|
29
|
-
} else if (param.required) {
|
|
30
|
-
// Required parameters without resolvers become required positional arguments
|
|
31
|
-
command.argument(
|
|
32
|
-
`<${kebabName}>`,
|
|
33
|
-
param.description || `${kebabName} parameter`,
|
|
34
|
-
);
|
|
35
|
-
} else if (param.isPositional) {
|
|
36
|
-
// Optional parameters marked as positional become optional positional arguments
|
|
37
|
-
command.argument(
|
|
38
|
-
`[${kebabName}]`,
|
|
39
|
-
param.description || `${kebabName} parameter`,
|
|
40
|
-
);
|
|
41
|
-
} else {
|
|
42
|
-
// Optional parameters become flags (whether they have resolvers or not)
|
|
43
|
-
const flags = [`--${kebabName}`];
|
|
44
|
-
|
|
45
|
-
if (param.type === "boolean") {
|
|
46
|
-
command.option(flags.join(", "), param.description);
|
|
47
|
-
} else {
|
|
48
|
-
const flagSignature = flags.join(", ") + ` <${param.type}>`;
|
|
49
|
-
command.option(
|
|
50
|
-
flagSignature,
|
|
51
|
-
param.description || "",
|
|
52
|
-
param.default as string | boolean | string[] | undefined,
|
|
53
|
-
);
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
});
|
|
57
|
-
|
|
58
|
-
// Add formatting options like other commands
|
|
59
|
-
command.option("--json", "Output raw JSON instead of formatted results");
|
|
60
|
-
|
|
61
|
-
command.action(async (...args: unknown[]) => {
|
|
62
|
-
try {
|
|
63
|
-
// The last argument is always the command object with parsed options
|
|
64
|
-
const commandObj = args[args.length - 1] as {
|
|
65
|
-
opts(): Record<string, unknown>;
|
|
66
|
-
};
|
|
67
|
-
const options = commandObj.opts();
|
|
68
|
-
|
|
69
|
-
// Convert CLI args to SDK method parameters
|
|
70
|
-
const rawParams = convertCliArgsToSdkParams(
|
|
71
|
-
parameters,
|
|
72
|
-
args.slice(0, -1),
|
|
73
|
-
options,
|
|
74
|
-
);
|
|
75
|
-
|
|
76
|
-
// No parameter resolution needed for bundle-code since it doesn't use SDK
|
|
77
|
-
|
|
78
|
-
if (!rawParams.input) {
|
|
79
|
-
throw new Error("Input file path is required");
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
console.log(chalk.blue(`📦 Bundling ${rawParams.input}...`));
|
|
83
|
-
|
|
84
|
-
// Call our implementation
|
|
85
|
-
const result = await bundleCode(
|
|
86
|
-
rawParams as {
|
|
87
|
-
string: boolean;
|
|
88
|
-
input: string;
|
|
89
|
-
minify: boolean;
|
|
90
|
-
target: string;
|
|
91
|
-
cjs: boolean;
|
|
92
|
-
output?: string | undefined;
|
|
93
|
-
},
|
|
94
|
-
);
|
|
95
|
-
|
|
96
|
-
if (options.json) {
|
|
97
|
-
console.log(JSON.stringify({ result }, null, 2));
|
|
98
|
-
} else if (rawParams.output && !rawParams.string) {
|
|
99
|
-
console.log(chalk.green("✅ Bundle created successfully!"));
|
|
100
|
-
console.log(chalk.gray(`Output written to: ${rawParams.output}`));
|
|
101
|
-
} else if (rawParams.string) {
|
|
102
|
-
console.log(chalk.green("✅ Bundle generated as string!"));
|
|
103
|
-
console.log("\n" + result);
|
|
104
|
-
} else {
|
|
105
|
-
console.log(chalk.green("✅ Bundle completed!"));
|
|
106
|
-
console.log("\n" + result);
|
|
107
|
-
}
|
|
108
|
-
} catch (error) {
|
|
109
|
-
console.error(
|
|
110
|
-
chalk.red("Error:"),
|
|
111
|
-
error instanceof Error ? error.message : "Unknown error",
|
|
112
|
-
);
|
|
113
|
-
process.exit(1);
|
|
114
|
-
}
|
|
115
|
-
});
|
|
116
|
-
|
|
117
|
-
return command;
|
|
118
|
-
}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { Command } from "commander";
|
|
2
|
-
import { getConfigPath } from "@zapier/zapier-sdk-cli-login";
|
|
3
|
-
|
|
4
|
-
export function createConfigPathCommand(): Command {
|
|
5
|
-
return new Command("get-config-path")
|
|
6
|
-
.description("Show the path to the configuration file")
|
|
7
|
-
.action(async () => {
|
|
8
|
-
console.log(`Configuration file: ${getConfigPath()}`);
|
|
9
|
-
});
|
|
10
|
-
}
|