@zapier/zapier-sdk-cli 0.42.2 → 0.43.1

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 (54) hide show
  1. package/CHANGELOG.md +21 -0
  2. package/dist/cli.cjs +1047 -547
  3. package/dist/cli.d.mts +0 -1
  4. package/dist/cli.d.ts +0 -1
  5. package/dist/cli.mjs +1034 -537
  6. package/dist/index.cjs +1037 -538
  7. package/dist/index.d.mts +395 -23
  8. package/dist/index.d.ts +395 -23
  9. package/dist/index.mjs +1027 -531
  10. package/dist/login.cjs +599 -7
  11. package/dist/login.d.mts +144 -1
  12. package/dist/login.d.ts +144 -1
  13. package/dist/login.mjs +565 -1
  14. package/dist/package.json +5 -2
  15. package/dist/src/login/filesystem-cache.d.ts +25 -0
  16. package/dist/src/login/filesystem-cache.js +195 -0
  17. package/dist/src/login/index.d.ts +115 -0
  18. package/dist/src/login/index.js +442 -0
  19. package/dist/src/login/keychain.d.ts +18 -0
  20. package/dist/src/login/keychain.js +74 -0
  21. package/dist/src/login.d.ts +10 -1
  22. package/dist/src/login.js +10 -1
  23. package/dist/src/plugins/add/index.d.ts +250 -11
  24. package/dist/src/plugins/add/index.js +8 -16
  25. package/dist/src/plugins/buildManifest/index.d.ts +116 -9
  26. package/dist/src/plugins/buildManifest/index.js +14 -23
  27. package/dist/src/plugins/bundleCode/index.d.ts +19 -10
  28. package/dist/src/plugins/bundleCode/index.js +7 -17
  29. package/dist/src/plugins/cliOverrides/index.d.ts +12 -10
  30. package/dist/src/plugins/cliOverrides/index.js +16 -20
  31. package/dist/src/plugins/curl/index.d.ts +69 -10
  32. package/dist/src/plugins/curl/index.js +3 -2
  33. package/dist/src/plugins/feedback/index.d.ts +18 -13
  34. package/dist/src/plugins/feedback/index.js +18 -26
  35. package/dist/src/plugins/generateAppTypes/index.d.ts +261 -9
  36. package/dist/src/plugins/generateAppTypes/index.js +17 -45
  37. package/dist/src/plugins/getLoginConfigPath/index.d.ts +12 -10
  38. package/dist/src/plugins/getLoginConfigPath/index.js +9 -19
  39. package/dist/src/plugins/init/index.d.ts +15 -11
  40. package/dist/src/plugins/init/index.js +9 -17
  41. package/dist/src/plugins/login/index.d.ts +18 -13
  42. package/dist/src/plugins/login/index.js +10 -18
  43. package/dist/src/plugins/logout/index.d.ts +12 -11
  44. package/dist/src/plugins/logout/index.js +11 -17
  45. package/dist/src/plugins/mcp/index.d.ts +18 -15
  46. package/dist/src/plugins/mcp/index.js +9 -21
  47. package/dist/src/sdk.js +1 -1
  48. package/dist/src/utils/auth/login.d.ts +1 -1
  49. package/dist/src/utils/auth/login.js +1 -1
  50. package/dist/src/utils/constants.d.ts +1 -1
  51. package/dist/src/utils/constants.js +1 -1
  52. package/dist/src/utils/version-checker.js +1 -1
  53. package/dist/tsconfig.tsbuildinfo +1 -1
  54. package/package.json +7 -4
@@ -1,19 +1,9 @@
1
- import { GetLoginConfigPathSchema, } from "./schemas";
2
- import { createFunction } from "@zapier/zapier-sdk";
3
- import { getConfigPath } from "@zapier/zapier-sdk-cli-login";
4
- export const getLoginConfigPathPlugin = () => {
5
- const getLoginConfigPathWithSdk = createFunction(async function getLoginConfigPathWithSdk(_options) {
6
- return getConfigPath();
7
- }, GetLoginConfigPathSchema);
8
- return {
9
- getLoginConfigPath: getLoginConfigPathWithSdk,
10
- context: {
11
- meta: {
12
- getLoginConfigPath: {
13
- categories: ["utility"],
14
- inputSchema: GetLoginConfigPathSchema,
15
- },
16
- },
17
- },
18
- };
19
- };
1
+ import { GetLoginConfigPathSchema } from "./schemas";
2
+ import { createPluginMethod, definePlugin, } from "@zapier/zapier-sdk";
3
+ import { getConfigPath } from "../../login";
4
+ export const getLoginConfigPathPlugin = definePlugin((sdk) => createPluginMethod(sdk, {
5
+ name: "getLoginConfigPath",
6
+ categories: ["utility"],
7
+ inputSchema: GetLoginConfigPathSchema,
8
+ handler: async () => getConfigPath(),
9
+ }));
@@ -1,16 +1,20 @@
1
- import type { Plugin } from "@zapier/zapier-sdk";
2
- import { InitSchema, type InitOptions } from "./schemas";
3
1
  export { toProjectName } from "./utils";
4
- interface InitPluginProvides {
5
- init: (options: InitOptions) => Promise<void>;
2
+ export declare const initPlugin: (sdk: {
3
+ context: import("@zapier/zapier-sdk").EventEmissionContext;
4
+ } & {
5
+ context: {
6
+ meta: Record<string, import("@zapier/zapier-sdk").PluginMeta>;
7
+ };
8
+ }) => {
9
+ init: (options?: {
10
+ projectName: string;
11
+ skipPrompts?: boolean | undefined;
12
+ } | undefined) => Promise<void>;
13
+ } & {
6
14
  context: {
7
15
  meta: {
8
- init: {
9
- inputSchema: typeof InitSchema;
10
- categories: string[];
11
- };
16
+ init: import("@zapier/zapier-sdk").PluginMeta;
12
17
  };
13
18
  };
14
- }
15
- export declare const initPlugin: Plugin<{}, InitPluginProvides>;
16
- export type { InitPluginProvides };
19
+ };
20
+ export type InitPluginProvides = ReturnType<typeof initPlugin>;
@@ -1,4 +1,4 @@
1
- import { createFunction } from "@zapier/zapier-sdk";
1
+ import { createPluginMethod, definePlugin, } from "@zapier/zapier-sdk";
2
2
  import { InitSchema } from "./schemas";
3
3
  import { detectPackageManager } from "../../utils/package-manager-detector";
4
4
  import { validateInitOptions, withInterruptCleanup } from "./utils";
@@ -6,8 +6,12 @@ import { getInitSteps, runStep } from "./steps";
6
6
  import { createConsoleDisplayHooks, displaySummaryAndNextSteps, } from "./display";
7
7
  import { ZapierCliExitError } from "../../utils/errors";
8
8
  export { toProjectName } from "./utils";
9
- export const initPlugin = () => {
10
- const init = createFunction(async function init(options) {
9
+ export const initPlugin = definePlugin((sdk) => createPluginMethod(sdk, {
10
+ name: "init",
11
+ categories: ["utility"],
12
+ inputSchema: InitSchema,
13
+ supportsJsonOutput: false,
14
+ handler: async ({ options }) => {
11
15
  const { projectName: rawName, skipPrompts = false } = options;
12
16
  const cwd = process.cwd();
13
17
  const { projectName, projectDir } = validateInitOptions({ rawName, cwd });
@@ -46,17 +50,5 @@ export const initPlugin = () => {
46
50
  completedSetupStepIds,
47
51
  packageManager,
48
52
  });
49
- }, InitSchema);
50
- return {
51
- init,
52
- context: {
53
- meta: {
54
- init: {
55
- categories: ["utility"],
56
- inputSchema: InitSchema,
57
- supportsJsonOutput: false,
58
- },
59
- },
60
- },
61
- };
62
- };
53
+ },
54
+ }));
@@ -1,5 +1,4 @@
1
- import type { Plugin, ResolvedCredentials, EventEmissionProvides } from "@zapier/zapier-sdk";
2
- import { LoginSchema, type LoginOptions } from "./schemas";
1
+ import type { ResolvedCredentials } from "@zapier/zapier-sdk";
3
2
  interface CliContext {
4
3
  session_id?: string | null;
5
4
  selected_api?: string | null;
@@ -7,18 +6,24 @@ interface CliContext {
7
6
  app_version_id?: number | null;
8
7
  resolveCredentials: () => Promise<ResolvedCredentials | undefined>;
9
8
  }
10
- interface LoginPluginProvides {
11
- login: (options: LoginOptions) => Promise<void>;
9
+ export declare const loginPlugin: (sdk: {
10
+ context: import("@zapier/zapier-sdk").EventEmissionContext;
11
+ } & {
12
+ context: CliContext;
13
+ } & {
14
+ context: {
15
+ meta: Record<string, import("@zapier/zapier-sdk").PluginMeta>;
16
+ };
17
+ }) => {
18
+ login: (options?: {
19
+ timeout?: string | undefined;
20
+ } | undefined) => Promise<void>;
21
+ } & {
12
22
  context: {
13
23
  meta: {
14
- login: {
15
- inputSchema: typeof LoginSchema;
16
- categories: string[];
17
- };
24
+ login: import("@zapier/zapier-sdk").PluginMeta;
18
25
  };
19
26
  };
20
- }
21
- export declare const loginPlugin: Plugin<EventEmissionProvides & {
22
- context: CliContext;
23
- }, LoginPluginProvides>;
24
- export type { LoginPluginProvides };
27
+ };
28
+ export type LoginPluginProvides = ReturnType<typeof loginPlugin>;
29
+ export {};
@@ -1,6 +1,6 @@
1
- import { isCredentialsObject, buildApplicationLifecycleEvent, } from "@zapier/zapier-sdk";
1
+ import { createPluginMethod, definePlugin, isCredentialsObject, buildApplicationLifecycleEvent, } from "@zapier/zapier-sdk";
2
2
  import login from "../../utils/auth/login";
3
- import { getLoggedInUser, } from "@zapier/zapier-sdk-cli-login";
3
+ import { getLoggedInUser } from "../../login";
4
4
  import { LoginSchema } from "./schemas";
5
5
  function toPkceCredentials(credentials) {
6
6
  if (credentials &&
@@ -15,8 +15,12 @@ function toPkceCredentials(credentials) {
15
15
  }
16
16
  return undefined;
17
17
  }
18
- export const loginPlugin = (sdk) => {
19
- const loginFn = async (options) => {
18
+ export const loginPlugin = definePlugin((sdk) => createPluginMethod(sdk, {
19
+ name: "login",
20
+ categories: ["account"],
21
+ inputSchema: LoginSchema,
22
+ supportsJsonOutput: false,
23
+ handler: async ({ sdk, options }) => {
20
24
  const timeoutSeconds = options.timeout
21
25
  ? parseInt(options.timeout, 10)
22
26
  : 300;
@@ -32,17 +36,5 @@ export const loginPlugin = (sdk) => {
32
36
  const user = await getLoggedInUser();
33
37
  sdk.context.eventEmission.emit("platform.sdk.ApplicationLifecycleEvent", buildApplicationLifecycleEvent({ lifecycle_event_type: "login_success" }, { customuser_id: user.customUserId, account_id: user.accountId }));
34
38
  console.log(`✅ Successfully logged in as ${user.email}`);
35
- };
36
- return {
37
- login: loginFn,
38
- context: {
39
- meta: {
40
- login: {
41
- categories: ["account"],
42
- inputSchema: LoginSchema,
43
- supportsJsonOutput: false,
44
- },
45
- },
46
- },
47
- };
48
- };
39
+ },
40
+ }));
@@ -1,15 +1,16 @@
1
- import type { Plugin } from "@zapier/zapier-sdk";
2
- import { LogoutSchema, type LogoutOptions } from "./schemas";
3
- interface LogoutPluginProvides {
4
- logout: (options: LogoutOptions) => Promise<void>;
1
+ export declare const logoutPlugin: (sdk: {
2
+ context: import("@zapier/zapier-sdk").EventEmissionContext;
3
+ } & {
4
+ context: {
5
+ meta: Record<string, import("@zapier/zapier-sdk").PluginMeta>;
6
+ };
7
+ }) => {
8
+ logout: (options?: Record<string, never> | undefined) => Promise<void>;
9
+ } & {
5
10
  context: {
6
11
  meta: {
7
- logout: {
8
- inputSchema: typeof LogoutSchema;
9
- categories: string[];
10
- };
12
+ logout: import("@zapier/zapier-sdk").PluginMeta;
11
13
  };
12
14
  };
13
- }
14
- export declare const logoutPlugin: Plugin<{}, LogoutPluginProvides>;
15
- export type { LogoutPluginProvides };
15
+ };
16
+ export type LogoutPluginProvides = ReturnType<typeof logoutPlugin>;
@@ -1,19 +1,13 @@
1
- import { createFunction } from "@zapier/zapier-sdk";
2
- import { logout } from "@zapier/zapier-sdk-cli-login";
1
+ import { createPluginMethod, definePlugin, } from "@zapier/zapier-sdk";
2
+ import { logout } from "../../login";
3
3
  import { LogoutSchema } from "./schemas";
4
- const logoutWithSdk = createFunction(async function logoutWithSdk(_options) {
5
- await 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
- supportsJsonOutput: false,
16
- },
17
- },
4
+ export const logoutPlugin = definePlugin((sdk) => createPluginMethod(sdk, {
5
+ name: "logout",
6
+ categories: ["account"],
7
+ inputSchema: LogoutSchema,
8
+ supportsJsonOutput: false,
9
+ handler: async () => {
10
+ await logout();
11
+ console.log("✅ Successfully logged out");
18
12
  },
19
- });
13
+ }));
@@ -1,21 +1,24 @@
1
- import type { Plugin } from "@zapier/zapier-sdk";
2
- import { McpSchema, type McpOptions } from "./schemas";
3
- interface McpPluginProvides {
4
- mcp: (options: McpOptions) => Promise<void>;
1
+ export declare const mcpPlugin: (sdk: {
5
2
  context: {
6
- meta: {
7
- mcp: {
8
- inputSchema: typeof McpSchema;
9
- categories: string[];
10
- };
3
+ options?: {
4
+ debug?: boolean;
11
5
  };
12
6
  };
13
- }
14
- export declare const mcpPlugin: Plugin<{
7
+ } & {
8
+ context: import("@zapier/zapier-sdk").EventEmissionContext;
9
+ } & {
15
10
  context: {
16
- options?: {
17
- debug?: boolean;
11
+ meta: Record<string, import("@zapier/zapier-sdk").PluginMeta>;
12
+ };
13
+ }) => {
14
+ mcp: (options?: {
15
+ port?: string | undefined;
16
+ } | undefined) => Promise<void>;
17
+ } & {
18
+ context: {
19
+ meta: {
20
+ mcp: import("@zapier/zapier-sdk").PluginMeta;
18
21
  };
19
22
  };
20
- }, McpPluginProvides>;
21
- export type { McpPluginProvides };
23
+ };
24
+ export type McpPluginProvides = ReturnType<typeof mcpPlugin>;
@@ -1,24 +1,12 @@
1
- import { createFunction } from "@zapier/zapier-sdk";
1
+ import { createPluginMethod, definePlugin, } from "@zapier/zapier-sdk";
2
2
  import { startMcpServer } from "@zapier/zapier-sdk-mcp";
3
3
  import { McpSchema } from "./schemas";
4
- export const mcpPlugin = (sdk) => {
5
- const mcpWithSdk = createFunction(async function mcpWithSdk(options) {
4
+ export const mcpPlugin = definePlugin((sdk) => createPluginMethod(sdk, {
5
+ name: "mcp",
6
+ categories: ["utility"],
7
+ inputSchema: McpSchema,
8
+ handler: async ({ sdk, options }) => {
6
9
  // Pass through the SDK's debug option to the MCP server
7
- const mcpOptions = {
8
- ...options,
9
- debug: sdk.context.options?.debug,
10
- };
11
- return await startMcpServer(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
- };
10
+ await startMcpServer({ ...options, debug: sdk.context.options?.debug });
11
+ },
12
+ }));
package/dist/src/sdk.js CHANGED
@@ -1,4 +1,4 @@
1
- import * as cliLogin from "@zapier/zapier-sdk-cli-login";
1
+ import * as cliLogin from "./login";
2
2
  import { createZapierSdk, injectCliLogin, } from "@zapier/zapier-sdk";
3
3
  import { loginPlugin, logoutPlugin, mcpPlugin, bundleCodePlugin, getLoginConfigPathPlugin, addPlugin, generateAppTypesPlugin, buildManifestPlugin, feedbackPlugin, curlPlugin, cliOverridesPlugin, initPlugin, } from "./plugins/index";
4
4
  import packageJson from "../package.json" with { type: "json" };
@@ -1,4 +1,4 @@
1
- import { type PkceCredentials } from "@zapier/zapier-sdk-cli-login";
1
+ import { type PkceCredentials } from "../../login";
2
2
  interface LoginOptions {
3
3
  timeoutMs?: number;
4
4
  credentials?: PkceCredentials;
@@ -8,7 +8,7 @@ import log from "../log";
8
8
  import api from "../api/client";
9
9
  import getCallablePromise from "../getCallablePromise";
10
10
  import inquirer from "inquirer";
11
- import { updateLogin, logout, getPkceLoginConfig, getLoginStorageMode, getConfigPath, } from "@zapier/zapier-sdk-cli-login";
11
+ import { updateLogin, logout, getPkceLoginConfig, getLoginStorageMode, getConfigPath, } from "../../login";
12
12
  import { ZapierCliUserCancellationError } from "../errors";
13
13
  const findAvailablePort = () => {
14
14
  return new Promise((resolve, reject) => {
@@ -1,3 +1,3 @@
1
- export { AUTH_MODE_HEADER } from "@zapier/zapier-sdk-cli-login";
1
+ export { AUTH_MODE_HEADER } from "../login";
2
2
  export declare const LOGIN_PORTS: number[];
3
3
  export declare const LOGIN_TIMEOUT_MS = 300000;
@@ -1,5 +1,5 @@
1
1
  // Import shared OAuth constants from login package
2
- export { AUTH_MODE_HEADER } from "@zapier/zapier-sdk-cli-login";
2
+ export { AUTH_MODE_HEADER } from "../login";
3
3
  // CLI-specific constants
4
4
  export const LOGIN_PORTS = [49505, 50575, 52804, 55981, 61010, 63851];
5
5
  export const LOGIN_TIMEOUT_MS = 300000; // 5 minutes
@@ -1,7 +1,7 @@
1
1
  import packageJsonLib from "package-json";
2
2
  import chalk from "chalk";
3
3
  import log from "./log";
4
- import { getConfig } from "@zapier/zapier-sdk-cli-login";
4
+ import { getConfig } from "../login";
5
5
  import { getUpdateCommand } from "./package-manager-detector";
6
6
  import semver from "semver";
7
7
  const ONE_DAY_MS = 24 * 60 * 60 * 1000;