@zapier/zapier-sdk-cli 0.6.3 → 0.6.4
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 +9 -0
- package/README.md +115 -12
- package/bin/{zapier-sdk.js → zapier-sdk.mjs} +1 -1
- package/dist/cli.cjs +1711 -0
- package/dist/cli.d.mts +1 -0
- package/dist/cli.d.ts +1 -0
- package/dist/{cli.js → cli.mjs} +204 -456
- 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 +4 -0
- 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.ts +5 -0
- 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
package/package.json
CHANGED
|
@@ -1,13 +1,24 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zapier/zapier-sdk-cli",
|
|
3
|
-
"version": "0.6.
|
|
3
|
+
"version": "0.6.4",
|
|
4
4
|
"description": "Command line interface for Zapier SDK",
|
|
5
|
-
"
|
|
6
|
-
"
|
|
5
|
+
"main": "dist/index.cjs",
|
|
6
|
+
"module": "dist/index.mjs",
|
|
7
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
|
+
},
|
|
8
20
|
"bin": {
|
|
9
|
-
"zapier-sdk": "./bin/zapier-sdk.
|
|
10
|
-
"zsdk": "./bin/zsdk.js"
|
|
21
|
+
"zapier-sdk": "./bin/zapier-sdk.mjs"
|
|
11
22
|
},
|
|
12
23
|
"keywords": [
|
|
13
24
|
"zapier",
|
|
@@ -31,9 +42,9 @@
|
|
|
31
42
|
"ora": "^8.2.0",
|
|
32
43
|
"pkce-challenge": "^5.0.0",
|
|
33
44
|
"zod": "^3.25.67",
|
|
34
|
-
"@zapier/zapier-sdk": "0.6.
|
|
35
|
-
"@zapier/zapier-sdk-
|
|
36
|
-
"@zapier/zapier-sdk-
|
|
45
|
+
"@zapier/zapier-sdk": "0.6.4",
|
|
46
|
+
"@zapier/zapier-sdk-cli-login": "0.3.2",
|
|
47
|
+
"@zapier/zapier-sdk-mcp": "0.2.4"
|
|
37
48
|
},
|
|
38
49
|
"devDependencies": {
|
|
39
50
|
"@types/express": "^5.0.3",
|
package/src/cli.ts
CHANGED
|
@@ -1,45 +1,32 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
|
|
3
3
|
import { Command } from "commander";
|
|
4
|
-
import { createZapierSdk } from "@zapier/zapier-sdk";
|
|
5
4
|
import { generateCliCommands } from "./utils/cli-generator";
|
|
6
|
-
import {
|
|
7
|
-
|
|
8
|
-
createLogoutCommand,
|
|
9
|
-
createConfigPathCommand,
|
|
10
|
-
createGenerateTypesCommand,
|
|
11
|
-
createBundleCodeCommand,
|
|
12
|
-
createMcpCommand,
|
|
13
|
-
} from "./commands/index";
|
|
5
|
+
import { createZapierCliSdk } from "./sdk";
|
|
6
|
+
import packageJson from "../package.json" with { type: "json" };
|
|
14
7
|
|
|
15
8
|
const program = new Command();
|
|
16
9
|
|
|
17
10
|
program
|
|
18
11
|
.name("zapier-sdk")
|
|
19
12
|
.description("CLI for Zapier SDK")
|
|
20
|
-
.version(
|
|
13
|
+
.version(packageJson.version, "-v, --version", "display version number")
|
|
21
14
|
.option("--debug", "Enable debug logging");
|
|
22
15
|
|
|
23
16
|
// Check for debug flag early
|
|
24
17
|
const isDebugMode =
|
|
25
18
|
process.env.DEBUG === "true" || process.argv.includes("--debug");
|
|
26
19
|
|
|
27
|
-
// Create SDK instance
|
|
28
|
-
const sdk =
|
|
20
|
+
// Create CLI SDK instance with all plugins
|
|
21
|
+
const sdk = createZapierCliSdk({
|
|
29
22
|
debug: isDebugMode,
|
|
30
23
|
});
|
|
31
24
|
|
|
32
|
-
//
|
|
33
|
-
program.addCommand(createLoginCommand());
|
|
34
|
-
program.addCommand(createLogoutCommand());
|
|
25
|
+
// Auth commands now handled by plugins
|
|
35
26
|
|
|
36
|
-
// Generate CLI commands from SDK schemas
|
|
27
|
+
// Generate CLI commands from SDK schemas (including CLI plugins)
|
|
37
28
|
generateCliCommands(program, sdk);
|
|
38
29
|
|
|
39
|
-
//
|
|
40
|
-
program.addCommand(createGenerateTypesCommand());
|
|
41
|
-
program.addCommand(createBundleCodeCommand());
|
|
42
|
-
program.addCommand(createConfigPathCommand());
|
|
43
|
-
program.addCommand(createMcpCommand());
|
|
30
|
+
// MCP command now handled by plugin
|
|
44
31
|
|
|
45
32
|
program.parse();
|
package/src/index.ts
CHANGED
|
@@ -1,8 +1,45 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { Plugin } from "@zapier/zapier-sdk";
|
|
2
|
+
import { BundleCodeSchema, type BundleCodeOptions } from "./schemas";
|
|
3
|
+
import { createFunction } from "@zapier/zapier-sdk";
|
|
2
4
|
import { buildSync } from "esbuild";
|
|
3
5
|
import * as fs from "fs";
|
|
4
6
|
import * as path from "path";
|
|
5
7
|
|
|
8
|
+
export interface BundleCodePluginProvides {
|
|
9
|
+
bundleCode: (options: BundleCodeOptions) => Promise<string>;
|
|
10
|
+
context: {
|
|
11
|
+
meta: {
|
|
12
|
+
bundleCode: {
|
|
13
|
+
inputSchema: typeof BundleCodeSchema;
|
|
14
|
+
};
|
|
15
|
+
};
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export const bundleCodePlugin: Plugin<
|
|
20
|
+
{}, // requires no existing SDK methods
|
|
21
|
+
{}, // requires no context
|
|
22
|
+
BundleCodePluginProvides
|
|
23
|
+
> = () => {
|
|
24
|
+
const bundleCodeWithSdk = createFunction(async function bundleCodeWithSdk(
|
|
25
|
+
options: BundleCodeOptions,
|
|
26
|
+
): Promise<string> {
|
|
27
|
+
return await bundleCode(options);
|
|
28
|
+
}, BundleCodeSchema);
|
|
29
|
+
|
|
30
|
+
return {
|
|
31
|
+
bundleCode: bundleCodeWithSdk,
|
|
32
|
+
context: {
|
|
33
|
+
meta: {
|
|
34
|
+
bundleCode: {
|
|
35
|
+
categories: ["utility"],
|
|
36
|
+
inputSchema: BundleCodeSchema,
|
|
37
|
+
},
|
|
38
|
+
},
|
|
39
|
+
},
|
|
40
|
+
};
|
|
41
|
+
};
|
|
42
|
+
|
|
6
43
|
class ZapierBundleError extends Error {
|
|
7
44
|
public readonly code = "ZAPIER_BUNDLE_ERROR";
|
|
8
45
|
public readonly details?: string[];
|
|
@@ -19,7 +56,7 @@ class ZapierBundleError extends Error {
|
|
|
19
56
|
/**
|
|
20
57
|
* Bundle TypeScript code into executable JavaScript (CLI version)
|
|
21
58
|
*/
|
|
22
|
-
|
|
59
|
+
async function bundleCode(options: BundleCodeOptions): Promise<string> {
|
|
23
60
|
const {
|
|
24
61
|
input,
|
|
25
62
|
output,
|
|
@@ -10,13 +10,13 @@ export const BundleCodeSchema = z
|
|
|
10
10
|
),
|
|
11
11
|
string: z
|
|
12
12
|
.boolean()
|
|
13
|
-
.
|
|
13
|
+
.optional()
|
|
14
14
|
.describe("Return bundled code as string instead of writing to file"),
|
|
15
|
-
minify: z.boolean().
|
|
16
|
-
target: z.string().
|
|
15
|
+
minify: z.boolean().optional().describe("Minify the bundled output"),
|
|
16
|
+
target: z.string().optional().describe("ECMAScript target version"),
|
|
17
17
|
cjs: z
|
|
18
18
|
.boolean()
|
|
19
|
-
.
|
|
19
|
+
.optional()
|
|
20
20
|
.describe("Output CommonJS format instead of ESM"),
|
|
21
21
|
})
|
|
22
22
|
.describe("Bundle TypeScript code into executable JavaScript");
|
|
@@ -2,12 +2,59 @@ import type {
|
|
|
2
2
|
Action,
|
|
3
3
|
ActionField,
|
|
4
4
|
ActionItem,
|
|
5
|
-
|
|
5
|
+
Plugin,
|
|
6
|
+
GetSdkType,
|
|
7
|
+
ListActionsPluginProvides,
|
|
8
|
+
ListInputFieldsPluginProvides,
|
|
9
|
+
ManifestPluginProvides,
|
|
6
10
|
} from "@zapier/zapier-sdk";
|
|
7
|
-
import type
|
|
11
|
+
import { GenerateTypesSchema, type GenerateTypesOptions } from "./schemas";
|
|
12
|
+
import { createFunction } from "@zapier/zapier-sdk";
|
|
8
13
|
import * as fs from "fs";
|
|
9
14
|
import * as path from "path";
|
|
10
15
|
|
|
16
|
+
export interface GenerateTypesPluginProvides {
|
|
17
|
+
generateTypes: (options: GenerateTypesOptions) => Promise<string>;
|
|
18
|
+
context: {
|
|
19
|
+
meta: {
|
|
20
|
+
generateTypes: {
|
|
21
|
+
inputSchema: typeof GenerateTypesSchema;
|
|
22
|
+
};
|
|
23
|
+
};
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export const generateTypesPlugin: Plugin<
|
|
28
|
+
GetSdkType<
|
|
29
|
+
ListActionsPluginProvides &
|
|
30
|
+
ListInputFieldsPluginProvides &
|
|
31
|
+
ManifestPluginProvides
|
|
32
|
+
>, // requires these SDK methods
|
|
33
|
+
{}, // requires no context
|
|
34
|
+
GenerateTypesPluginProvides
|
|
35
|
+
> = ({ sdk }) => {
|
|
36
|
+
const generateTypesWithSdk = createFunction(
|
|
37
|
+
async function generateTypesWithSdk(
|
|
38
|
+
options: GenerateTypesOptions,
|
|
39
|
+
): Promise<string> {
|
|
40
|
+
return await generateTypes({ ...options, sdk });
|
|
41
|
+
},
|
|
42
|
+
GenerateTypesSchema,
|
|
43
|
+
);
|
|
44
|
+
|
|
45
|
+
return {
|
|
46
|
+
generateTypes: generateTypesWithSdk,
|
|
47
|
+
context: {
|
|
48
|
+
meta: {
|
|
49
|
+
generateTypes: {
|
|
50
|
+
categories: ["utility"],
|
|
51
|
+
inputSchema: GenerateTypesSchema,
|
|
52
|
+
},
|
|
53
|
+
},
|
|
54
|
+
},
|
|
55
|
+
};
|
|
56
|
+
};
|
|
57
|
+
|
|
11
58
|
interface ActionWithActionFields extends Omit<Action, "inputFields" | "type"> {
|
|
12
59
|
inputFields: ActionField[];
|
|
13
60
|
app_key: string;
|
|
@@ -28,7 +75,13 @@ function generateFetchMethodSignature(): string {
|
|
|
28
75
|
* Generate TypeScript types for a specific app (CLI version)
|
|
29
76
|
*/
|
|
30
77
|
export async function generateTypes(
|
|
31
|
-
options: GenerateTypesOptions & {
|
|
78
|
+
options: GenerateTypesOptions & {
|
|
79
|
+
sdk: GetSdkType<
|
|
80
|
+
ListActionsPluginProvides &
|
|
81
|
+
ListInputFieldsPluginProvides &
|
|
82
|
+
ManifestPluginProvides
|
|
83
|
+
>;
|
|
84
|
+
},
|
|
32
85
|
): Promise<string> {
|
|
33
86
|
const {
|
|
34
87
|
appKey,
|
|
@@ -3,7 +3,6 @@ import {
|
|
|
3
3
|
AppKeyPropertySchema,
|
|
4
4
|
AuthenticationIdPropertySchema,
|
|
5
5
|
OutputPropertySchema,
|
|
6
|
-
DebugPropertySchema,
|
|
7
6
|
} from "@zapier/zapier-sdk";
|
|
8
7
|
|
|
9
8
|
// Generate types schema - mirrors the original from SDK but for CLI use
|
|
@@ -14,9 +13,6 @@ export const GenerateTypesSchema = z
|
|
|
14
13
|
output: OutputPropertySchema.optional().describe(
|
|
15
14
|
"Output file path (defaults to generated/<appKey>.ts)",
|
|
16
15
|
),
|
|
17
|
-
debug: DebugPropertySchema.describe(
|
|
18
|
-
"Enable debug logging during generation",
|
|
19
|
-
),
|
|
20
16
|
lockFilePath: z
|
|
21
17
|
.string()
|
|
22
18
|
.optional()
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import type { Plugin } from "@zapier/zapier-sdk";
|
|
2
|
+
import { GetConfigPathSchema, type GetConfigPathOptions } from "./schemas";
|
|
3
|
+
import { createFunction } from "@zapier/zapier-sdk";
|
|
4
|
+
import { getConfigPath } from "@zapier/zapier-sdk-cli-login";
|
|
5
|
+
|
|
6
|
+
export interface GetConfigPathPluginProvides {
|
|
7
|
+
getConfigPath: (options?: GetConfigPathOptions) => Promise<string>;
|
|
8
|
+
context: {
|
|
9
|
+
meta: {
|
|
10
|
+
getConfigPath: {
|
|
11
|
+
inputSchema: typeof GetConfigPathSchema;
|
|
12
|
+
};
|
|
13
|
+
};
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export const getConfigPathPlugin: Plugin<
|
|
18
|
+
{}, // requires no existing SDK methods
|
|
19
|
+
{}, // requires no context
|
|
20
|
+
GetConfigPathPluginProvides
|
|
21
|
+
> = () => {
|
|
22
|
+
const getConfigPathWithSdk = createFunction(
|
|
23
|
+
async function getConfigPathWithSdk(
|
|
24
|
+
_options?: GetConfigPathOptions,
|
|
25
|
+
): Promise<string> {
|
|
26
|
+
return getConfigPath();
|
|
27
|
+
},
|
|
28
|
+
GetConfigPathSchema,
|
|
29
|
+
);
|
|
30
|
+
|
|
31
|
+
return {
|
|
32
|
+
getConfigPath: getConfigPathWithSdk,
|
|
33
|
+
context: {
|
|
34
|
+
meta: {
|
|
35
|
+
getConfigPath: {
|
|
36
|
+
categories: ["utility"],
|
|
37
|
+
inputSchema: GetConfigPathSchema,
|
|
38
|
+
},
|
|
39
|
+
},
|
|
40
|
+
},
|
|
41
|
+
};
|
|
42
|
+
};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
|
|
3
|
+
// Get config path schema - simple command with no parameters
|
|
4
|
+
export const GetConfigPathSchema = z
|
|
5
|
+
.object({})
|
|
6
|
+
.describe("Show the path to the configuration file");
|
|
7
|
+
|
|
8
|
+
export type GetConfigPathOptions = z.infer<typeof GetConfigPathSchema>;
|
|
@@ -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,48 @@
|
|
|
1
|
+
import { createFunction } from "@zapier/zapier-sdk";
|
|
2
|
+
import type { Plugin } from "@zapier/zapier-sdk";
|
|
3
|
+
import login from "../../utils/auth/login";
|
|
4
|
+
import { getLoggedInUser } from "@zapier/zapier-sdk-cli-login";
|
|
5
|
+
import { LoginSchema, type LoginOptions } from "./schemas";
|
|
6
|
+
|
|
7
|
+
interface LoginPluginProvides {
|
|
8
|
+
login: (options: LoginOptions) => Promise<void>;
|
|
9
|
+
context: {
|
|
10
|
+
meta: {
|
|
11
|
+
login: {
|
|
12
|
+
inputSchema: typeof LoginSchema;
|
|
13
|
+
categories: string[];
|
|
14
|
+
};
|
|
15
|
+
};
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
const loginWithSdk = createFunction(async function loginWithSdk(
|
|
20
|
+
options: LoginOptions,
|
|
21
|
+
): Promise<void> {
|
|
22
|
+
const timeoutSeconds = options.timeout ? parseInt(options.timeout, 10) : 300;
|
|
23
|
+
if (isNaN(timeoutSeconds) || timeoutSeconds <= 0) {
|
|
24
|
+
throw new Error("Timeout must be a positive number");
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
await login(timeoutSeconds * 1000); // Convert to milliseconds
|
|
28
|
+
const user = await getLoggedInUser();
|
|
29
|
+
|
|
30
|
+
console.log(`✅ Successfully logged in as ${user.email}`);
|
|
31
|
+
|
|
32
|
+
// Force immediate exit to prevent hanging (especially in development with tsx)
|
|
33
|
+
setTimeout(() => process.exit(0), 100);
|
|
34
|
+
}, LoginSchema);
|
|
35
|
+
|
|
36
|
+
export const loginPlugin: Plugin<{}, {}, LoginPluginProvides> = () => ({
|
|
37
|
+
login: loginWithSdk,
|
|
38
|
+
context: {
|
|
39
|
+
meta: {
|
|
40
|
+
login: {
|
|
41
|
+
categories: ["account"],
|
|
42
|
+
inputSchema: LoginSchema,
|
|
43
|
+
},
|
|
44
|
+
},
|
|
45
|
+
},
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
export type { LoginPluginProvides };
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
|
|
3
|
+
// Login schema
|
|
4
|
+
export const LoginSchema = z
|
|
5
|
+
.object({
|
|
6
|
+
timeout: z
|
|
7
|
+
.string()
|
|
8
|
+
.optional()
|
|
9
|
+
.describe("Login timeout in seconds (default: 300)"),
|
|
10
|
+
})
|
|
11
|
+
.describe("Log in to Zapier to access your account");
|
|
12
|
+
|
|
13
|
+
export type LoginOptions = z.infer<typeof LoginSchema>;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { createFunction } from "@zapier/zapier-sdk";
|
|
2
|
+
import type { Plugin } from "@zapier/zapier-sdk";
|
|
3
|
+
import { logout } from "@zapier/zapier-sdk-cli-login";
|
|
4
|
+
import { LogoutSchema, type LogoutOptions } from "./schemas";
|
|
5
|
+
|
|
6
|
+
interface LogoutPluginProvides {
|
|
7
|
+
logout: (options: LogoutOptions) => Promise<void>;
|
|
8
|
+
context: {
|
|
9
|
+
meta: {
|
|
10
|
+
logout: {
|
|
11
|
+
inputSchema: typeof LogoutSchema;
|
|
12
|
+
categories: string[];
|
|
13
|
+
};
|
|
14
|
+
};
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
const logoutWithSdk = createFunction(async function logoutWithSdk(
|
|
19
|
+
_options: LogoutOptions,
|
|
20
|
+
): Promise<void> {
|
|
21
|
+
logout();
|
|
22
|
+
console.log("✅ Successfully logged out");
|
|
23
|
+
}, LogoutSchema);
|
|
24
|
+
|
|
25
|
+
export const logoutPlugin: Plugin<{}, {}, LogoutPluginProvides> = () => ({
|
|
26
|
+
logout: logoutWithSdk,
|
|
27
|
+
context: {
|
|
28
|
+
meta: {
|
|
29
|
+
logout: {
|
|
30
|
+
categories: ["account"],
|
|
31
|
+
inputSchema: LogoutSchema,
|
|
32
|
+
},
|
|
33
|
+
},
|
|
34
|
+
},
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
export type { LogoutPluginProvides };
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { createFunction } from "@zapier/zapier-sdk";
|
|
2
|
+
import type { Plugin } from "@zapier/zapier-sdk";
|
|
3
|
+
import { startMcpServerAsProcess } from "@zapier/zapier-sdk-mcp";
|
|
4
|
+
import { McpSchema, type McpOptions } from "./schemas";
|
|
5
|
+
|
|
6
|
+
interface McpPluginProvides {
|
|
7
|
+
mcp: (options: McpOptions) => Promise<void>;
|
|
8
|
+
context: {
|
|
9
|
+
meta: {
|
|
10
|
+
mcp: {
|
|
11
|
+
inputSchema: typeof McpSchema;
|
|
12
|
+
categories: string[];
|
|
13
|
+
};
|
|
14
|
+
};
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export const mcpPlugin: Plugin<{}, {}, McpPluginProvides> = ({ context }) => {
|
|
19
|
+
const mcpWithSdk = createFunction(async function mcpWithSdk(
|
|
20
|
+
options: McpOptions,
|
|
21
|
+
): Promise<void> {
|
|
22
|
+
// Pass through the SDK's debug option to the MCP server
|
|
23
|
+
const mcpOptions = {
|
|
24
|
+
...options,
|
|
25
|
+
debug: context.options.debug,
|
|
26
|
+
};
|
|
27
|
+
return await startMcpServerAsProcess(mcpOptions);
|
|
28
|
+
}, McpSchema);
|
|
29
|
+
|
|
30
|
+
return {
|
|
31
|
+
mcp: mcpWithSdk,
|
|
32
|
+
context: {
|
|
33
|
+
meta: {
|
|
34
|
+
mcp: {
|
|
35
|
+
categories: ["utility"],
|
|
36
|
+
inputSchema: McpSchema,
|
|
37
|
+
},
|
|
38
|
+
},
|
|
39
|
+
},
|
|
40
|
+
};
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
export type { McpPluginProvides };
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
|
|
3
|
+
// MCP server schema
|
|
4
|
+
export const McpSchema = z
|
|
5
|
+
.object({
|
|
6
|
+
port: z
|
|
7
|
+
.string()
|
|
8
|
+
.optional()
|
|
9
|
+
.describe("Port to listen on (for future HTTP transport)"),
|
|
10
|
+
})
|
|
11
|
+
.describe("Start MCP server for Zapier SDK");
|
|
12
|
+
|
|
13
|
+
export type McpOptions = z.infer<typeof McpSchema>;
|
package/src/sdk.ts
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import {
|
|
2
|
+
createZapierSdkWithoutRegistry,
|
|
3
|
+
registryPlugin,
|
|
4
|
+
type ZapierSdk,
|
|
5
|
+
} from "@zapier/zapier-sdk";
|
|
6
|
+
import {
|
|
7
|
+
loginPlugin,
|
|
8
|
+
logoutPlugin,
|
|
9
|
+
mcpPlugin,
|
|
10
|
+
generateTypesPlugin,
|
|
11
|
+
bundleCodePlugin,
|
|
12
|
+
getConfigPathPlugin,
|
|
13
|
+
} from "./plugins/index";
|
|
14
|
+
|
|
15
|
+
export interface ZapierCliSdkOptions {
|
|
16
|
+
debug?: boolean;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Create a Zapier SDK instance configured specifically for the CLI
|
|
21
|
+
* Includes all CLI-specific plugins in addition to the standard SDK functionality
|
|
22
|
+
*/
|
|
23
|
+
export function createZapierCliSdk(
|
|
24
|
+
options: ZapierCliSdkOptions = {},
|
|
25
|
+
): ZapierSdk {
|
|
26
|
+
// Create SDK instance without registry
|
|
27
|
+
let sdk = createZapierSdkWithoutRegistry({
|
|
28
|
+
debug: options.debug,
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
// Add CLI-specific plugins before registry
|
|
32
|
+
sdk = sdk.addPlugin(generateTypesPlugin);
|
|
33
|
+
sdk = sdk.addPlugin(bundleCodePlugin);
|
|
34
|
+
sdk = sdk.addPlugin(getConfigPathPlugin);
|
|
35
|
+
sdk = sdk.addPlugin(mcpPlugin);
|
|
36
|
+
sdk = sdk.addPlugin(loginPlugin);
|
|
37
|
+
sdk = sdk.addPlugin(logoutPlugin);
|
|
38
|
+
|
|
39
|
+
// Add registry plugin to finalize SDK
|
|
40
|
+
const finalSdk = sdk.addPlugin(registryPlugin);
|
|
41
|
+
|
|
42
|
+
return finalSdk;
|
|
43
|
+
}
|
|
@@ -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 &&
|
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
|