@zapier/zapier-sdk-cli 0.40.0 → 0.41.0

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 (35) hide show
  1. package/CHANGELOG.md +21 -0
  2. package/dist/cli.cjs +29 -29
  3. package/dist/cli.mjs +29 -29
  4. package/dist/index.cjs +20 -23
  5. package/dist/index.d.mts +2 -3
  6. package/dist/index.d.ts +2 -3
  7. package/dist/index.mjs +20 -23
  8. package/dist/package.json +1 -1
  9. package/dist/src/cli.js +3 -3
  10. package/dist/src/generators/ast-generator.d.ts +2 -2
  11. package/dist/src/plugins/add/index.d.ts +2 -2
  12. package/dist/src/plugins/add/index.js +1 -1
  13. package/dist/src/plugins/buildManifest/index.d.ts +2 -2
  14. package/dist/src/plugins/buildManifest/index.js +2 -2
  15. package/dist/src/plugins/bundleCode/index.d.ts +0 -1
  16. package/dist/src/plugins/cliOverrides/index.d.ts +5 -3
  17. package/dist/src/plugins/cliOverrides/index.js +7 -4
  18. package/dist/src/plugins/curl/index.d.ts +1 -1
  19. package/dist/src/plugins/curl/index.js +1 -1
  20. package/dist/src/plugins/feedback/index.d.ts +7 -1
  21. package/dist/src/plugins/feedback/index.js +2 -2
  22. package/dist/src/plugins/generateAppTypes/index.d.ts +2 -2
  23. package/dist/src/plugins/generateAppTypes/index.js +1 -1
  24. package/dist/src/plugins/getLoginConfigPath/index.d.ts +0 -1
  25. package/dist/src/plugins/init/index.d.ts +1 -1
  26. package/dist/src/plugins/login/index.d.ts +5 -3
  27. package/dist/src/plugins/login/index.js +3 -3
  28. package/dist/src/plugins/logout/index.d.ts +1 -1
  29. package/dist/src/plugins/mcp/index.d.ts +7 -1
  30. package/dist/src/plugins/mcp/index.js +2 -2
  31. package/dist/src/types/sdk.d.ts +2 -3
  32. package/dist/src/utils/cli-generator.js +1 -3
  33. package/dist/src/utils/parameter-resolver.js +1 -1
  34. package/dist/tsconfig.tsbuildinfo +1 -1
  35. package/package.json +3 -3
package/dist/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zapier/zapier-sdk-cli",
3
- "version": "0.40.0",
3
+ "version": "0.41.0",
4
4
  "description": "Command line interface for Zapier SDK",
5
5
  "main": "dist/index.cjs",
6
6
  "module": "dist/index.mjs",
package/dist/src/cli.js CHANGED
@@ -79,7 +79,7 @@ function buildCredentialsFromFlags() {
79
79
  type: "client_credentials",
80
80
  clientId: credentialsClientId,
81
81
  clientSecret: credentialsClientSecret,
82
- baseUrl: credentialsBaseUrl,
82
+ ...(credentialsBaseUrl && { baseUrl: credentialsBaseUrl }),
83
83
  };
84
84
  }
85
85
  else {
@@ -87,7 +87,7 @@ function buildCredentialsFromFlags() {
87
87
  return {
88
88
  type: "pkce",
89
89
  clientId: credentialsClientId,
90
- baseUrl: credentialsBaseUrl,
90
+ ...(credentialsBaseUrl && { baseUrl: credentialsBaseUrl }),
91
91
  };
92
92
  }
93
93
  }
@@ -146,7 +146,7 @@ program.exitOverride();
146
146
  // Flush the exit telemetry event before we force-terminate. The async
147
147
  // transport needs an explicit await because process.on("exit") only
148
148
  // allows synchronous work.
149
- await sdk.getContext().eventEmission.close(exitCode);
149
+ await sdk.context.eventEmission.close(exitCode);
150
150
  // Force exit after a short grace period. We can't rely on process.exitCode
151
151
  // alone because background handles (stdin, pending file closes) keep the
152
152
  // event loop alive indefinitely. The unref'd timer won't prevent natural
@@ -1,4 +1,4 @@
1
- import type { GetSdkType, ListActionsPluginProvides, ListInputFieldsPluginProvides, ManifestPluginProvides, AppItem } from "@zapier/zapier-sdk";
1
+ import type { ListActionsPluginProvides, ListInputFieldsPluginProvides, ManifestPluginProvides, AppItem } from "@zapier/zapier-sdk";
2
2
  interface GenerateTypesOptions {
3
3
  app: AppItem;
4
4
  connectionId?: string | number;
@@ -13,7 +13,7 @@ export declare class AstTypeGenerator {
13
13
  * Generate TypeScript types using AST for a specific app
14
14
  */
15
15
  generateTypes(options: GenerateTypesOptions & {
16
- sdk: GetSdkType<ListActionsPluginProvides & ListInputFieldsPluginProvides & ManifestPluginProvides>;
16
+ sdk: ListActionsPluginProvides & ListInputFieldsPluginProvides & ManifestPluginProvides;
17
17
  }): Promise<string>;
18
18
  private createSourceFile;
19
19
  private createImportStatement;
@@ -1,4 +1,4 @@
1
- import type { Plugin, GetSdkType, ListActionsPluginProvides, ListAppsPluginProvides, ListInputFieldsPluginProvides, ListConnectionsPluginProvides } from "@zapier/zapier-sdk";
1
+ import type { Plugin, ListActionsPluginProvides, ListAppsPluginProvides, ListInputFieldsPluginProvides, ListConnectionsPluginProvides } from "@zapier/zapier-sdk";
2
2
  import { AddSchema, type AddOptions } from "./schemas";
3
3
  import { type GenerateAppTypesPluginProvides } from "../generateAppTypes";
4
4
  import { type BuildManifestPluginProvides } from "../buildManifest";
@@ -12,4 +12,4 @@ export interface AddPluginProvides {
12
12
  };
13
13
  };
14
14
  }
15
- export declare const addPlugin: Plugin<GetSdkType<ListAppsPluginProvides & ListActionsPluginProvides & ListInputFieldsPluginProvides & ListConnectionsPluginProvides & BuildManifestPluginProvides & GenerateAppTypesPluginProvides>, {}, AddPluginProvides>;
15
+ export declare const addPlugin: Plugin<ListAppsPluginProvides & ListActionsPluginProvides & ListInputFieldsPluginProvides & ListConnectionsPluginProvides & BuildManifestPluginProvides & GenerateAppTypesPluginProvides, AddPluginProvides>;
@@ -2,7 +2,7 @@ import { createFunction } from "@zapier/zapier-sdk";
2
2
  import { AddSchema } from "./schemas";
3
3
  import { detectTypesOutputDirectory } from "../../utils/directory-detection";
4
4
  import { resolve } from "path";
5
- export const addPlugin = ({ sdk }) => {
5
+ export const addPlugin = (sdk) => {
6
6
  const add = createFunction(async function add(options) {
7
7
  const { apps: appKeys, connections: connectionIds, configPath, typesOutput = await detectTypesOutputDirectory(), } = options;
8
8
  const resolvedTypesOutput = resolve(typesOutput);
@@ -1,4 +1,4 @@
1
- import type { Plugin, GetSdkType, GetContextType, ListAppsPluginProvides, ManifestPluginProvides } from "@zapier/zapier-sdk";
1
+ import type { Plugin, ListAppsPluginProvides, ManifestPluginProvides } from "@zapier/zapier-sdk";
2
2
  import { BuildManifestSchema, type BuildManifestOptions, type BuildManifestResult } from "./schemas";
3
3
  export interface BuildManifestPluginProvides {
4
4
  buildManifest: (options: BuildManifestOptions) => Promise<BuildManifestResult>;
@@ -10,4 +10,4 @@ export interface BuildManifestPluginProvides {
10
10
  };
11
11
  };
12
12
  }
13
- export declare const buildManifestPlugin: Plugin<GetSdkType<ListAppsPluginProvides>, GetContextType<ManifestPluginProvides>, BuildManifestPluginProvides>;
13
+ export declare const buildManifestPlugin: Plugin<ListAppsPluginProvides & ManifestPluginProvides, BuildManifestPluginProvides>;
@@ -1,7 +1,7 @@
1
1
  import { createFunction, ZapierValidationError, ZapierUnknownError, } from "@zapier/zapier-sdk";
2
2
  import { BuildManifestSchema, } from "./schemas";
3
3
  import { createManifestEntry } from "../../utils/manifest-helpers";
4
- export const buildManifestPlugin = ({ sdk, context }) => {
4
+ export const buildManifestPlugin = (sdk) => {
5
5
  const buildManifest = createFunction(async function buildManifest(options) {
6
6
  const { apps: appKeys, skipWrite = false, configPath, onProgress, } = options;
7
7
  onProgress?.({ type: "apps_lookup_start", count: appKeys.length });
@@ -31,7 +31,7 @@ export const buildManifestPlugin = ({ sdk, context }) => {
31
31
  manifestKey: manifestEntry.implementationName,
32
32
  version: manifestEntry.version || "",
33
33
  });
34
- const { key: updatedManifestKey, manifest } = await context.updateManifestEntry({
34
+ const { key: updatedManifestKey, manifest } = await sdk.context.updateManifestEntry({
35
35
  appKey: app.key,
36
36
  entry: manifestEntry,
37
37
  configPath,
@@ -11,5 +11,4 @@ export interface BundleCodePluginProvides {
11
11
  };
12
12
  }
13
13
  export declare const bundleCodePlugin: Plugin<{}, // requires no existing SDK methods
14
- {}, // requires no context
15
14
  BundleCodePluginProvides>;
@@ -14,9 +14,11 @@ interface CliOverridesProvides {
14
14
  * CLI-specific metadata overrides.
15
15
  * Adds "deprecated" category to fetch so it's hidden from CLI help.
16
16
  */
17
- export declare const cliOverridesPlugin: Plugin<{}, {
18
- meta: {
19
- fetch?: FetchMeta;
17
+ export declare const cliOverridesPlugin: Plugin<{
18
+ context: {
19
+ meta: {
20
+ fetch?: FetchMeta;
21
+ };
20
22
  };
21
23
  }, CliOverridesProvides>;
22
24
  export {};
@@ -2,16 +2,19 @@
2
2
  * CLI-specific metadata overrides.
3
3
  * Adds "deprecated" category to fetch so it's hidden from CLI help.
4
4
  */
5
- export const cliOverridesPlugin = ({ context }) => {
6
- if (!context.meta.fetch) {
5
+ export const cliOverridesPlugin = (sdk) => {
6
+ if (!sdk.context.meta.fetch) {
7
7
  return { context: { meta: {} } };
8
8
  }
9
9
  return {
10
10
  context: {
11
11
  meta: {
12
12
  fetch: {
13
- ...context.meta.fetch,
14
- categories: [...(context.meta.fetch.categories || []), "deprecated"],
13
+ ...sdk.context.meta.fetch,
14
+ categories: [
15
+ ...(sdk.context.meta.fetch.categories || []),
16
+ "deprecated",
17
+ ],
15
18
  deprecation: {
16
19
  message: "This command is deprecated and will be removed soon. Use `curl` instead. Learn more: https://docs.zapier.com/sdk/cli-reference#curl",
17
20
  },
@@ -13,5 +13,5 @@ export interface CurlPluginProvides {
13
13
  type SdkWithFetch = FetchPluginProvides["fetch"] extends infer F ? {
14
14
  fetch: F;
15
15
  } : never;
16
- export declare const curlPlugin: Plugin<SdkWithFetch, {}, CurlPluginProvides>;
16
+ export declare const curlPlugin: Plugin<SdkWithFetch, CurlPluginProvides>;
17
17
  export {};
@@ -3,7 +3,7 @@ import { promises as fs } from "fs";
3
3
  import { dirname } from "path";
4
4
  import { CurlSchema } from "./schemas";
5
5
  import { CurlExitError, parseHeaderLine, basicAuthHeader, deriveRemoteFilename, formatWriteOut, appendQueryParams, readAllStdin, resolveDataArgText, resolveDataArgBinary, buildFormData, } from "./utils";
6
- export const curlPlugin = ({ sdk, }) => {
6
+ export const curlPlugin = (sdk) => {
7
7
  async function curl(options) {
8
8
  const { url: rawUrl, request, header = [], data = [], dataRaw = [], dataAscii = [], dataBinary = [], dataUrlencode = [], json, form = [], formString = [], get: forceGet, head: forceHead, location, include, output, remoteName, verbose, silent, showError, fail, failWithBody, writeOut, maxTime, user, compressed, connection: connectionParam, connectionId, } = options;
9
9
  const connection = connectionParam ?? connectionId;
@@ -10,4 +10,10 @@ export interface FeedbackPluginProvides {
10
10
  };
11
11
  };
12
12
  }
13
- export declare const feedbackPlugin: Plugin<{}, {}, FeedbackPluginProvides>;
13
+ export declare const feedbackPlugin: Plugin<{
14
+ context: {
15
+ options?: {
16
+ debug?: boolean;
17
+ };
18
+ };
19
+ }, FeedbackPluginProvides>;
@@ -27,8 +27,8 @@ async function postWithRetry({ body, attemptsLeft, }) {
27
27
  }
28
28
  return response;
29
29
  }
30
- export const feedbackPlugin = ({ context, }) => {
31
- const debug = context.options.debug;
30
+ export const feedbackPlugin = (sdk) => {
31
+ const debug = sdk.context.options?.debug;
32
32
  const feedbackWithSdk = createFunction(async function feedback(options) {
33
33
  const user = await getLoggedInUser();
34
34
  const body = JSON.stringify({
@@ -1,4 +1,4 @@
1
- import type { Plugin, GetSdkType, ListActionsPluginProvides, ListAppsPluginProvides, ListInputFieldsPluginProvides, ListConnectionsPluginProvides, ManifestPluginProvides } from "@zapier/zapier-sdk";
1
+ import type { Plugin, ListActionsPluginProvides, ListAppsPluginProvides, ListInputFieldsPluginProvides, ListConnectionsPluginProvides, ManifestPluginProvides } from "@zapier/zapier-sdk";
2
2
  import { GenerateAppTypesSchema, type GenerateAppTypesOptions, type GenerateAppTypesResult } from "./schemas";
3
3
  export interface GenerateAppTypesPluginProvides {
4
4
  generateAppTypes: (options: GenerateAppTypesOptions) => Promise<GenerateAppTypesResult>;
@@ -10,4 +10,4 @@ export interface GenerateAppTypesPluginProvides {
10
10
  };
11
11
  };
12
12
  }
13
- export declare const generateAppTypesPlugin: Plugin<GetSdkType<ListAppsPluginProvides & ListActionsPluginProvides & ListInputFieldsPluginProvides & ListConnectionsPluginProvides & ManifestPluginProvides>, {}, GenerateAppTypesPluginProvides>;
13
+ export declare const generateAppTypesPlugin: Plugin<ListAppsPluginProvides & ListActionsPluginProvides & ListInputFieldsPluginProvides & ListConnectionsPluginProvides & ManifestPluginProvides, GenerateAppTypesPluginProvides>;
@@ -5,7 +5,7 @@ import { getManifestKey } from "../../utils/manifest-helpers";
5
5
  import { mkdir, writeFile } from "fs/promises";
6
6
  import { join, resolve } from "path";
7
7
  import { detectTypesOutputDirectory } from "../../utils/directory-detection";
8
- export const generateAppTypesPlugin = ({ sdk }) => {
8
+ export const generateAppTypesPlugin = (sdk) => {
9
9
  const generateAppTypes = createFunction(async function generateAppTypes(options) {
10
10
  const { apps: appKeys, connections: connectionIds, skipWrite = false, typesOutputDirectory = await detectTypesOutputDirectory(), onProgress, } = options;
11
11
  const resolvedTypesOutput = resolve(typesOutputDirectory);
@@ -11,5 +11,4 @@ export interface GetLoginConfigPathPluginProvides {
11
11
  };
12
12
  }
13
13
  export declare const getLoginConfigPathPlugin: Plugin<{}, // requires no existing SDK methods
14
- {}, // requires no context
15
14
  GetLoginConfigPathPluginProvides>;
@@ -12,5 +12,5 @@ interface InitPluginProvides {
12
12
  };
13
13
  };
14
14
  }
15
- export declare const initPlugin: Plugin<{}, {}, InitPluginProvides>;
15
+ export declare const initPlugin: Plugin<{}, InitPluginProvides>;
16
16
  export type { InitPluginProvides };
@@ -1,6 +1,6 @@
1
- import type { Plugin, ResolvedCredentials, EventEmissionContext } from "@zapier/zapier-sdk";
1
+ import type { Plugin, ResolvedCredentials, EventEmissionProvides } from "@zapier/zapier-sdk";
2
2
  import { LoginSchema, type LoginOptions } from "./schemas";
3
- interface CliContext extends EventEmissionContext {
3
+ interface CliContext {
4
4
  session_id?: string | null;
5
5
  selected_api?: string | null;
6
6
  app_id?: number | null;
@@ -18,5 +18,7 @@ interface LoginPluginProvides {
18
18
  };
19
19
  };
20
20
  }
21
- export declare const loginPlugin: Plugin<{}, CliContext, LoginPluginProvides>;
21
+ export declare const loginPlugin: Plugin<EventEmissionProvides & {
22
+ context: CliContext;
23
+ }, LoginPluginProvides>;
22
24
  export type { LoginPluginProvides };
@@ -15,7 +15,7 @@ function toPkceCredentials(credentials) {
15
15
  }
16
16
  return undefined;
17
17
  }
18
- export const loginPlugin = ({ context, }) => {
18
+ export const loginPlugin = (sdk) => {
19
19
  const loginFn = async (options) => {
20
20
  const timeoutSeconds = options.timeout
21
21
  ? parseInt(options.timeout, 10)
@@ -23,14 +23,14 @@ export const loginPlugin = ({ context, }) => {
23
23
  if (isNaN(timeoutSeconds) || timeoutSeconds <= 0) {
24
24
  throw new Error("Timeout must be a positive number");
25
25
  }
26
- const resolvedCredentials = await context.resolveCredentials();
26
+ const resolvedCredentials = await sdk.context.resolveCredentials();
27
27
  const pkceCredentials = toPkceCredentials(resolvedCredentials);
28
28
  await login({
29
29
  timeoutMs: timeoutSeconds * 1000,
30
30
  credentials: pkceCredentials,
31
31
  });
32
32
  const user = await getLoggedInUser();
33
- context.eventEmission.emit("platform.sdk.ApplicationLifecycleEvent", buildApplicationLifecycleEvent({ lifecycle_event_type: "login_success" }, { customuser_id: user.customUserId, account_id: user.accountId }));
33
+ sdk.context.eventEmission.emit("platform.sdk.ApplicationLifecycleEvent", buildApplicationLifecycleEvent({ lifecycle_event_type: "login_success" }, { customuser_id: user.customUserId, account_id: user.accountId }));
34
34
  console.log(`✅ Successfully logged in as ${user.email}`);
35
35
  };
36
36
  return {
@@ -11,5 +11,5 @@ interface LogoutPluginProvides {
11
11
  };
12
12
  };
13
13
  }
14
- export declare const logoutPlugin: Plugin<{}, {}, LogoutPluginProvides>;
14
+ export declare const logoutPlugin: Plugin<{}, LogoutPluginProvides>;
15
15
  export type { LogoutPluginProvides };
@@ -11,5 +11,11 @@ interface McpPluginProvides {
11
11
  };
12
12
  };
13
13
  }
14
- export declare const mcpPlugin: Plugin<{}, {}, McpPluginProvides>;
14
+ export declare const mcpPlugin: Plugin<{
15
+ context: {
16
+ options?: {
17
+ debug?: boolean;
18
+ };
19
+ };
20
+ }, McpPluginProvides>;
15
21
  export type { McpPluginProvides };
@@ -1,12 +1,12 @@
1
1
  import { createFunction } from "@zapier/zapier-sdk";
2
2
  import { startMcpServer } from "@zapier/zapier-sdk-mcp";
3
3
  import { McpSchema } from "./schemas";
4
- export const mcpPlugin = ({ context }) => {
4
+ export const mcpPlugin = (sdk) => {
5
5
  const mcpWithSdk = createFunction(async function mcpWithSdk(options) {
6
6
  // Pass through the SDK's debug option to the MCP server
7
7
  const mcpOptions = {
8
8
  ...options,
9
- debug: context.options.debug,
9
+ debug: sdk.context.options?.debug,
10
10
  };
11
11
  return await startMcpServer(mcpOptions);
12
12
  }, McpSchema);
@@ -1,6 +1,5 @@
1
- import type { GetSdkType, ZapierSdk } from "@zapier/zapier-sdk";
1
+ import type { ZapierSdk } from "@zapier/zapier-sdk";
2
2
  import type { BuildManifestPluginProvides } from "../plugins/buildManifest";
3
3
  import type { FeedbackPluginProvides } from "../plugins/feedback";
4
4
  import type { GenerateAppTypesPluginProvides } from "../plugins/generateAppTypes";
5
- export interface ZapierSdkCli extends GetSdkType<ZapierSdk & BuildManifestPluginProvides & FeedbackPluginProvides & GenerateAppTypesPluginProvides> {
6
- }
5
+ export type ZapierSdkCli = ZapierSdk & BuildManifestPluginProvides & FeedbackPluginProvides & GenerateAppTypesPluginProvides;
@@ -607,9 +607,7 @@ function createCommandConfig(cliCommandName, functionInfo, sdk) {
607
607
  selected_api: resolvedParams.app ?? null,
608
608
  },
609
609
  });
610
- sdk
611
- .getContext()
612
- .eventEmission.emit(CLI_COMMAND_EXECUTED_EVENT_SUBJECT, event);
610
+ sdk.context.eventEmission.emit(CLI_COMMAND_EXECUTED_EVENT_SUBJECT, event);
613
611
  }
614
612
  catch {
615
613
  // Never let telemetry failures affect command execution
@@ -387,7 +387,7 @@ export class SchemaParameterResolver {
387
387
  if (!hasMore &&
388
388
  promptConfig.choices &&
389
389
  dynamicResolver.requireCapabilities) {
390
- const capContext = context.sdk.getContext();
390
+ const capContext = context.sdk.context;
391
391
  if (capContext.hasCapability) {
392
392
  for (const cap of dynamicResolver.requireCapabilities) {
393
393
  const enabled = await capContext.hasCapability(cap);