@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.
Files changed (174) hide show
  1. package/CHANGELOG.md +33 -0
  2. package/dist/cli.cjs +2 -2
  3. package/dist/cli.mjs +2 -2
  4. package/dist/experimental.cjs +1 -1
  5. package/dist/experimental.mjs +1 -1
  6. package/dist/index.cjs +2 -2
  7. package/dist/index.mjs +2 -2
  8. package/package.json +4 -4
  9. package/dist/package.json +0 -121
  10. package/dist/src/cli.d.ts +0 -2
  11. package/dist/src/cli.js +0 -219
  12. package/dist/src/experimental.d.ts +0 -33
  13. package/dist/src/experimental.js +0 -86
  14. package/dist/src/generators/ast-generator.d.ts +0 -41
  15. package/dist/src/generators/ast-generator.js +0 -405
  16. package/dist/src/index.d.ts +0 -5
  17. package/dist/src/index.js +0 -5
  18. package/dist/src/login/config.d.ts +0 -4
  19. package/dist/src/login/config.js +0 -21
  20. package/dist/src/login/credentials-revoke.d.ts +0 -14
  21. package/dist/src/login/credentials-revoke.js +0 -95
  22. package/dist/src/login/credentials-store.d.ts +0 -60
  23. package/dist/src/login/credentials-store.js +0 -181
  24. package/dist/src/login/filesystem-cache.d.ts +0 -25
  25. package/dist/src/login/filesystem-cache.js +0 -195
  26. package/dist/src/login/index.d.ts +0 -110
  27. package/dist/src/login/index.js +0 -424
  28. package/dist/src/login/keychain.d.ts +0 -18
  29. package/dist/src/login/keychain.js +0 -74
  30. package/dist/src/login/legacy-jwt.d.ts +0 -4
  31. package/dist/src/login/legacy-jwt.js +0 -18
  32. package/dist/src/login.d.ts +0 -10
  33. package/dist/src/login.js +0 -10
  34. package/dist/src/paths.d.ts +0 -1
  35. package/dist/src/paths.js +0 -6
  36. package/dist/src/plugins/add/index.d.ts +0 -254
  37. package/dist/src/plugins/add/index.js +0 -95
  38. package/dist/src/plugins/add/schemas.d.ts +0 -8
  39. package/dist/src/plugins/add/schemas.js +0 -22
  40. package/dist/src/plugins/auth/credentials-base-url.d.ts +0 -11
  41. package/dist/src/plugins/auth/credentials-base-url.js +0 -24
  42. package/dist/src/plugins/buildManifest/index.d.ts +0 -120
  43. package/dist/src/plugins/buildManifest/index.js +0 -71
  44. package/dist/src/plugins/buildManifest/schemas.d.ts +0 -44
  45. package/dist/src/plugins/buildManifest/schemas.js +0 -17
  46. package/dist/src/plugins/bundleCode/index.d.ts +0 -23
  47. package/dist/src/plugins/bundleCode/index.js +0 -62
  48. package/dist/src/plugins/bundleCode/schemas.d.ts +0 -10
  49. package/dist/src/plugins/bundleCode/schemas.js +0 -19
  50. package/dist/src/plugins/cliOverrides/index.d.ts +0 -21
  51. package/dist/src/plugins/cliOverrides/index.js +0 -17
  52. package/dist/src/plugins/curl/index.d.ts +0 -76
  53. package/dist/src/plugins/curl/index.js +0 -236
  54. package/dist/src/plugins/curl/schemas.d.ts +0 -40
  55. package/dist/src/plugins/curl/schemas.js +0 -108
  56. package/dist/src/plugins/curl/utils.d.ts +0 -34
  57. package/dist/src/plugins/curl/utils.js +0 -150
  58. package/dist/src/plugins/drainTriggerInbox/index.d.ts +0 -46
  59. package/dist/src/plugins/drainTriggerInbox/index.js +0 -178
  60. package/dist/src/plugins/feedback/index.d.ts +0 -24
  61. package/dist/src/plugins/feedback/index.js +0 -52
  62. package/dist/src/plugins/feedback/schemas.d.ts +0 -5
  63. package/dist/src/plugins/feedback/schemas.js +0 -8
  64. package/dist/src/plugins/generateAppTypes/index.d.ts +0 -265
  65. package/dist/src/plugins/generateAppTypes/index.js +0 -129
  66. package/dist/src/plugins/generateAppTypes/schemas.d.ts +0 -58
  67. package/dist/src/plugins/generateAppTypes/schemas.js +0 -21
  68. package/dist/src/plugins/getLoginConfigPath/index.d.ts +0 -16
  69. package/dist/src/plugins/getLoginConfigPath/index.js +0 -9
  70. package/dist/src/plugins/getLoginConfigPath/schemas.d.ts +0 -3
  71. package/dist/src/plugins/getLoginConfigPath/schemas.js +0 -5
  72. package/dist/src/plugins/index.d.ts +0 -15
  73. package/dist/src/plugins/index.js +0 -15
  74. package/dist/src/plugins/init/display.d.ts +0 -9
  75. package/dist/src/plugins/init/display.js +0 -72
  76. package/dist/src/plugins/init/index.d.ts +0 -21
  77. package/dist/src/plugins/init/index.js +0 -56
  78. package/dist/src/plugins/init/schemas.d.ts +0 -9
  79. package/dist/src/plugins/init/schemas.js +0 -19
  80. package/dist/src/plugins/init/steps.d.ts +0 -39
  81. package/dist/src/plugins/init/steps.js +0 -141
  82. package/dist/src/plugins/init/types.d.ts +0 -31
  83. package/dist/src/plugins/init/types.js +0 -1
  84. package/dist/src/plugins/init/utils.d.ts +0 -48
  85. package/dist/src/plugins/init/utils.js +0 -135
  86. package/dist/src/plugins/login/index.d.ts +0 -25
  87. package/dist/src/plugins/login/index.js +0 -12
  88. package/dist/src/plugins/login/schemas.d.ts +0 -9
  89. package/dist/src/plugins/login/schemas.js +0 -27
  90. package/dist/src/plugins/logout/index.d.ts +0 -30
  91. package/dist/src/plugins/logout/index.js +0 -33
  92. package/dist/src/plugins/logout/schemas.d.ts +0 -2
  93. package/dist/src/plugins/logout/schemas.js +0 -4
  94. package/dist/src/plugins/mcp/index.d.ts +0 -28
  95. package/dist/src/plugins/mcp/index.js +0 -24
  96. package/dist/src/plugins/mcp/schemas.d.ts +0 -5
  97. package/dist/src/plugins/mcp/schemas.js +0 -10
  98. package/dist/src/plugins/signup/index.d.ts +0 -25
  99. package/dist/src/plugins/signup/index.js +0 -12
  100. package/dist/src/plugins/signup/schemas.d.ts +0 -9
  101. package/dist/src/plugins/signup/schemas.js +0 -26
  102. package/dist/src/plugins/signup/test-harness.d.ts +0 -34
  103. package/dist/src/plugins/signup/test-harness.js +0 -76
  104. package/dist/src/plugins/watchTriggerInbox/index.d.ts +0 -46
  105. package/dist/src/plugins/watchTriggerInbox/index.js +0 -166
  106. package/dist/src/sdk.d.ts +0 -17
  107. package/dist/src/sdk.js +0 -67
  108. package/dist/src/telemetry/builders.d.ts +0 -44
  109. package/dist/src/telemetry/builders.js +0 -59
  110. package/dist/src/telemetry/events.d.ts +0 -40
  111. package/dist/src/telemetry/events.js +0 -4
  112. package/dist/src/types/sdk.d.ts +0 -6
  113. package/dist/src/types/sdk.js +0 -1
  114. package/dist/src/utils/api/client.d.ts +0 -15
  115. package/dist/src/utils/api/client.js +0 -27
  116. package/dist/src/utils/approval-errors.d.ts +0 -1
  117. package/dist/src/utils/approval-errors.js +0 -9
  118. package/dist/src/utils/approval-progress.d.ts +0 -12
  119. package/dist/src/utils/approval-progress.js +0 -179
  120. package/dist/src/utils/auth/account-auth.d.ts +0 -33
  121. package/dist/src/utils/auth/account-auth.js +0 -302
  122. package/dist/src/utils/auth/client-credentials.d.ts +0 -26
  123. package/dist/src/utils/auth/client-credentials.js +0 -67
  124. package/dist/src/utils/auth/oauth-callback.d.ts +0 -6
  125. package/dist/src/utils/auth/oauth-callback.js +0 -28
  126. package/dist/src/utils/auth/oauth-errors.d.ts +0 -2
  127. package/dist/src/utils/auth/oauth-errors.js +0 -39
  128. package/dist/src/utils/auth/oauth-flow.d.ts +0 -37
  129. package/dist/src/utils/auth/oauth-flow.js +0 -313
  130. package/dist/src/utils/auth/oauth-transaction.d.ts +0 -35
  131. package/dist/src/utils/auth/oauth-transaction.js +0 -69
  132. package/dist/src/utils/cli-generator-utils.d.ts +0 -14
  133. package/dist/src/utils/cli-generator-utils.js +0 -122
  134. package/dist/src/utils/cli-generator.d.ts +0 -4
  135. package/dist/src/utils/cli-generator.js +0 -831
  136. package/dist/src/utils/cli-options.d.ts +0 -16
  137. package/dist/src/utils/cli-options.js +0 -34
  138. package/dist/src/utils/cli-renderer.d.ts +0 -53
  139. package/dist/src/utils/cli-renderer.js +0 -265
  140. package/dist/src/utils/constants.d.ts +0 -3
  141. package/dist/src/utils/constants.js +0 -5
  142. package/dist/src/utils/directory-detection.d.ts +0 -5
  143. package/dist/src/utils/directory-detection.js +0 -21
  144. package/dist/src/utils/errors.d.ts +0 -33
  145. package/dist/src/utils/errors.js +0 -36
  146. package/dist/src/utils/extensions.d.ts +0 -20
  147. package/dist/src/utils/extensions.js +0 -66
  148. package/dist/src/utils/getCallablePromise.d.ts +0 -6
  149. package/dist/src/utils/getCallablePromise.js +0 -14
  150. package/dist/src/utils/log.d.ts +0 -8
  151. package/dist/src/utils/log.js +0 -26
  152. package/dist/src/utils/manifest-helpers.d.ts +0 -10
  153. package/dist/src/utils/manifest-helpers.js +0 -19
  154. package/dist/src/utils/non-interactive.d.ts +0 -14
  155. package/dist/src/utils/non-interactive.js +0 -15
  156. package/dist/src/utils/package-manager-detector.d.ts +0 -18
  157. package/dist/src/utils/package-manager-detector.js +0 -72
  158. package/dist/src/utils/parameter-resolver.d.ts +0 -179
  159. package/dist/src/utils/parameter-resolver.js +0 -1554
  160. package/dist/src/utils/retry.d.ts +0 -6
  161. package/dist/src/utils/retry.js +0 -21
  162. package/dist/src/utils/schema-formatter.d.ts +0 -11
  163. package/dist/src/utils/schema-formatter.js +0 -131
  164. package/dist/src/utils/serializeAsync.d.ts +0 -2
  165. package/dist/src/utils/serializeAsync.js +0 -16
  166. package/dist/src/utils/spinner.d.ts +0 -1
  167. package/dist/src/utils/spinner.js +0 -21
  168. package/dist/src/utils/string-utils.d.ts +0 -1
  169. package/dist/src/utils/string-utils.js +0 -6
  170. package/dist/src/utils/triggerDrain.d.ts +0 -144
  171. package/dist/src/utils/triggerDrain.js +0 -351
  172. package/dist/src/utils/version-checker.d.ts +0 -17
  173. package/dist/src/utils/version-checker.js +0 -154
  174. package/dist/tsconfig.tsbuildinfo +0 -1
@@ -1,56 +0,0 @@
1
- import { createPluginMethod, definePlugin, } from "@zapier/zapier-sdk";
2
- import { InitSchema } from "./schemas";
3
- import { detectPackageManager } from "../../utils/package-manager-detector";
4
- import { validateInitOptions, withInterruptCleanup } from "./utils";
5
- import { getInitSteps, runStep } from "./steps";
6
- import { createConsoleDisplayHooks, displaySummaryAndNextSteps, } from "./display";
7
- import { ZapierCliExitError } from "../../utils/errors";
8
- import { resolveNonInteractive } from "../../utils/non-interactive";
9
- export { toProjectName } from "./utils";
10
- export const initPlugin = definePlugin((sdk) => createPluginMethod(sdk, {
11
- name: "init",
12
- categories: ["utility"],
13
- inputSchema: InitSchema,
14
- supportsJsonOutput: false,
15
- handler: async ({ options }) => {
16
- const { projectName: rawName } = options;
17
- const nonInteractive = resolveNonInteractive(options);
18
- const cwd = process.cwd();
19
- const { projectName, projectDir } = validateInitOptions({ rawName, cwd });
20
- const displayHooks = createConsoleDisplayHooks();
21
- const packageManagerInfo = detectPackageManager(cwd);
22
- if (packageManagerInfo.name === "unknown") {
23
- displayHooks.onWarn("Could not detect package manager, defaulting to npm.");
24
- }
25
- const packageManager = packageManagerInfo.name === "unknown" ? "npm" : packageManagerInfo.name;
26
- const steps = getInitSteps({
27
- projectDir,
28
- projectName,
29
- packageManager,
30
- displayHooks,
31
- });
32
- const completedSetupStepIds = [];
33
- for (let i = 0; i < steps.length; i++) {
34
- const step = steps[i];
35
- const succeeded = await withInterruptCleanup(step.cleanup, () => runStep({
36
- step,
37
- stepNumber: i + 1,
38
- totalSteps: steps.length,
39
- nonInteractive,
40
- displayHooks,
41
- }));
42
- if (!succeeded)
43
- break;
44
- completedSetupStepIds.push(step.id);
45
- }
46
- if (completedSetupStepIds.length === 0) {
47
- throw new ZapierCliExitError("Project setup failed — no steps completed.");
48
- }
49
- displaySummaryAndNextSteps({
50
- projectName,
51
- steps,
52
- completedSetupStepIds,
53
- packageManager,
54
- });
55
- },
56
- }));
@@ -1,9 +0,0 @@
1
- import { z } from "zod";
2
- export declare const TEMPLATES: readonly ["basic"];
3
- export type TemplateName = (typeof TEMPLATES)[number];
4
- export declare const InitSchema: z.ZodObject<{
5
- projectName: z.ZodString;
6
- nonInteractive: z.ZodOptional<z.ZodBoolean>;
7
- skipPrompts: z.ZodOptional<z.ZodBoolean>;
8
- }, z.core.$strip>;
9
- export type InitOptions = z.infer<typeof InitSchema>;
@@ -1,19 +0,0 @@
1
- import { z } from "zod";
2
- export const TEMPLATES = ["basic"];
3
- export const InitSchema = z
4
- .object({
5
- projectName: z
6
- .string()
7
- .min(1)
8
- .describe("Name of the project directory to create"),
9
- nonInteractive: z
10
- .boolean()
11
- .optional()
12
- .describe("Skip all interactive prompts and accept all defaults"),
13
- /** @deprecated Use `nonInteractive` instead. */
14
- skipPrompts: z.boolean().optional().meta({
15
- deprecated: true,
16
- deprecationMessage: "Use --non-interactive instead.",
17
- }),
18
- })
19
- .describe("Create a new Zapier SDK project in a new directory with starter files");
@@ -1,39 +0,0 @@
1
- import { type TemplateName } from "./schemas";
2
- import { type PackageManager } from "../../utils/package-manager-detector";
3
- import type { DisplayHooks, SetupStep, SetupStepId, RunnableSetupStep } from "./types";
4
- export type { DisplayHooks, SetupStep, SetupStepId, RunnableSetupStep };
5
- export declare function getTemplateDir({ template, }?: {
6
- template?: TemplateName;
7
- }): string;
8
- export declare function scaffoldFiles({ projectDir, templatesDir, variables, displayHooks, }: {
9
- projectDir: string;
10
- templatesDir: string;
11
- variables?: Record<string, unknown>;
12
- displayHooks?: DisplayHooks;
13
- }): void;
14
- export declare function scaffoldProject({ projectDir, projectName, packageManager, template, displayHooks, }: {
15
- projectDir: string;
16
- projectName: string;
17
- packageManager: PackageManager;
18
- template?: TemplateName;
19
- displayHooks?: DisplayHooks;
20
- }): void;
21
- export declare function runStep({ step, stepNumber, totalSteps, nonInteractive, displayHooks, }: {
22
- step: RunnableSetupStep;
23
- stepNumber: number;
24
- totalSteps: number;
25
- nonInteractive: boolean;
26
- displayHooks?: DisplayHooks;
27
- }): Promise<boolean>;
28
- export declare function getInitSteps({ projectDir, projectName, packageManager, template, displayHooks, }: {
29
- projectDir: string;
30
- projectName: string;
31
- packageManager: PackageManager;
32
- template?: TemplateName;
33
- displayHooks?: DisplayHooks;
34
- }): RunnableSetupStep[];
35
- export declare function buildNextSteps({ projectName, leftoverSteps, execCmd, }: {
36
- projectName: string;
37
- leftoverSteps: RunnableSetupStep[];
38
- execCmd: string;
39
- }): SetupStep[];
@@ -1,141 +0,0 @@
1
- import { existsSync, mkdirSync, writeFileSync, readdirSync, copyFileSync, } from "fs";
2
- import { join, dirname, relative } from "path";
3
- import { promptYesNo, createExec, getPackageManagerCommands, getDirentParentPath, buildTemplateVariables, cleanupProject, createProjectDir, isTemplateFile, getDestRelPath, renderTemplate, } from "./utils";
4
- import { TEMPLATES } from "./schemas";
5
- import { TEMPLATES_DIR } from "../../paths";
6
- const DEFAULT_TEMPLATE = "basic";
7
- export function getTemplateDir({ template = DEFAULT_TEMPLATE, } = {}) {
8
- const dirPath = join(TEMPLATES_DIR, template);
9
- if (!existsSync(dirPath)) {
10
- throw new Error(`Template "${template}" not found at ${dirPath}. Available templates: ${TEMPLATES.join(", ")}`);
11
- }
12
- return dirPath;
13
- }
14
- export function scaffoldFiles({ projectDir, templatesDir, variables = {}, displayHooks, }) {
15
- const entries = readdirSync(templatesDir, {
16
- withFileTypes: true,
17
- recursive: true,
18
- });
19
- const files = entries.filter((e) => e.isFile());
20
- if (files.length === 0) {
21
- throw new Error(`Template directory "${templatesDir}" contains no files.`);
22
- }
23
- for (const entry of files) {
24
- const srcPath = join(getDirentParentPath(entry), entry.name);
25
- const relPath = relative(templatesDir, srcPath);
26
- const isTemplate = isTemplateFile(entry.name);
27
- const destRelPath = getDestRelPath(relPath, isTemplate);
28
- const destPath = join(projectDir, destRelPath);
29
- mkdirSync(dirname(destPath), { recursive: true });
30
- if (isTemplate) {
31
- writeFileSync(destPath, renderTemplate(srcPath, variables));
32
- }
33
- else {
34
- copyFileSync(srcPath, destPath);
35
- }
36
- displayHooks?.onItemComplete?.(destRelPath);
37
- }
38
- }
39
- export function scaffoldProject({ projectDir, projectName, packageManager, template, displayHooks, }) {
40
- const variables = buildTemplateVariables({ projectName, packageManager });
41
- const templatesDir = getTemplateDir({ template });
42
- createProjectDir({ projectDir, projectName });
43
- scaffoldFiles({ projectDir, templatesDir, variables, displayHooks });
44
- }
45
- export async function runStep({ step, stepNumber, totalSteps, nonInteractive, displayHooks, }) {
46
- if (step.askConfirmation) {
47
- const should = await promptYesNo({
48
- message: step.description,
49
- defaultValue: true,
50
- nonInteractive,
51
- });
52
- if (!should)
53
- return false;
54
- }
55
- displayHooks?.onStepStart({
56
- description: step.description,
57
- stepNumber,
58
- totalSteps,
59
- command: step.command,
60
- nonInteractive,
61
- });
62
- try {
63
- await step.run();
64
- displayHooks?.onStepSuccess({ stepNumber, totalSteps });
65
- return true;
66
- }
67
- catch (err) {
68
- step.cleanup?.();
69
- displayHooks?.onStepError({
70
- description: step.description,
71
- command: step.command,
72
- err,
73
- });
74
- return false;
75
- }
76
- }
77
- export function getInitSteps({ projectDir, projectName, packageManager, template, displayHooks, }) {
78
- if (template !== undefined &&
79
- !TEMPLATES.includes(template)) {
80
- throw new Error(`Unknown template "${template}". Available templates: ${TEMPLATES.join(", ")}`);
81
- }
82
- const { installCmd, execCmd, devCmd } = getPackageManagerCommands({
83
- packageManager,
84
- });
85
- const exec = createExec({ cwd: projectDir });
86
- return [
87
- {
88
- id: "scaffold",
89
- description: "Scaffold project files",
90
- cleanup: () => cleanupProject({ projectDir }),
91
- run: () => scaffoldProject({
92
- projectDir,
93
- projectName,
94
- packageManager,
95
- template,
96
- displayHooks,
97
- }),
98
- },
99
- {
100
- id: "install-deps",
101
- description: "Install dependencies",
102
- askConfirmation: true,
103
- command: installCmd,
104
- run: () => exec(installCmd),
105
- },
106
- {
107
- id: "login",
108
- description: "Log in to Zapier",
109
- askConfirmation: true,
110
- command: `${execCmd} zapier-sdk login`,
111
- run: () => exec(`${execCmd} zapier-sdk login`),
112
- },
113
- {
114
- id: "run",
115
- description: "Run your app",
116
- askConfirmation: true,
117
- command: devCmd,
118
- run: () => exec(devCmd),
119
- },
120
- ];
121
- }
122
- export function buildNextSteps({ projectName, leftoverSteps, execCmd, }) {
123
- return [
124
- {
125
- description: "Change into your project directory",
126
- command: `cd ${projectName}`,
127
- },
128
- ...leftoverSteps.map(({ description, command }) => ({
129
- description,
130
- command,
131
- })),
132
- {
133
- description: "Search for an app to integrate",
134
- command: `${execCmd} zapier-sdk list-apps --search "<app name>"`,
135
- },
136
- {
137
- description: "Add an app and generate TypeScript types",
138
- command: `${execCmd} zapier-sdk add <app-key>`,
139
- },
140
- ];
141
- }
@@ -1,31 +0,0 @@
1
- export interface DisplayHooks {
2
- onItemComplete: (message: string) => void;
3
- onWarn: (message: string) => void;
4
- onStepStart: (params: {
5
- description: string;
6
- stepNumber: number;
7
- totalSteps: number;
8
- command?: string;
9
- nonInteractive: boolean;
10
- }) => void;
11
- onStepSuccess: (params: {
12
- stepNumber: number;
13
- totalSteps: number;
14
- }) => void;
15
- onStepError: (params: {
16
- description: string;
17
- command?: string;
18
- err: unknown;
19
- }) => void;
20
- }
21
- export interface SetupStep {
22
- description: string;
23
- command?: string;
24
- }
25
- export type SetupStepId = "scaffold" | "install-deps" | "login" | "run";
26
- export interface RunnableSetupStep extends SetupStep {
27
- id: SetupStepId;
28
- askConfirmation?: boolean;
29
- cleanup?: () => void;
30
- run: () => void | Promise<void>;
31
- }
@@ -1 +0,0 @@
1
- export {};
@@ -1,48 +0,0 @@
1
- import type { Dirent } from "fs";
2
- import { type PackageManager } from "../../utils/package-manager-detector";
3
- export declare function getDirentParentPath(entry: Dirent): string;
4
- export declare function toProjectName(name: string): string;
5
- export declare function validateInitOptions({ rawName, cwd, }: {
6
- rawName: string;
7
- cwd: string;
8
- }): {
9
- projectName: string;
10
- projectDir: string;
11
- };
12
- export declare function createExec({ cwd }: {
13
- cwd: string;
14
- }): (cmd: string) => void;
15
- export declare function promptYesNo({ message, defaultValue, nonInteractive, }: {
16
- message: string;
17
- defaultValue: boolean;
18
- nonInteractive: boolean;
19
- }): Promise<boolean>;
20
- export declare function getPackageManagerCommands({ packageManager, }: {
21
- packageManager: PackageManager;
22
- }): {
23
- installCmd: string;
24
- devCmd: string;
25
- devScript: string;
26
- execCmd: string;
27
- };
28
- export declare function isTemplateFile(name: string): boolean;
29
- export declare function getDestRelPath(relPath: string, isTemplate: boolean): string;
30
- export declare function renderTemplate(srcPath: string, variables: Record<string, unknown>): string;
31
- export declare function buildTemplateVariables({ projectName, packageManager, }: {
32
- projectName: string;
33
- packageManager: PackageManager;
34
- }): Record<string, unknown>;
35
- export declare function cleanupProject({ projectDir }: {
36
- projectDir: string;
37
- }): void;
38
- /**
39
- * Registers a cleanup callback that fires if the process receives SIGINT while
40
- * `fn` is running. The listener is always removed once `fn` settles, preventing
41
- * listener leaks across steps. The SIGINT is re-raised after cleanup so the
42
- * shell receives a proper signal-terminated exit code (130) rather than exit(1).
43
- */
44
- export declare function withInterruptCleanup(cleanup: (() => void) | undefined, fn: () => Promise<boolean>): Promise<boolean>;
45
- export declare function createProjectDir({ projectDir, projectName, }: {
46
- projectDir: string;
47
- projectName: string;
48
- }): void;
@@ -1,135 +0,0 @@
1
- import { existsSync, mkdirSync, readFileSync, readdirSync, rmSync } from "fs";
2
- import { execSync } from "child_process";
3
- import { extname, join } from "path";
4
- import chalk from "chalk";
5
- import Handlebars from "handlebars";
6
- import inquirer from "inquirer";
7
- // Node 20 added `parentPath`; Node 18 used `path` for the same purpose.
8
- export function getDirentParentPath(entry) {
9
- const e = entry;
10
- const parent = e.parentPath ?? e.path;
11
- if (!parent)
12
- throw new Error("readdirSync entry missing parentPath/path — unsupported Node version");
13
- return parent;
14
- }
15
- export function toProjectName(name) {
16
- // Essentially converts to kebab-case
17
- return (name
18
- .toLowerCase()
19
- // Replace anything that isn't a letter, digit, or hyphen with a hyphen.
20
- // Hyphens are kept as-is since they're valid in npm package names.
21
- .replace(/[^a-z0-9-]/g, "-")
22
- .replace(/-+/g, "-") // collapse consecutive hyphens produced by the step above
23
- .replace(/^-|-$/g, "")); // strip any leading/trailing hyphens
24
- }
25
- export function validateInitOptions({ rawName, cwd, }) {
26
- const projectName = toProjectName(rawName);
27
- if (!projectName) {
28
- throw new Error(`"${rawName}" results in an empty project name. Provide a name with at least one letter or number.`);
29
- }
30
- const projectDir = join(cwd, projectName);
31
- if (existsSync(projectDir)) {
32
- const contents = readdirSync(projectDir);
33
- if (contents.length > 0) {
34
- throw new Error(`Directory "${projectName}" already exists and is not empty. Choose a different name.`);
35
- }
36
- }
37
- return { projectName, projectDir };
38
- }
39
- // shell is required on Windows where npx/npm/pnpm/yarn are .cmd files
40
- // that execSync cannot locate without a shell.
41
- export function createExec({ cwd }) {
42
- return (cmd) => execSync(cmd, {
43
- cwd,
44
- stdio: "inherit",
45
- shell: process.platform === "win32" ? "cmd.exe" : "/bin/sh",
46
- });
47
- }
48
- export async function promptYesNo({ message, defaultValue, nonInteractive, }) {
49
- if (nonInteractive)
50
- return defaultValue;
51
- const { answer } = await inquirer.prompt([
52
- { type: "confirm", name: "answer", message, default: defaultValue },
53
- ]);
54
- return answer;
55
- }
56
- export function getPackageManagerCommands({ packageManager, }) {
57
- return {
58
- installCmd: `${packageManager} install`,
59
- devCmd: packageManager === "yarn" ? "yarn dev" : `${packageManager} run dev`,
60
- devScript: packageManager === "bun" ? "bun src/index.ts" : "tsx src/index.ts",
61
- execCmd: {
62
- npm: "npx",
63
- yarn: "yarn dlx",
64
- pnpm: "pnpm dlx",
65
- bun: "bunx",
66
- }[packageManager],
67
- };
68
- }
69
- export function isTemplateFile(name) {
70
- return extname(name) === ".hbs";
71
- }
72
- export function getDestRelPath(relPath, isTemplate) {
73
- return isTemplate ? relPath.slice(0, -extname(relPath).length) : relPath;
74
- }
75
- export function renderTemplate(srcPath, variables) {
76
- const source = readFileSync(srcPath, "utf-8");
77
- // Without this, Handlebars HTML-encodes output (& → &amp;), which corrupts JSON and TypeScript files.
78
- const template = Handlebars.compile(source, { noEscape: true });
79
- return template(variables);
80
- }
81
- export function buildTemplateVariables({ projectName, packageManager, }) {
82
- const { execCmd, devScript, devCmd } = getPackageManagerCommands({
83
- packageManager,
84
- });
85
- return {
86
- projectName,
87
- execCmd,
88
- devScript,
89
- devCmd,
90
- includeTsx: packageManager !== "bun",
91
- };
92
- }
93
- export function cleanupProject({ projectDir }) {
94
- console.log("\n" + chalk.yellow("!") + " Cleaning up...");
95
- rmSync(projectDir, { recursive: true, force: true });
96
- }
97
- /**
98
- * Registers a cleanup callback that fires if the process receives SIGINT while
99
- * `fn` is running. The listener is always removed once `fn` settles, preventing
100
- * listener leaks across steps. The SIGINT is re-raised after cleanup so the
101
- * shell receives a proper signal-terminated exit code (130) rather than exit(1).
102
- */
103
- export async function withInterruptCleanup(cleanup, fn) {
104
- if (!cleanup)
105
- return fn();
106
- const handler = () => {
107
- cleanup();
108
- process.removeListener("SIGINT", handler);
109
- process.kill(process.pid, "SIGINT");
110
- };
111
- process.on("SIGINT", handler);
112
- try {
113
- return await fn();
114
- }
115
- finally {
116
- process.removeListener("SIGINT", handler);
117
- }
118
- }
119
- export function createProjectDir({ projectDir, projectName, }) {
120
- try {
121
- mkdirSync(projectDir, { recursive: true });
122
- }
123
- catch (err) {
124
- if (err instanceof Error) {
125
- const code = err.code;
126
- if (code === "EACCES") {
127
- throw new Error(`Permission denied creating "${projectName}". Check directory permissions.`);
128
- }
129
- if (code === "ENOSPC") {
130
- throw new Error("No space left on device.");
131
- }
132
- }
133
- throw err;
134
- }
135
- }
@@ -1,25 +0,0 @@
1
- import { type AccountAuthCliContext } from "../../utils/auth/account-auth";
2
- export declare const loginPlugin: (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
- login: (options?: {
12
- name?: string | undefined;
13
- timeout?: string | undefined;
14
- useApprovals?: boolean | undefined;
15
- nonInteractive?: boolean | undefined;
16
- skipPrompts?: boolean | undefined;
17
- } | undefined) => Promise<void>;
18
- } & {
19
- context: {
20
- meta: {
21
- login: import("@zapier/zapier-sdk").PluginMeta<unknown>;
22
- };
23
- };
24
- };
25
- export type LoginPluginProvides = ReturnType<typeof loginPlugin>;
@@ -1,12 +0,0 @@
1
- import { createPluginMethod, definePlugin, } from "@zapier/zapier-sdk";
2
- import { runAccountAuth, } from "../../utils/auth/account-auth";
3
- import { LoginSchema } from "./schemas";
4
- export const loginPlugin = definePlugin((sdk) => createPluginMethod(sdk, {
5
- name: "login",
6
- categories: ["account"],
7
- inputSchema: LoginSchema,
8
- supportsJsonOutput: false,
9
- handler: async ({ sdk, options }) => {
10
- await runAccountAuth({ sdk, options, entryPoint: "login" });
11
- },
12
- }));
@@ -1,9 +0,0 @@
1
- import { z } from "zod";
2
- export declare const LoginSchema: z.ZodObject<{
3
- name: z.ZodOptional<z.ZodString>;
4
- timeout: z.ZodOptional<z.ZodString>;
5
- useApprovals: z.ZodOptional<z.ZodBoolean>;
6
- nonInteractive: z.ZodOptional<z.ZodBoolean>;
7
- skipPrompts: z.ZodOptional<z.ZodBoolean>;
8
- }, z.core.$strip>;
9
- export type LoginOptions = z.infer<typeof LoginSchema>;
@@ -1,27 +0,0 @@
1
- import { z } from "zod";
2
- // Login schema
3
- export const LoginSchema = z
4
- .object({
5
- name: z
6
- .string()
7
- .optional()
8
- .describe("Name to identify these credentials (defaults to <email>@<hostname>). Provide this to set a custom name without the interactive prompt."),
9
- timeout: z
10
- .string()
11
- .optional()
12
- .describe("Login timeout in seconds (default: 300)"),
13
- useApprovals: z
14
- .boolean()
15
- .optional()
16
- .describe("Require approvals for actions performed with these credentials"),
17
- nonInteractive: z
18
- .boolean()
19
- .optional()
20
- .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."),
21
- /** @deprecated Use `nonInteractive` instead. */
22
- skipPrompts: z.boolean().optional().meta({
23
- deprecated: true,
24
- deprecationMessage: "Use --non-interactive instead.",
25
- }),
26
- })
27
- .describe("Log in to Zapier to access your account");
@@ -1,30 +0,0 @@
1
- import { type ApiClient, type ResolvedCredentials } from "@zapier/zapier-sdk";
2
- import { type LogoutEventEmitter } from "../../login/credentials-revoke";
3
- interface CliContext {
4
- api: ApiClient;
5
- resolveCredentials?: () => Promise<ResolvedCredentials | undefined>;
6
- options?: {
7
- onEvent?: LogoutEventEmitter;
8
- baseUrl?: string;
9
- credentials?: unknown;
10
- };
11
- }
12
- export declare const logoutPlugin: (sdk: {
13
- context: import("@zapier/zapier-sdk").EventEmissionContext;
14
- } & {
15
- context: CliContext;
16
- } & {
17
- context: {
18
- meta: Record<string, import("@zapier/zapier-sdk").PluginMeta>;
19
- };
20
- }) => {
21
- logout: (options?: Record<string, never> | undefined) => Promise<void>;
22
- } & {
23
- context: {
24
- meta: {
25
- logout: import("@zapier/zapier-sdk").PluginMeta<unknown>;
26
- };
27
- };
28
- };
29
- export type LogoutPluginProvides = ReturnType<typeof logoutPlugin>;
30
- export {};
@@ -1,33 +0,0 @@
1
- import { createPluginMethod, definePlugin, } from "@zapier/zapier-sdk";
2
- import { logout as jwtLogout } from "../../login";
3
- import { getActiveCredentials } from "../../login/credentials-store";
4
- import { revokeCredentials, } from "../../login/credentials-revoke";
5
- import { resolveCredentialsBaseUrl } from "../auth/credentials-base-url";
6
- import { LogoutSchema } from "./schemas";
7
- export const logoutPlugin = definePlugin((sdk) => createPluginMethod(sdk, {
8
- name: "logout",
9
- categories: ["account"],
10
- inputSchema: LogoutSchema,
11
- supportsJsonOutput: false,
12
- handler: async ({ sdk }) => {
13
- const credentialsBaseUrl = await resolveCredentialsBaseUrl(sdk.context);
14
- const activeCredentials = getActiveCredentials({
15
- baseUrl: credentialsBaseUrl,
16
- });
17
- const onEvent = sdk.context.options?.onEvent;
18
- if (!activeCredentials) {
19
- await jwtLogout({ onEvent });
20
- console.log("✅ Successfully logged out");
21
- return;
22
- }
23
- // Logout is teardown: clear local state even if the server refuses to
24
- // revoke the credential, so a permanent 4xx can't strand the user.
25
- await revokeCredentials({
26
- api: sdk.context.api,
27
- credentials: activeCredentials,
28
- onEvent,
29
- alwaysClearLocalState: true,
30
- });
31
- console.log("✅ Successfully logged out");
32
- },
33
- }));
@@ -1,2 +0,0 @@
1
- import { z } from "zod";
2
- export declare const LogoutSchema: z.ZodObject<{}, z.core.$strip>;
@@ -1,4 +0,0 @@
1
- import { z } from "zod";
2
- export const LogoutSchema = z
3
- .object({})
4
- .describe("Log out of your Zapier account");
@@ -1,28 +0,0 @@
1
- import { type Plugin, type PluginProvides } from "@zapier/zapier-sdk";
2
- export declare const mcpPlugin: (sdk: {
3
- context: {
4
- options?: {
5
- debug?: boolean;
6
- maxConcurrentRequests?: number;
7
- };
8
- extensions?: Plugin<unknown, PluginProvides>[];
9
- experimental?: boolean;
10
- };
11
- } & {
12
- context: import("@zapier/zapier-sdk").EventEmissionContext;
13
- } & {
14
- context: {
15
- meta: Record<string, import("@zapier/zapier-sdk").PluginMeta>;
16
- };
17
- }) => {
18
- mcp: (options?: {
19
- port?: string | undefined;
20
- } | undefined) => Promise<void>;
21
- } & {
22
- context: {
23
- meta: {
24
- mcp: import("@zapier/zapier-sdk").PluginMeta<unknown>;
25
- };
26
- };
27
- };
28
- export type McpPluginProvides = ReturnType<typeof mcpPlugin>;