@zapier/zapier-sdk-cli 0.59.0 → 0.59.2
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 +33 -0
- package/dist/cli.cjs +2 -2
- package/dist/cli.mjs +2 -2
- package/dist/experimental.cjs +1 -1
- package/dist/experimental.mjs +1 -1
- package/dist/index.cjs +2 -2
- package/dist/index.mjs +2 -2
- package/package.json +4 -4
- package/dist/package.json +0 -121
- package/dist/src/cli.d.ts +0 -2
- package/dist/src/cli.js +0 -219
- package/dist/src/experimental.d.ts +0 -33
- package/dist/src/experimental.js +0 -86
- package/dist/src/generators/ast-generator.d.ts +0 -41
- package/dist/src/generators/ast-generator.js +0 -405
- package/dist/src/index.d.ts +0 -5
- package/dist/src/index.js +0 -5
- package/dist/src/login/config.d.ts +0 -4
- package/dist/src/login/config.js +0 -21
- package/dist/src/login/credentials-revoke.d.ts +0 -14
- package/dist/src/login/credentials-revoke.js +0 -95
- package/dist/src/login/credentials-store.d.ts +0 -60
- package/dist/src/login/credentials-store.js +0 -181
- package/dist/src/login/filesystem-cache.d.ts +0 -25
- package/dist/src/login/filesystem-cache.js +0 -195
- package/dist/src/login/index.d.ts +0 -110
- package/dist/src/login/index.js +0 -424
- package/dist/src/login/keychain.d.ts +0 -18
- package/dist/src/login/keychain.js +0 -74
- package/dist/src/login/legacy-jwt.d.ts +0 -4
- package/dist/src/login/legacy-jwt.js +0 -18
- package/dist/src/login.d.ts +0 -10
- package/dist/src/login.js +0 -10
- package/dist/src/paths.d.ts +0 -1
- package/dist/src/paths.js +0 -6
- package/dist/src/plugins/add/index.d.ts +0 -254
- package/dist/src/plugins/add/index.js +0 -95
- package/dist/src/plugins/add/schemas.d.ts +0 -8
- package/dist/src/plugins/add/schemas.js +0 -22
- package/dist/src/plugins/auth/credentials-base-url.d.ts +0 -11
- package/dist/src/plugins/auth/credentials-base-url.js +0 -24
- package/dist/src/plugins/buildManifest/index.d.ts +0 -120
- package/dist/src/plugins/buildManifest/index.js +0 -71
- package/dist/src/plugins/buildManifest/schemas.d.ts +0 -44
- package/dist/src/plugins/buildManifest/schemas.js +0 -17
- package/dist/src/plugins/bundleCode/index.d.ts +0 -23
- package/dist/src/plugins/bundleCode/index.js +0 -62
- package/dist/src/plugins/bundleCode/schemas.d.ts +0 -10
- package/dist/src/plugins/bundleCode/schemas.js +0 -19
- package/dist/src/plugins/cliOverrides/index.d.ts +0 -21
- package/dist/src/plugins/cliOverrides/index.js +0 -17
- package/dist/src/plugins/curl/index.d.ts +0 -76
- package/dist/src/plugins/curl/index.js +0 -236
- package/dist/src/plugins/curl/schemas.d.ts +0 -40
- package/dist/src/plugins/curl/schemas.js +0 -108
- package/dist/src/plugins/curl/utils.d.ts +0 -34
- package/dist/src/plugins/curl/utils.js +0 -150
- package/dist/src/plugins/drainTriggerInbox/index.d.ts +0 -46
- package/dist/src/plugins/drainTriggerInbox/index.js +0 -178
- package/dist/src/plugins/feedback/index.d.ts +0 -24
- package/dist/src/plugins/feedback/index.js +0 -52
- package/dist/src/plugins/feedback/schemas.d.ts +0 -5
- package/dist/src/plugins/feedback/schemas.js +0 -8
- package/dist/src/plugins/generateAppTypes/index.d.ts +0 -265
- package/dist/src/plugins/generateAppTypes/index.js +0 -129
- package/dist/src/plugins/generateAppTypes/schemas.d.ts +0 -58
- package/dist/src/plugins/generateAppTypes/schemas.js +0 -21
- package/dist/src/plugins/getLoginConfigPath/index.d.ts +0 -16
- package/dist/src/plugins/getLoginConfigPath/index.js +0 -9
- package/dist/src/plugins/getLoginConfigPath/schemas.d.ts +0 -3
- package/dist/src/plugins/getLoginConfigPath/schemas.js +0 -5
- package/dist/src/plugins/index.d.ts +0 -15
- package/dist/src/plugins/index.js +0 -15
- package/dist/src/plugins/init/display.d.ts +0 -9
- package/dist/src/plugins/init/display.js +0 -72
- package/dist/src/plugins/init/index.d.ts +0 -21
- package/dist/src/plugins/init/index.js +0 -56
- package/dist/src/plugins/init/schemas.d.ts +0 -9
- package/dist/src/plugins/init/schemas.js +0 -19
- package/dist/src/plugins/init/steps.d.ts +0 -39
- package/dist/src/plugins/init/steps.js +0 -141
- package/dist/src/plugins/init/types.d.ts +0 -31
- package/dist/src/plugins/init/types.js +0 -1
- package/dist/src/plugins/init/utils.d.ts +0 -48
- package/dist/src/plugins/init/utils.js +0 -135
- package/dist/src/plugins/login/index.d.ts +0 -25
- package/dist/src/plugins/login/index.js +0 -12
- package/dist/src/plugins/login/schemas.d.ts +0 -9
- package/dist/src/plugins/login/schemas.js +0 -27
- package/dist/src/plugins/logout/index.d.ts +0 -30
- package/dist/src/plugins/logout/index.js +0 -33
- package/dist/src/plugins/logout/schemas.d.ts +0 -2
- package/dist/src/plugins/logout/schemas.js +0 -4
- package/dist/src/plugins/mcp/index.d.ts +0 -28
- package/dist/src/plugins/mcp/index.js +0 -24
- package/dist/src/plugins/mcp/schemas.d.ts +0 -5
- package/dist/src/plugins/mcp/schemas.js +0 -10
- package/dist/src/plugins/signup/index.d.ts +0 -25
- package/dist/src/plugins/signup/index.js +0 -12
- package/dist/src/plugins/signup/schemas.d.ts +0 -9
- package/dist/src/plugins/signup/schemas.js +0 -26
- package/dist/src/plugins/signup/test-harness.d.ts +0 -34
- package/dist/src/plugins/signup/test-harness.js +0 -76
- package/dist/src/plugins/watchTriggerInbox/index.d.ts +0 -46
- package/dist/src/plugins/watchTriggerInbox/index.js +0 -166
- package/dist/src/sdk.d.ts +0 -17
- package/dist/src/sdk.js +0 -67
- package/dist/src/telemetry/builders.d.ts +0 -44
- package/dist/src/telemetry/builders.js +0 -59
- package/dist/src/telemetry/events.d.ts +0 -40
- package/dist/src/telemetry/events.js +0 -4
- package/dist/src/types/sdk.d.ts +0 -6
- package/dist/src/types/sdk.js +0 -1
- package/dist/src/utils/api/client.d.ts +0 -15
- package/dist/src/utils/api/client.js +0 -27
- package/dist/src/utils/approval-errors.d.ts +0 -1
- package/dist/src/utils/approval-errors.js +0 -9
- package/dist/src/utils/approval-progress.d.ts +0 -12
- package/dist/src/utils/approval-progress.js +0 -179
- package/dist/src/utils/auth/account-auth.d.ts +0 -33
- package/dist/src/utils/auth/account-auth.js +0 -302
- package/dist/src/utils/auth/client-credentials.d.ts +0 -26
- package/dist/src/utils/auth/client-credentials.js +0 -67
- package/dist/src/utils/auth/oauth-callback.d.ts +0 -6
- package/dist/src/utils/auth/oauth-callback.js +0 -28
- package/dist/src/utils/auth/oauth-errors.d.ts +0 -2
- package/dist/src/utils/auth/oauth-errors.js +0 -39
- package/dist/src/utils/auth/oauth-flow.d.ts +0 -37
- package/dist/src/utils/auth/oauth-flow.js +0 -313
- package/dist/src/utils/auth/oauth-transaction.d.ts +0 -35
- package/dist/src/utils/auth/oauth-transaction.js +0 -69
- package/dist/src/utils/cli-generator-utils.d.ts +0 -14
- package/dist/src/utils/cli-generator-utils.js +0 -122
- package/dist/src/utils/cli-generator.d.ts +0 -4
- package/dist/src/utils/cli-generator.js +0 -831
- package/dist/src/utils/cli-options.d.ts +0 -16
- package/dist/src/utils/cli-options.js +0 -34
- package/dist/src/utils/cli-renderer.d.ts +0 -53
- package/dist/src/utils/cli-renderer.js +0 -265
- package/dist/src/utils/constants.d.ts +0 -3
- package/dist/src/utils/constants.js +0 -5
- package/dist/src/utils/directory-detection.d.ts +0 -5
- package/dist/src/utils/directory-detection.js +0 -21
- package/dist/src/utils/errors.d.ts +0 -33
- package/dist/src/utils/errors.js +0 -36
- package/dist/src/utils/extensions.d.ts +0 -20
- package/dist/src/utils/extensions.js +0 -66
- package/dist/src/utils/getCallablePromise.d.ts +0 -6
- package/dist/src/utils/getCallablePromise.js +0 -14
- package/dist/src/utils/log.d.ts +0 -8
- package/dist/src/utils/log.js +0 -26
- package/dist/src/utils/manifest-helpers.d.ts +0 -10
- package/dist/src/utils/manifest-helpers.js +0 -19
- package/dist/src/utils/non-interactive.d.ts +0 -14
- package/dist/src/utils/non-interactive.js +0 -15
- package/dist/src/utils/package-manager-detector.d.ts +0 -18
- package/dist/src/utils/package-manager-detector.js +0 -72
- package/dist/src/utils/parameter-resolver.d.ts +0 -179
- package/dist/src/utils/parameter-resolver.js +0 -1554
- package/dist/src/utils/retry.d.ts +0 -6
- package/dist/src/utils/retry.js +0 -21
- package/dist/src/utils/schema-formatter.d.ts +0 -11
- package/dist/src/utils/schema-formatter.js +0 -131
- package/dist/src/utils/serializeAsync.d.ts +0 -2
- package/dist/src/utils/serializeAsync.js +0 -16
- package/dist/src/utils/spinner.d.ts +0 -1
- package/dist/src/utils/spinner.js +0 -21
- package/dist/src/utils/string-utils.d.ts +0 -1
- package/dist/src/utils/string-utils.js +0 -6
- package/dist/src/utils/triggerDrain.d.ts +0 -144
- package/dist/src/utils/triggerDrain.js +0 -351
- package/dist/src/utils/version-checker.d.ts +0 -17
- package/dist/src/utils/version-checker.js +0 -154
- package/dist/tsconfig.tsbuildinfo +0 -1
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import { createPluginMethod, definePlugin, } from "@zapier/zapier-sdk";
|
|
2
|
-
import { startMcpServer } from "@zapier/zapier-sdk-mcp";
|
|
3
|
-
import { McpSchema } from "./schemas";
|
|
4
|
-
export const mcpPlugin = definePlugin((sdk) => createPluginMethod(sdk, {
|
|
5
|
-
name: "mcp",
|
|
6
|
-
categories: ["utility"],
|
|
7
|
-
inputSchema: McpSchema,
|
|
8
|
-
handler: async ({ sdk, options }) => {
|
|
9
|
-
// Forward debug, the concurrency cap, and the extensions resolved at
|
|
10
|
-
// CLI startup so the MCP server's SDK matches what the user asked
|
|
11
|
-
// for at the CLI surface. Without this forward, MCP would build a
|
|
12
|
-
// vanilla SDK and the CLI/MCP surfaces would diverge. The
|
|
13
|
-
// `experimental` flag (set by the experimental CLI factory) tells
|
|
14
|
-
// the MCP server to build against `@zapier/zapier-sdk/experimental`
|
|
15
|
-
// so experimental tools are exposed.
|
|
16
|
-
await startMcpServer({
|
|
17
|
-
...options,
|
|
18
|
-
debug: sdk.context.options?.debug,
|
|
19
|
-
maxConcurrentRequests: sdk.context.options?.maxConcurrentRequests,
|
|
20
|
-
extensions: sdk.context.extensions,
|
|
21
|
-
experimental: sdk.context.experimental,
|
|
22
|
-
});
|
|
23
|
-
},
|
|
24
|
-
}));
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import { type AccountAuthCliContext } from "../../utils/auth/account-auth";
|
|
2
|
-
export declare const signupPlugin: (sdk: {
|
|
3
|
-
context: import("@zapier/zapier-sdk").EventEmissionContext;
|
|
4
|
-
} & {
|
|
5
|
-
context: AccountAuthCliContext;
|
|
6
|
-
} & {
|
|
7
|
-
context: {
|
|
8
|
-
meta: Record<string, import("@zapier/zapier-sdk").PluginMeta>;
|
|
9
|
-
};
|
|
10
|
-
}) => {
|
|
11
|
-
signup: (options?: {
|
|
12
|
-
timeout?: string | undefined;
|
|
13
|
-
useApprovals?: boolean | undefined;
|
|
14
|
-
nonInteractive?: boolean | undefined;
|
|
15
|
-
skipPrompts?: boolean | undefined;
|
|
16
|
-
headless?: boolean | undefined;
|
|
17
|
-
} | undefined) => Promise<void>;
|
|
18
|
-
} & {
|
|
19
|
-
context: {
|
|
20
|
-
meta: {
|
|
21
|
-
signup: import("@zapier/zapier-sdk").PluginMeta<unknown>;
|
|
22
|
-
};
|
|
23
|
-
};
|
|
24
|
-
};
|
|
25
|
-
export type SignupPluginProvides = ReturnType<typeof signupPlugin>;
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { createPluginMethod, definePlugin, } from "@zapier/zapier-sdk";
|
|
2
|
-
import { runAccountAuth, } from "../../utils/auth/account-auth";
|
|
3
|
-
import { SignupSchema } from "./schemas";
|
|
4
|
-
export const signupPlugin = definePlugin((sdk) => createPluginMethod(sdk, {
|
|
5
|
-
name: "signup",
|
|
6
|
-
categories: ["account"],
|
|
7
|
-
inputSchema: SignupSchema,
|
|
8
|
-
supportsJsonOutput: false,
|
|
9
|
-
handler: async ({ sdk, options }) => {
|
|
10
|
-
await runAccountAuth({ sdk, options, entryPoint: "signup" });
|
|
11
|
-
},
|
|
12
|
-
}));
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { z } from "zod";
|
|
2
|
-
export declare const SignupSchema: z.ZodObject<{
|
|
3
|
-
timeout: z.ZodOptional<z.ZodString>;
|
|
4
|
-
useApprovals: z.ZodOptional<z.ZodBoolean>;
|
|
5
|
-
nonInteractive: z.ZodOptional<z.ZodBoolean>;
|
|
6
|
-
skipPrompts: z.ZodOptional<z.ZodBoolean>;
|
|
7
|
-
headless: z.ZodOptional<z.ZodBoolean>;
|
|
8
|
-
}, z.core.$strip>;
|
|
9
|
-
export type SignupOptions = z.infer<typeof SignupSchema>;
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import { z } from "zod";
|
|
2
|
-
export const SignupSchema = z
|
|
3
|
-
.object({
|
|
4
|
-
timeout: z
|
|
5
|
-
.string()
|
|
6
|
-
.optional()
|
|
7
|
-
.describe("Signup timeout in seconds (default: 300)"),
|
|
8
|
-
useApprovals: z
|
|
9
|
-
.boolean()
|
|
10
|
-
.optional()
|
|
11
|
-
.describe("Require approvals for actions performed with these credentials"),
|
|
12
|
-
nonInteractive: z
|
|
13
|
-
.boolean()
|
|
14
|
-
.optional()
|
|
15
|
-
.describe("Skip interactive prompts. Uses defaults where possible; errors instead of prompting when input is required. Useful in CI, piped output, or environments where TTY detection is unreliable."),
|
|
16
|
-
/** @deprecated Use `nonInteractive` instead. */
|
|
17
|
-
skipPrompts: z.boolean().optional().meta({
|
|
18
|
-
deprecated: true,
|
|
19
|
-
deprecationMessage: "Use --non-interactive instead.",
|
|
20
|
-
}),
|
|
21
|
-
headless: z
|
|
22
|
-
.boolean()
|
|
23
|
-
.optional()
|
|
24
|
-
.describe("Use when signing up from a machine that has no browser. Prints a signup link to open elsewhere, then accepts the pasted loopback callback URL."),
|
|
25
|
-
})
|
|
26
|
-
.describe("Set up Zapier account access and SDK credentials");
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
import { type EventEmissionContext, type EventEmissionProvides } from "@zapier/zapier-sdk";
|
|
2
|
-
import type { vi } from "vitest";
|
|
3
|
-
import type { CliContext } from "../../utils/auth/account-auth";
|
|
4
|
-
import { type SignupPluginProvides } from "./index";
|
|
5
|
-
type Vi = typeof vi;
|
|
6
|
-
type EventEmit = EventEmissionProvides["context"]["eventEmission"]["emit"];
|
|
7
|
-
type SignupTestContext = CliContext & EventEmissionContext;
|
|
8
|
-
interface SpyWithCalls {
|
|
9
|
-
mock: {
|
|
10
|
-
calls: unknown[][];
|
|
11
|
-
};
|
|
12
|
-
}
|
|
13
|
-
export interface SignupTestTtyState {
|
|
14
|
-
stdinIsTty: boolean | undefined;
|
|
15
|
-
stdoutIsTty: boolean | undefined;
|
|
16
|
-
}
|
|
17
|
-
export declare function getSignupTestTty(): SignupTestTtyState;
|
|
18
|
-
export declare function setSignupTestTty(value: boolean): void;
|
|
19
|
-
export declare function restoreSignupTestTty(state: SignupTestTtyState): void;
|
|
20
|
-
export declare function getSignupTestOutput(spy: SpyWithCalls): string;
|
|
21
|
-
export declare function getSignupTestLogs(spy: SpyWithCalls): string;
|
|
22
|
-
export declare function existingSignupCredentials(): {
|
|
23
|
-
name: string;
|
|
24
|
-
clientId: string;
|
|
25
|
-
createdAt: number;
|
|
26
|
-
scopes: string[];
|
|
27
|
-
baseUrl: string;
|
|
28
|
-
};
|
|
29
|
-
export declare function buildSignupTestContext(vi: Vi, mockEmit?: EventEmit): SignupTestContext;
|
|
30
|
-
export declare function createSignupTestSdk({ vi, context, }: {
|
|
31
|
-
vi: Vi;
|
|
32
|
-
context?: SignupTestContext;
|
|
33
|
-
}): SignupPluginProvides;
|
|
34
|
-
export {};
|
|
@@ -1,76 +0,0 @@
|
|
|
1
|
-
import { createSdk, } from "@zapier/zapier-sdk";
|
|
2
|
-
import { signupPlugin } from "./index";
|
|
3
|
-
export function getSignupTestTty() {
|
|
4
|
-
return {
|
|
5
|
-
stdinIsTty: process.stdin.isTTY,
|
|
6
|
-
stdoutIsTty: process.stdout.isTTY,
|
|
7
|
-
};
|
|
8
|
-
}
|
|
9
|
-
export function setSignupTestTty(value) {
|
|
10
|
-
const descriptor = { value, configurable: true, writable: true };
|
|
11
|
-
Object.defineProperty(process.stdin, "isTTY", descriptor);
|
|
12
|
-
Object.defineProperty(process.stdout, "isTTY", descriptor);
|
|
13
|
-
}
|
|
14
|
-
export function restoreSignupTestTty(state) {
|
|
15
|
-
Object.defineProperty(process.stdin, "isTTY", {
|
|
16
|
-
value: state.stdinIsTty,
|
|
17
|
-
configurable: true,
|
|
18
|
-
writable: true,
|
|
19
|
-
});
|
|
20
|
-
Object.defineProperty(process.stdout, "isTTY", {
|
|
21
|
-
value: state.stdoutIsTty,
|
|
22
|
-
configurable: true,
|
|
23
|
-
writable: true,
|
|
24
|
-
});
|
|
25
|
-
}
|
|
26
|
-
export function getSignupTestOutput(spy) {
|
|
27
|
-
return spy.mock.calls.map((call) => String(call[0])).join("");
|
|
28
|
-
}
|
|
29
|
-
export function getSignupTestLogs(spy) {
|
|
30
|
-
return spy.mock.calls.map((call) => call.map(String).join(" ")).join("\n");
|
|
31
|
-
}
|
|
32
|
-
export function existingSignupCredentials() {
|
|
33
|
-
return {
|
|
34
|
-
name: "existing",
|
|
35
|
-
clientId: "old-id",
|
|
36
|
-
createdAt: 1,
|
|
37
|
-
scopes: ["external"],
|
|
38
|
-
baseUrl: "https://zapier.com",
|
|
39
|
-
};
|
|
40
|
-
}
|
|
41
|
-
async function emptyApiResult() {
|
|
42
|
-
return undefined;
|
|
43
|
-
}
|
|
44
|
-
function createSignupTestApi() {
|
|
45
|
-
return {
|
|
46
|
-
get: emptyApiResult,
|
|
47
|
-
post: emptyApiResult,
|
|
48
|
-
put: emptyApiResult,
|
|
49
|
-
patch: emptyApiResult,
|
|
50
|
-
delete: emptyApiResult,
|
|
51
|
-
poll: emptyApiResult,
|
|
52
|
-
fetch: () => Promise.resolve(new Response()),
|
|
53
|
-
fetchStream: async function* () { },
|
|
54
|
-
fetchJsonStream: async function* () { },
|
|
55
|
-
};
|
|
56
|
-
}
|
|
57
|
-
export function buildSignupTestContext(vi, mockEmit = () => undefined) {
|
|
58
|
-
return {
|
|
59
|
-
resolveCredentials: vi.fn().mockResolvedValue(undefined),
|
|
60
|
-
api: createSignupTestApi(),
|
|
61
|
-
eventEmission: {
|
|
62
|
-
transport: { emit: vi.fn(), close: vi.fn() },
|
|
63
|
-
config: { enabled: true },
|
|
64
|
-
emit: mockEmit,
|
|
65
|
-
createBaseEvent: vi.fn().mockResolvedValue({}),
|
|
66
|
-
flush: vi.fn().mockResolvedValue(undefined),
|
|
67
|
-
close: vi.fn().mockResolvedValue(undefined),
|
|
68
|
-
},
|
|
69
|
-
hooks: { onMethodEnd: vi.fn() },
|
|
70
|
-
};
|
|
71
|
-
}
|
|
72
|
-
export function createSignupTestSdk({ vi, context = buildSignupTestContext(vi), }) {
|
|
73
|
-
return createSdk()
|
|
74
|
-
.addPlugin(() => ({ context }))
|
|
75
|
-
.addPlugin(signupPlugin);
|
|
76
|
-
}
|
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
import { z } from "zod";
|
|
2
|
-
import type { ZapierSdk } from "@zapier/zapier-sdk/experimental";
|
|
3
|
-
type SdkWithWatchTriggerInbox = {
|
|
4
|
-
watchTriggerInbox: ZapierSdk["watchTriggerInbox"];
|
|
5
|
-
context: {
|
|
6
|
-
meta: {
|
|
7
|
-
watchTriggerInbox: {
|
|
8
|
-
inputSchema?: z.ZodObject;
|
|
9
|
-
[key: string]: unknown;
|
|
10
|
-
};
|
|
11
|
-
};
|
|
12
|
-
};
|
|
13
|
-
};
|
|
14
|
-
/**
|
|
15
|
-
* CLI command for `watch-trigger-inbox`. Same flag dispatch as
|
|
16
|
-
* drain-trigger-inbox. `--continue-on-error` flows through from the
|
|
17
|
-
* auto-generated SDK schema flag; without it, the first handler
|
|
18
|
-
* failure rejects (fail-fast). Errors print live to stderr via
|
|
19
|
-
* `onError`, not buffered until the end — for a forever loop "the
|
|
20
|
-
* end" is Ctrl-C, which is too late.
|
|
21
|
-
*
|
|
22
|
-
* `--json` for watch is NDJSON streaming (one record per line)
|
|
23
|
-
* rather than a final envelope. The watch loop has no terminal
|
|
24
|
-
* aggregate to format.
|
|
25
|
-
*/
|
|
26
|
-
export declare const watchTriggerInboxCliPlugin: (sdk: SdkWithWatchTriggerInbox & {
|
|
27
|
-
context: {
|
|
28
|
-
meta: Record<string, import("@zapier/zapier-sdk").PluginMeta>;
|
|
29
|
-
};
|
|
30
|
-
}) => {
|
|
31
|
-
watchTriggerInbox: ZapierSdk["watchTriggerInbox"];
|
|
32
|
-
context: {
|
|
33
|
-
meta: {
|
|
34
|
-
watchTriggerInbox: {
|
|
35
|
-
description: string;
|
|
36
|
-
inputSchema: z.ZodObject<{
|
|
37
|
-
exec: z.ZodOptional<z.ZodString>;
|
|
38
|
-
execShell: z.ZodOptional<z.ZodString>;
|
|
39
|
-
json: z.ZodOptional<z.ZodBoolean>;
|
|
40
|
-
}, z.core.$strip>;
|
|
41
|
-
packages: undefined;
|
|
42
|
-
};
|
|
43
|
-
};
|
|
44
|
-
};
|
|
45
|
-
};
|
|
46
|
-
export {};
|
|
@@ -1,166 +0,0 @@
|
|
|
1
|
-
import { z } from "zod";
|
|
2
|
-
import { definePlugin, ZapierReleaseTriggerMessageSignal, } from "@zapier/zapier-sdk";
|
|
3
|
-
import { CliSkipLeaseExpireError, combineSignals, createInteractiveCallback, createNdjsonCallback, getPostDashArgs, printDrainError, printDrainSummary, rejectExecJsonMutex, requireInteractiveTty, runExecCommand, runShellCommand, warnInteractiveContinueOnErrorOverride, } from "../../utils/triggerDrain";
|
|
4
|
-
const JsonProperty = z
|
|
5
|
-
.boolean()
|
|
6
|
-
.optional()
|
|
7
|
-
.describe("Stream each message as JSON to stdout (one record per line, NDJSON), acking as each write completes. Use for piping to other tools. Mutually exclusive with --exec / --exec-shell and the interactive default.");
|
|
8
|
-
// Both `--exec` and `--exec-shell` are CLI-only — see drainTriggerInbox/index.ts.
|
|
9
|
-
const ExecCliProperty = z
|
|
10
|
-
.string()
|
|
11
|
-
.optional()
|
|
12
|
-
.describe("Run a binary per message with no shell interpretation. Message JSON is piped to stdin; exit code 0 acks, non-zero records the error per the same rules as a thrown handler. Pass extra argv after `--` (e.g. `--exec ./handler -- --verbose`). Mutually exclusive with --exec-shell and --json.");
|
|
13
|
-
const ExecShellCliProperty = z
|
|
14
|
-
.string()
|
|
15
|
-
.optional()
|
|
16
|
-
.describe("Run a shell command per message. Message JSON is piped to the subprocess on stdin; exit code 0 acks, non-zero records the error per the same rules as a thrown handler. Interpreted by the platform's default shell (sh on POSIX, cmd.exe on Windows). Mutually exclusive with --exec and --json.");
|
|
17
|
-
/**
|
|
18
|
-
* CLI command for `watch-trigger-inbox`. Same flag dispatch as
|
|
19
|
-
* drain-trigger-inbox. `--continue-on-error` flows through from the
|
|
20
|
-
* auto-generated SDK schema flag; without it, the first handler
|
|
21
|
-
* failure rejects (fail-fast). Errors print live to stderr via
|
|
22
|
-
* `onError`, not buffered until the end — for a forever loop "the
|
|
23
|
-
* end" is Ctrl-C, which is too late.
|
|
24
|
-
*
|
|
25
|
-
* `--json` for watch is NDJSON streaming (one record per line)
|
|
26
|
-
* rather than a final envelope. The watch loop has no terminal
|
|
27
|
-
* aggregate to format.
|
|
28
|
-
*/
|
|
29
|
-
export const watchTriggerInboxCliPlugin = definePlugin((sdk) => {
|
|
30
|
-
const original = sdk.watchTriggerInbox;
|
|
31
|
-
const existingMeta = sdk.context.meta.watchTriggerInbox;
|
|
32
|
-
const baseInputSchema = existingMeta.inputSchema;
|
|
33
|
-
// The SDK already documents that real-time health is reported on stderr;
|
|
34
|
-
// append only the CLI-specific clarification that stdout stays clean for
|
|
35
|
-
// piping. This flows into the CLI README via the doc generator's per-command
|
|
36
|
-
// `description` rendering.
|
|
37
|
-
const baseDescription = typeof existingMeta.description === "string"
|
|
38
|
-
? existingMeta.description
|
|
39
|
-
: "";
|
|
40
|
-
const cliDescription = `${baseDescription} stdout (including --json NDJSON) is unaffected.`;
|
|
41
|
-
const extendedInputSchema = baseInputSchema
|
|
42
|
-
? baseInputSchema.extend({
|
|
43
|
-
exec: ExecCliProperty,
|
|
44
|
-
execShell: ExecShellCliProperty,
|
|
45
|
-
json: JsonProperty,
|
|
46
|
-
})
|
|
47
|
-
: z.object({
|
|
48
|
-
exec: ExecCliProperty,
|
|
49
|
-
execShell: ExecShellCliProperty,
|
|
50
|
-
json: JsonProperty,
|
|
51
|
-
});
|
|
52
|
-
return {
|
|
53
|
-
watchTriggerInbox: (async (options) => {
|
|
54
|
-
const { json, exec, execShell, ...sdkArgs } = options;
|
|
55
|
-
rejectExecJsonMutex({ exec, execShell, json });
|
|
56
|
-
// Validate TTY before installing the SIGINT handler / finally,
|
|
57
|
-
// so a preflight failure doesn't print a misleading
|
|
58
|
-
// "Processed 0 messages" summary on its way out.
|
|
59
|
-
if (!exec && !execShell && !json) {
|
|
60
|
-
requireInteractiveTty("watch-trigger-inbox");
|
|
61
|
-
}
|
|
62
|
-
// SIGINT + user signal → combined.
|
|
63
|
-
const sigintController = new AbortController();
|
|
64
|
-
const onSigint = () => sigintController.abort();
|
|
65
|
-
process.on("SIGINT", onSigint);
|
|
66
|
-
const combined = combineSignals(sdkArgs.signal, sigintController.signal);
|
|
67
|
-
let fulfilled = 0;
|
|
68
|
-
let rejected = 0;
|
|
69
|
-
let skipped = 0;
|
|
70
|
-
const liveOnError = (reason, message) => {
|
|
71
|
-
rejected++;
|
|
72
|
-
printDrainError(reason, message);
|
|
73
|
-
};
|
|
74
|
-
try {
|
|
75
|
-
if (exec) {
|
|
76
|
-
const execArgv = [exec, ...getPostDashArgs()];
|
|
77
|
-
await original({
|
|
78
|
-
...sdkArgs,
|
|
79
|
-
signal: combined.signal,
|
|
80
|
-
onMessage: async (message) => {
|
|
81
|
-
await runExecCommand(execArgv, message, combined.signal);
|
|
82
|
-
fulfilled++;
|
|
83
|
-
},
|
|
84
|
-
onError: liveOnError,
|
|
85
|
-
});
|
|
86
|
-
}
|
|
87
|
-
else if (execShell) {
|
|
88
|
-
await original({
|
|
89
|
-
...sdkArgs,
|
|
90
|
-
signal: combined.signal,
|
|
91
|
-
onMessage: async (message) => {
|
|
92
|
-
await runShellCommand(execShell, message, combined.signal);
|
|
93
|
-
fulfilled++;
|
|
94
|
-
},
|
|
95
|
-
onError: liveOnError,
|
|
96
|
-
});
|
|
97
|
-
}
|
|
98
|
-
else if (json) {
|
|
99
|
-
const ndjson = createNdjsonCallback();
|
|
100
|
-
await original({
|
|
101
|
-
...sdkArgs,
|
|
102
|
-
signal: combined.signal,
|
|
103
|
-
onMessage: async (message) => {
|
|
104
|
-
await ndjson(message);
|
|
105
|
-
fulfilled++;
|
|
106
|
-
},
|
|
107
|
-
onError: liveOnError,
|
|
108
|
-
});
|
|
109
|
-
}
|
|
110
|
-
else {
|
|
111
|
-
// Interactive: continueOnError is forced true so the user's
|
|
112
|
-
// "skip (let lease expire)" choice (which throws a plain
|
|
113
|
-
// Error) doesn't tear down the loop. We don't pass onError
|
|
114
|
-
// here — user-driven skips aren't errors worth reporting,
|
|
115
|
-
// and SDK-level failures still propagate as a rejection.
|
|
116
|
-
// TTY validation already ran above the try block.
|
|
117
|
-
if (sdkArgs.continueOnError === false) {
|
|
118
|
-
warnInteractiveContinueOnErrorOverride();
|
|
119
|
-
}
|
|
120
|
-
const interactive = createInteractiveCallback();
|
|
121
|
-
await original({
|
|
122
|
-
...sdkArgs,
|
|
123
|
-
signal: combined.signal,
|
|
124
|
-
concurrency: 1,
|
|
125
|
-
continueOnError: true,
|
|
126
|
-
onMessage: async (message) => {
|
|
127
|
-
try {
|
|
128
|
-
await interactive(message);
|
|
129
|
-
fulfilled++;
|
|
130
|
-
}
|
|
131
|
-
catch (err) {
|
|
132
|
-
// See drainTriggerInbox for the counting policy: both
|
|
133
|
-
// skip flavors land in `skipped`; quit and unknown
|
|
134
|
-
// errors fall through uncounted.
|
|
135
|
-
if (err instanceof ZapierReleaseTriggerMessageSignal ||
|
|
136
|
-
err instanceof CliSkipLeaseExpireError) {
|
|
137
|
-
skipped++;
|
|
138
|
-
}
|
|
139
|
-
throw err;
|
|
140
|
-
}
|
|
141
|
-
},
|
|
142
|
-
});
|
|
143
|
-
}
|
|
144
|
-
}
|
|
145
|
-
finally {
|
|
146
|
-
process.off("SIGINT", onSigint);
|
|
147
|
-
combined.dispose();
|
|
148
|
-
// NDJSON mode emitted everything per-line; printing a
|
|
149
|
-
// summary on top would mix with the data stream.
|
|
150
|
-
if (!json) {
|
|
151
|
-
printDrainSummary({ fulfilled, rejected, skipped });
|
|
152
|
-
}
|
|
153
|
-
}
|
|
154
|
-
}),
|
|
155
|
-
context: {
|
|
156
|
-
meta: {
|
|
157
|
-
watchTriggerInbox: {
|
|
158
|
-
...existingMeta,
|
|
159
|
-
description: cliDescription,
|
|
160
|
-
inputSchema: extendedInputSchema,
|
|
161
|
-
packages: undefined,
|
|
162
|
-
},
|
|
163
|
-
},
|
|
164
|
-
},
|
|
165
|
-
};
|
|
166
|
-
});
|
package/dist/src/sdk.d.ts
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import { type Plugin, type PluginProvides, type ZapierSdkOptions } from "@zapier/zapier-sdk";
|
|
2
|
-
import type { ZapierSdkCli } from "./types/sdk";
|
|
3
|
-
export interface ZapierCliSdkOptions extends ZapierSdkOptions {
|
|
4
|
-
/**
|
|
5
|
-
* Extra plugins discovered from `@zapier/zapier-sdk` extension packages.
|
|
6
|
-
* Pre-resolved by `cli.ts` (`utils/extensions.ts`) so this factory stays
|
|
7
|
-
* synchronous. Each plugin is layered onto the chain after all built-in
|
|
8
|
-
* CLI plugins, so its functions appear in `getRegistry({ package: "cli" })`
|
|
9
|
-
* automatically.
|
|
10
|
-
*/
|
|
11
|
-
extensions?: Plugin<unknown, PluginProvides>[];
|
|
12
|
-
}
|
|
13
|
-
/**
|
|
14
|
-
* Create a Zapier SDK instance configured specifically for the CLI
|
|
15
|
-
* Includes all CLI-specific plugins in addition to the standard SDK functionality
|
|
16
|
-
*/
|
|
17
|
-
export declare function createZapierCliSdk(options?: ZapierCliSdkOptions): ZapierSdkCli;
|
package/dist/src/sdk.js
DELETED
|
@@ -1,67 +0,0 @@
|
|
|
1
|
-
import * as cliLogin from "./login";
|
|
2
|
-
import { addPlugin, createZapierSdkStack, injectCliLogin, } from "@zapier/zapier-sdk";
|
|
3
|
-
import { loginPlugin, signupPlugin, logoutPlugin, mcpPlugin, bundleCodePlugin, getLoginConfigPathPlugin, addAppsPlugin, generateAppTypesPlugin, buildManifestPlugin, feedbackPlugin, curlPlugin, cliOverridesPlugin, initPlugin,
|
|
4
|
-
// drainTriggerInboxForeverCliPlugin is experimental — registered only
|
|
5
|
-
// in `./experimental.ts`. See the "Experimental gating" section in
|
|
6
|
-
// `docs/design/2026-05-01-triggers-in-sdk.md`.
|
|
7
|
-
} from "./plugins/index";
|
|
8
|
-
import packageJson from "../package.json" with { type: "json" };
|
|
9
|
-
injectCliLogin(cliLogin);
|
|
10
|
-
/**
|
|
11
|
-
* Create a Zapier SDK instance configured specifically for the CLI
|
|
12
|
-
* Includes all CLI-specific plugins in addition to the standard SDK functionality
|
|
13
|
-
*/
|
|
14
|
-
export function createZapierCliSdk(options = {}) {
|
|
15
|
-
const { extensions = [], ...sdkOptions } = options;
|
|
16
|
-
// Stash the resolved extensions on context so `mcpPlugin` can forward
|
|
17
|
-
// them to `startMcpServer`. Without this, MCP would build a vanilla SDK
|
|
18
|
-
// with no extensions and the CLI/MCP surfaces would diverge.
|
|
19
|
-
const extensionsContextPlugin = () => ({
|
|
20
|
-
context: { extensions },
|
|
21
|
-
});
|
|
22
|
-
const sdk = createZapierSdkStack({
|
|
23
|
-
...sdkOptions,
|
|
24
|
-
eventEmission: { ...sdkOptions.eventEmission, callContext: "cli" },
|
|
25
|
-
callerPackage: { name: packageJson.name, version: packageJson.version },
|
|
26
|
-
})
|
|
27
|
-
.use(extensionsContextPlugin)
|
|
28
|
-
.use(generateAppTypesPlugin)
|
|
29
|
-
.use(buildManifestPlugin)
|
|
30
|
-
.use(bundleCodePlugin)
|
|
31
|
-
.use(getLoginConfigPathPlugin)
|
|
32
|
-
.use(addAppsPlugin)
|
|
33
|
-
.use(feedbackPlugin)
|
|
34
|
-
.use(curlPlugin)
|
|
35
|
-
.use(initPlugin)
|
|
36
|
-
.use(mcpPlugin)
|
|
37
|
-
.use(loginPlugin)
|
|
38
|
-
.use(signupPlugin)
|
|
39
|
-
.use(logoutPlugin)
|
|
40
|
-
// cliOverridesPlugin patches existing meta entries (e.g. flags `fetch`
|
|
41
|
-
// as deprecated) without re-registering the method. `.use` throws on
|
|
42
|
-
// meta-key collisions by default, so the intent has to be explicit.
|
|
43
|
-
.use(cliOverridesPlugin, { override: true })
|
|
44
|
-
.toSdk();
|
|
45
|
-
// Construct extensions defensively. The loader (`utils/extensions.ts`)
|
|
46
|
-
// already isolates *load*-time failures (failed dynamic imports);
|
|
47
|
-
// here we cover the second failure mode — a successfully-imported
|
|
48
|
-
// plugin that throws during construction (bad context lookup, schema
|
|
49
|
-
// build error, plugin collision, etc.). Honors the design-doc promise
|
|
50
|
-
// that "a broken extension does not kill the CLI."
|
|
51
|
-
//
|
|
52
|
-
// `addPlugin` mutates `sdk` in place and `mergeContribution` is
|
|
53
|
-
// atomic (validate-all-then-apply), so a failed extension leaves
|
|
54
|
-
// the sdk in its prior consistent state. Base plugins run exactly
|
|
55
|
-
// once regardless of how many extensions are installed, so the
|
|
56
|
-
// `eventEmission` startup payload reaches the wire once per
|
|
57
|
-
// process.
|
|
58
|
-
for (const ext of extensions) {
|
|
59
|
-
try {
|
|
60
|
-
addPlugin(sdk, ext);
|
|
61
|
-
}
|
|
62
|
-
catch (err) {
|
|
63
|
-
console.warn(`Extension plugin failed to construct: ${err.message}; skipping.`);
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
return sdk;
|
|
67
|
-
}
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* CLI-specific event builders
|
|
3
|
-
*
|
|
4
|
-
* Provides builder functions for CLI command telemetry that auto-populate
|
|
5
|
-
* common CLI fields and system information.
|
|
6
|
-
*/
|
|
7
|
-
import type { CliCommandExecutedEvent } from "./events";
|
|
8
|
-
export interface CliEventContext {
|
|
9
|
-
customuser_id?: number | null;
|
|
10
|
-
account_id?: number | null;
|
|
11
|
-
client_id?: string | null;
|
|
12
|
-
auth_mechanism?: string | null;
|
|
13
|
-
identity_id?: number | null;
|
|
14
|
-
visitor_id?: string | null;
|
|
15
|
-
correlation_id?: string | null;
|
|
16
|
-
session_id?: string | null;
|
|
17
|
-
selected_api?: string | null;
|
|
18
|
-
app_id?: number | null;
|
|
19
|
-
app_version_id?: number | null;
|
|
20
|
-
}
|
|
21
|
-
export interface CliCommandExecutedEventData {
|
|
22
|
-
cli_primary_command: string;
|
|
23
|
-
success_flag: boolean;
|
|
24
|
-
execution_duration_ms?: number | null;
|
|
25
|
-
exit_code?: number | null;
|
|
26
|
-
error_message?: string | null;
|
|
27
|
-
command_category?: string | null;
|
|
28
|
-
requires_auth?: boolean | null;
|
|
29
|
-
cli_arguments?: (string | null)[] | null;
|
|
30
|
-
cli_version?: string | null;
|
|
31
|
-
made_network_requests?: boolean | null;
|
|
32
|
-
files_modified_count?: number | null;
|
|
33
|
-
files_created_count?: number | null;
|
|
34
|
-
files_processed_size_bytes?: number | null;
|
|
35
|
-
peak_memory_usage_bytes?: number | null;
|
|
36
|
-
cpu_time_ms?: number | null;
|
|
37
|
-
subprocess_count?: number | null;
|
|
38
|
-
package_manager?: string | null;
|
|
39
|
-
}
|
|
40
|
-
export declare function buildCliCommandExecutedEvent({ data, context, cliVersion, }: {
|
|
41
|
-
data: CliCommandExecutedEventData;
|
|
42
|
-
context?: CliEventContext;
|
|
43
|
-
cliVersion?: string;
|
|
44
|
-
}): CliCommandExecutedEvent;
|
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* CLI-specific event builders
|
|
3
|
-
*
|
|
4
|
-
* Provides builder functions for CLI command telemetry that auto-populate
|
|
5
|
-
* common CLI fields and system information.
|
|
6
|
-
*/
|
|
7
|
-
import { generateEventId, getCurrentTimestamp, getReleaseId, getOsInfo, getPlatformVersions, isCi, getCiPlatform, getTtyContext, getAgent, } from "@zapier/zapier-sdk";
|
|
8
|
-
import cliPackageJson from "../../package.json";
|
|
9
|
-
// Create base event for CLI events
|
|
10
|
-
function createCliBaseEvent(context = {}) {
|
|
11
|
-
return {
|
|
12
|
-
event_id: generateEventId(),
|
|
13
|
-
timestamp_ms: getCurrentTimestamp(),
|
|
14
|
-
release_id: getReleaseId(),
|
|
15
|
-
customuser_id: context.customuser_id ?? null,
|
|
16
|
-
account_id: context.account_id ?? null,
|
|
17
|
-
client_id: context.client_id ?? null,
|
|
18
|
-
auth_mechanism: context.auth_mechanism ?? null,
|
|
19
|
-
identity_id: context.identity_id ?? null,
|
|
20
|
-
visitor_id: context.visitor_id ?? null,
|
|
21
|
-
correlation_id: context.correlation_id ?? null,
|
|
22
|
-
};
|
|
23
|
-
}
|
|
24
|
-
export function buildCliCommandExecutedEvent({ data, context = {}, cliVersion = cliPackageJson.version, }) {
|
|
25
|
-
const osInfo = getOsInfo();
|
|
26
|
-
const platformVersions = getPlatformVersions();
|
|
27
|
-
return {
|
|
28
|
-
...createCliBaseEvent(context),
|
|
29
|
-
system_name: "zapier-sdk-cli",
|
|
30
|
-
session_id: context.session_id ?? null,
|
|
31
|
-
cli_version: data.cli_version ?? cliVersion,
|
|
32
|
-
cli_arguments: data.cli_arguments ?? null,
|
|
33
|
-
cli_primary_command: data.cli_primary_command,
|
|
34
|
-
os_platform: osInfo.platform,
|
|
35
|
-
os_release: osInfo.release,
|
|
36
|
-
os_architecture: osInfo.architecture,
|
|
37
|
-
platform_versions: platformVersions,
|
|
38
|
-
selected_api: context.selected_api ?? null,
|
|
39
|
-
app_id: context.app_id ?? null,
|
|
40
|
-
app_version_id: context.app_version_id ?? null,
|
|
41
|
-
execution_duration_ms: data.execution_duration_ms ?? null,
|
|
42
|
-
success_flag: data.success_flag,
|
|
43
|
-
exit_code: data.exit_code ?? (data.success_flag ? 0 : 1),
|
|
44
|
-
error_message: data.error_message ?? null,
|
|
45
|
-
command_category: data.command_category ?? null,
|
|
46
|
-
requires_auth: data.requires_auth ?? null,
|
|
47
|
-
is_ci_environment: isCi(),
|
|
48
|
-
ci_platform: getCiPlatform(),
|
|
49
|
-
...getTtyContext(),
|
|
50
|
-
agent: getAgent(),
|
|
51
|
-
package_manager: data.package_manager ?? "pnpm", // Default based on project setup
|
|
52
|
-
made_network_requests: data.made_network_requests ?? null,
|
|
53
|
-
files_modified_count: data.files_modified_count ?? null,
|
|
54
|
-
files_created_count: data.files_created_count ?? null,
|
|
55
|
-
files_processed_size_bytes: data.files_processed_size_bytes ?? null,
|
|
56
|
-
cpu_time_ms: data.cpu_time_ms ?? null,
|
|
57
|
-
subprocess_count: data.subprocess_count ?? null,
|
|
58
|
-
};
|
|
59
|
-
}
|