@zapier/zapier-sdk-cli 0.39.11 → 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 +21 -0
- package/README.md +29 -29
- package/dist/cli.cjs +32 -31
- package/dist/cli.mjs +32 -31
- package/dist/index.cjs +25 -27
- package/dist/index.d.mts +2 -3
- package/dist/index.d.ts +2 -3
- package/dist/index.mjs +25 -27
- 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 +2 -3
- package/dist/src/plugins/curl/schemas.js +3 -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 +4 -4
package/dist/index.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { AppItem, Manifest,
|
|
1
|
+
import { AppItem, Manifest, ZapierSdk, ZapierSdkOptions, BaseEvent } from '@zapier/zapier-sdk';
|
|
2
2
|
import { z } from 'zod';
|
|
3
3
|
|
|
4
4
|
declare const BuildManifestSchema: z.ZodObject<{
|
|
@@ -139,8 +139,7 @@ interface GenerateAppTypesPluginProvides {
|
|
|
139
139
|
};
|
|
140
140
|
}
|
|
141
141
|
|
|
142
|
-
|
|
143
|
-
}
|
|
142
|
+
type ZapierSdkCli = ZapierSdk & BuildManifestPluginProvides & FeedbackPluginProvides & GenerateAppTypesPluginProvides;
|
|
144
143
|
|
|
145
144
|
interface ZapierCliSdkOptions extends ZapierSdkOptions {
|
|
146
145
|
}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { AppItem, Manifest,
|
|
1
|
+
import { AppItem, Manifest, ZapierSdk, ZapierSdkOptions, BaseEvent } from '@zapier/zapier-sdk';
|
|
2
2
|
import { z } from 'zod';
|
|
3
3
|
|
|
4
4
|
declare const BuildManifestSchema: z.ZodObject<{
|
|
@@ -139,8 +139,7 @@ interface GenerateAppTypesPluginProvides {
|
|
|
139
139
|
};
|
|
140
140
|
}
|
|
141
141
|
|
|
142
|
-
|
|
143
|
-
}
|
|
142
|
+
type ZapierSdkCli = ZapierSdk & BuildManifestPluginProvides & FeedbackPluginProvides & GenerateAppTypesPluginProvides;
|
|
144
143
|
|
|
145
144
|
interface ZapierCliSdkOptions extends ZapierSdkOptions {
|
|
146
145
|
}
|
package/dist/index.mjs
CHANGED
|
@@ -321,22 +321,20 @@ function toPkceCredentials(credentials) {
|
|
|
321
321
|
}
|
|
322
322
|
return void 0;
|
|
323
323
|
}
|
|
324
|
-
var loginPlugin = ({
|
|
325
|
-
context
|
|
326
|
-
}) => {
|
|
324
|
+
var loginPlugin = (sdk) => {
|
|
327
325
|
const loginFn = async (options) => {
|
|
328
326
|
const timeoutSeconds = options.timeout ? parseInt(options.timeout, 10) : 300;
|
|
329
327
|
if (isNaN(timeoutSeconds) || timeoutSeconds <= 0) {
|
|
330
328
|
throw new Error("Timeout must be a positive number");
|
|
331
329
|
}
|
|
332
|
-
const resolvedCredentials = await context.resolveCredentials();
|
|
330
|
+
const resolvedCredentials = await sdk.context.resolveCredentials();
|
|
333
331
|
const pkceCredentials = toPkceCredentials(resolvedCredentials);
|
|
334
332
|
await login_default({
|
|
335
333
|
timeoutMs: timeoutSeconds * 1e3,
|
|
336
334
|
credentials: pkceCredentials
|
|
337
335
|
});
|
|
338
336
|
const user = await getLoggedInUser();
|
|
339
|
-
context.eventEmission.emit(
|
|
337
|
+
sdk.context.eventEmission.emit(
|
|
340
338
|
"platform.sdk.ApplicationLifecycleEvent",
|
|
341
339
|
buildApplicationLifecycleEvent(
|
|
342
340
|
{ lifecycle_event_type: "login_success" },
|
|
@@ -382,11 +380,11 @@ var McpSchema = z.object({
|
|
|
382
380
|
}).describe("Start MCP server for Zapier SDK");
|
|
383
381
|
|
|
384
382
|
// src/plugins/mcp/index.ts
|
|
385
|
-
var mcpPlugin = (
|
|
383
|
+
var mcpPlugin = (sdk) => {
|
|
386
384
|
const mcpWithSdk = createFunction(async function mcpWithSdk2(options) {
|
|
387
385
|
const mcpOptions = {
|
|
388
386
|
...options,
|
|
389
|
-
debug: context.options
|
|
387
|
+
debug: sdk.context.options?.debug
|
|
390
388
|
};
|
|
391
389
|
return await startMcpServer(mcpOptions);
|
|
392
390
|
}, McpSchema);
|
|
@@ -540,7 +538,7 @@ async function detectTypesOutputDirectory() {
|
|
|
540
538
|
}
|
|
541
539
|
return "./zapier/apps/";
|
|
542
540
|
}
|
|
543
|
-
var addPlugin = (
|
|
541
|
+
var addPlugin = (sdk) => {
|
|
544
542
|
const add = createFunction(async function add2(options) {
|
|
545
543
|
const {
|
|
546
544
|
apps: appKeys,
|
|
@@ -1251,7 +1249,7 @@ function createManifestEntry(app) {
|
|
|
1251
1249
|
version: app.version
|
|
1252
1250
|
};
|
|
1253
1251
|
}
|
|
1254
|
-
var generateAppTypesPlugin = (
|
|
1252
|
+
var generateAppTypesPlugin = (sdk) => {
|
|
1255
1253
|
const generateAppTypes = createFunction(async function generateAppTypes2(options) {
|
|
1256
1254
|
const {
|
|
1257
1255
|
apps: appKeys,
|
|
@@ -1410,7 +1408,7 @@ var BuildManifestSchema = z.object({
|
|
|
1410
1408
|
);
|
|
1411
1409
|
|
|
1412
1410
|
// src/plugins/buildManifest/index.ts
|
|
1413
|
-
var buildManifestPlugin = (
|
|
1411
|
+
var buildManifestPlugin = (sdk) => {
|
|
1414
1412
|
const buildManifest = createFunction(async function buildManifest2(options) {
|
|
1415
1413
|
const {
|
|
1416
1414
|
apps: appKeys,
|
|
@@ -1444,7 +1442,7 @@ var buildManifestPlugin = ({ sdk, context }) => {
|
|
|
1444
1442
|
manifestKey: manifestEntry.implementationName,
|
|
1445
1443
|
version: manifestEntry.version || ""
|
|
1446
1444
|
});
|
|
1447
|
-
const { key: updatedManifestKey, manifest } = await context.updateManifestEntry({
|
|
1445
|
+
const { key: updatedManifestKey, manifest } = await sdk.context.updateManifestEntry({
|
|
1448
1446
|
appKey: app.key,
|
|
1449
1447
|
entry: manifestEntry,
|
|
1450
1448
|
configPath,
|
|
@@ -1523,10 +1521,8 @@ async function postWithRetry({
|
|
|
1523
1521
|
}
|
|
1524
1522
|
return response;
|
|
1525
1523
|
}
|
|
1526
|
-
var feedbackPlugin = ({
|
|
1527
|
-
context
|
|
1528
|
-
}) => {
|
|
1529
|
-
const debug = context.options.debug;
|
|
1524
|
+
var feedbackPlugin = (sdk) => {
|
|
1525
|
+
const debug = sdk.context.options?.debug;
|
|
1530
1526
|
const feedbackWithSdk = createFunction(async function feedback(options) {
|
|
1531
1527
|
const user = await getLoggedInUser();
|
|
1532
1528
|
const body = JSON.stringify({
|
|
@@ -1580,7 +1576,9 @@ var CurlSchema = z.object({
|
|
|
1580
1576
|
fail: z.boolean().optional().describe("Fail silently on HTTP errors (exit code 22)"),
|
|
1581
1577
|
failWithBody: z.boolean().optional().describe("Fail on HTTP errors but still output the body"),
|
|
1582
1578
|
writeOut: z.string().optional().describe("Output format string after completion (e.g., '%{http_code}')"),
|
|
1583
|
-
maxTime: z.number().optional().describe(
|
|
1579
|
+
maxTime: z.number().int().positive().optional().describe(
|
|
1580
|
+
"Maximum seconds to wait for a response. Honored on a best-effort basis; the server may silently enforce a lower ceiling."
|
|
1581
|
+
),
|
|
1584
1582
|
user: z.string().optional().describe("Basic auth credentials as 'user:password'"),
|
|
1585
1583
|
compressed: z.boolean().optional().describe("Request compressed response (sends Accept-Encoding header)"),
|
|
1586
1584
|
connection: z.union([z.string(), z.number()]).optional().describe("Zapier connection ID or alias for authentication"),
|
|
@@ -1729,9 +1727,7 @@ async function buildFormData(formArgs, formStringArgs) {
|
|
|
1729
1727
|
}
|
|
1730
1728
|
|
|
1731
1729
|
// src/plugins/curl/index.ts
|
|
1732
|
-
var curlPlugin = ({
|
|
1733
|
-
sdk
|
|
1734
|
-
}) => {
|
|
1730
|
+
var curlPlugin = (sdk) => {
|
|
1735
1731
|
async function curl(options) {
|
|
1736
1732
|
const {
|
|
1737
1733
|
url: rawUrl,
|
|
@@ -1863,15 +1859,14 @@ var curlPlugin = ({
|
|
|
1863
1859
|
}
|
|
1864
1860
|
process.stderr.write(">\n");
|
|
1865
1861
|
}
|
|
1866
|
-
const signal = maxTime ? AbortSignal.timeout(maxTime * 1e3) : void 0;
|
|
1867
1862
|
const start = performance.now();
|
|
1868
1863
|
const response = await sdk.fetch(effectiveUrl.toString(), {
|
|
1869
1864
|
method,
|
|
1870
1865
|
headers,
|
|
1871
1866
|
body,
|
|
1872
1867
|
redirect,
|
|
1873
|
-
|
|
1874
|
-
|
|
1868
|
+
connection,
|
|
1869
|
+
maxTime
|
|
1875
1870
|
});
|
|
1876
1871
|
const timeTotalSeconds = (performance.now() - start) / 1e3;
|
|
1877
1872
|
if (verbose && !silent) {
|
|
@@ -1978,16 +1973,19 @@ ${Array.from(
|
|
|
1978
1973
|
};
|
|
1979
1974
|
|
|
1980
1975
|
// src/plugins/cliOverrides/index.ts
|
|
1981
|
-
var cliOverridesPlugin = (
|
|
1982
|
-
if (!context.meta.fetch) {
|
|
1976
|
+
var cliOverridesPlugin = (sdk) => {
|
|
1977
|
+
if (!sdk.context.meta.fetch) {
|
|
1983
1978
|
return { context: { meta: {} } };
|
|
1984
1979
|
}
|
|
1985
1980
|
return {
|
|
1986
1981
|
context: {
|
|
1987
1982
|
meta: {
|
|
1988
1983
|
fetch: {
|
|
1989
|
-
...context.meta.fetch,
|
|
1990
|
-
categories: [
|
|
1984
|
+
...sdk.context.meta.fetch,
|
|
1985
|
+
categories: [
|
|
1986
|
+
...sdk.context.meta.fetch.categories || [],
|
|
1987
|
+
"deprecated"
|
|
1988
|
+
],
|
|
1991
1989
|
deprecation: {
|
|
1992
1990
|
message: "This command is deprecated and will be removed soon. Use `curl` instead. Learn more: https://docs.zapier.com/sdk/cli-reference#curl"
|
|
1993
1991
|
}
|
|
@@ -2479,7 +2477,7 @@ function createZapierCliSdk(options = {}) {
|
|
|
2479
2477
|
|
|
2480
2478
|
// package.json
|
|
2481
2479
|
var package_default = {
|
|
2482
|
-
version: "0.
|
|
2480
|
+
version: "0.40.1"};
|
|
2483
2481
|
|
|
2484
2482
|
// src/telemetry/builders.ts
|
|
2485
2483
|
function createCliBaseEvent(context = {}) {
|
package/dist/package.json
CHANGED
package/dist/src/cli.js
CHANGED
|
@@ -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.
|
|
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 {
|
|
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:
|
|
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,
|
|
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;
|
|
@@ -119,15 +119,14 @@ export const curlPlugin = ({ sdk, }) => {
|
|
|
119
119
|
}
|
|
120
120
|
process.stderr.write(">\n");
|
|
121
121
|
}
|
|
122
|
-
const signal = maxTime ? AbortSignal.timeout(maxTime * 1000) : undefined;
|
|
123
122
|
const start = performance.now();
|
|
124
123
|
const response = await sdk.fetch(effectiveUrl.toString(), {
|
|
125
124
|
method,
|
|
126
125
|
headers,
|
|
127
126
|
body,
|
|
128
127
|
redirect,
|
|
129
|
-
signal,
|
|
130
128
|
connection,
|
|
129
|
+
maxTime,
|
|
131
130
|
});
|
|
132
131
|
const timeTotalSeconds = (performance.now() - start) / 1000;
|
|
133
132
|
if (verbose && !silent) {
|
|
@@ -83,8 +83,10 @@ export const CurlSchema = z
|
|
|
83
83
|
.describe("Output format string after completion (e.g., '%{http_code}')"),
|
|
84
84
|
maxTime: z
|
|
85
85
|
.number()
|
|
86
|
+
.int()
|
|
87
|
+
.positive()
|
|
86
88
|
.optional()
|
|
87
|
-
.describe("Maximum
|
|
89
|
+
.describe("Maximum seconds to wait for a response. Honored on a best-effort basis; the server may silently enforce a lower ceiling."),
|
|
88
90
|
user: z
|
|
89
91
|
.string()
|
|
90
92
|
.optional()
|
|
@@ -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);
|