@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
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@zapier/zapier-sdk-cli",
|
|
3
|
+
"version": "0.6.4",
|
|
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 {
|
|
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(
|
|
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
|
|
15
|
-
const sdk =
|
|
14
|
+
// Create CLI SDK instance with all plugins
|
|
15
|
+
const sdk = createZapierCliSdk({
|
|
16
16
|
debug: isDebugMode,
|
|
17
17
|
});
|
|
18
|
-
//
|
|
19
|
-
|
|
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
|
-
//
|
|
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();
|
package/dist/src/index.d.ts
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { createZapierCliSdk, type ZapierCliSdkOptions } from "./sdk";
|
package/dist/src/index.js
CHANGED
|
@@ -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
|
-
|
|
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.
|
|
6
|
-
minify: z.
|
|
7
|
-
target: z.
|
|
8
|
-
cjs: z.
|
|
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
|
-
|
|
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
|
-
.
|
|
10
|
+
.optional()
|
|
11
11
|
.describe("Return bundled code as string instead of writing to file"),
|
|
12
|
-
minify: z.boolean().
|
|
13
|
-
target: z.string().
|
|
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
|
-
.
|
|
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,
|
|
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,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,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,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 { 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;
|
package/dist/src/sdk.js
ADDED
|
@@ -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" &&
|