@zapier/zapier-sdk-cli 0.40.0 → 0.40.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.
- package/CHANGELOG.md +9 -0
- package/dist/cli.cjs +27 -27
- package/dist/cli.mjs +27 -27
- package/dist/index.cjs +20 -23
- package/dist/index.d.mts +2 -3
- package/dist/index.d.ts +2 -3
- package/dist/index.mjs +20 -23
- package/dist/package.json +1 -1
- package/dist/src/cli.js +1 -1
- package/dist/src/generators/ast-generator.d.ts +2 -2
- package/dist/src/plugins/add/index.d.ts +2 -2
- package/dist/src/plugins/add/index.js +1 -1
- package/dist/src/plugins/buildManifest/index.d.ts +2 -2
- package/dist/src/plugins/buildManifest/index.js +2 -2
- package/dist/src/plugins/bundleCode/index.d.ts +0 -1
- package/dist/src/plugins/cliOverrides/index.d.ts +5 -3
- package/dist/src/plugins/cliOverrides/index.js +7 -4
- package/dist/src/plugins/curl/index.d.ts +1 -1
- package/dist/src/plugins/curl/index.js +1 -1
- package/dist/src/plugins/feedback/index.d.ts +7 -1
- package/dist/src/plugins/feedback/index.js +2 -2
- package/dist/src/plugins/generateAppTypes/index.d.ts +2 -2
- package/dist/src/plugins/generateAppTypes/index.js +1 -1
- package/dist/src/plugins/getLoginConfigPath/index.d.ts +0 -1
- package/dist/src/plugins/init/index.d.ts +1 -1
- package/dist/src/plugins/login/index.d.ts +5 -3
- package/dist/src/plugins/login/index.js +3 -3
- package/dist/src/plugins/logout/index.d.ts +1 -1
- package/dist/src/plugins/mcp/index.d.ts +7 -1
- package/dist/src/plugins/mcp/index.js +2 -2
- package/dist/src/types/sdk.d.ts +2 -3
- package/dist/src/utils/cli-generator.js +1 -3
- package/dist/src/utils/parameter-resolver.js +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +3 -3
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { Plugin,
|
|
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<
|
|
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 = (
|
|
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,
|
|
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<
|
|
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 = (
|
|
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,
|
|
@@ -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
|
-
|
|
19
|
-
|
|
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 = (
|
|
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: [
|
|
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,
|
|
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 = (
|
|
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<{
|
|
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 = (
|
|
31
|
-
const debug = context.options
|
|
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,
|
|
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<
|
|
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 = (
|
|
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);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import type { Plugin, ResolvedCredentials,
|
|
1
|
+
import type { Plugin, ResolvedCredentials, EventEmissionProvides } from "@zapier/zapier-sdk";
|
|
2
2
|
import { LoginSchema, type LoginOptions } from "./schemas";
|
|
3
|
-
interface CliContext
|
|
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<
|
|
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 = (
|
|
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,11 @@ interface McpPluginProvides {
|
|
|
11
11
|
};
|
|
12
12
|
};
|
|
13
13
|
}
|
|
14
|
-
export declare const mcpPlugin: Plugin<{
|
|
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 = (
|
|
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
|
|
9
|
+
debug: sdk.context.options?.debug,
|
|
10
10
|
};
|
|
11
11
|
return await startMcpServer(mcpOptions);
|
|
12
12
|
}, McpSchema);
|
package/dist/src/types/sdk.d.ts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import type {
|
|
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
|
|
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.
|
|
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);
|