@zapier/zapier-sdk-cli 0.19.0 → 0.21.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (87) hide show
  1. package/dist/cli.cjs +2 -2
  2. package/dist/cli.mjs +2 -2
  3. package/dist/index.cjs +1 -1
  4. package/dist/index.mjs +1 -1
  5. package/package.json +4 -4
  6. package/dist/package.json +0 -78
  7. package/dist/src/cli.d.ts +0 -2
  8. package/dist/src/cli.js +0 -105
  9. package/dist/src/generators/ast-generator.d.ts +0 -41
  10. package/dist/src/generators/ast-generator.js +0 -409
  11. package/dist/src/index.d.ts +0 -4
  12. package/dist/src/index.js +0 -4
  13. package/dist/src/plugins/add/index.d.ts +0 -15
  14. package/dist/src/plugins/add/index.js +0 -103
  15. package/dist/src/plugins/add/schemas.d.ts +0 -8
  16. package/dist/src/plugins/add/schemas.js +0 -22
  17. package/dist/src/plugins/buildManifest/index.d.ts +0 -13
  18. package/dist/src/plugins/buildManifest/index.js +0 -81
  19. package/dist/src/plugins/buildManifest/schemas.d.ts +0 -44
  20. package/dist/src/plugins/buildManifest/schemas.js +0 -17
  21. package/dist/src/plugins/bundleCode/index.d.ts +0 -15
  22. package/dist/src/plugins/bundleCode/index.js +0 -80
  23. package/dist/src/plugins/bundleCode/schemas.d.ts +0 -10
  24. package/dist/src/plugins/bundleCode/schemas.js +0 -19
  25. package/dist/src/plugins/generateAppTypes/index.d.ts +0 -13
  26. package/dist/src/plugins/generateAppTypes/index.js +0 -157
  27. package/dist/src/plugins/generateAppTypes/schemas.d.ts +0 -58
  28. package/dist/src/plugins/generateAppTypes/schemas.js +0 -21
  29. package/dist/src/plugins/getLoginConfigPath/index.d.ts +0 -15
  30. package/dist/src/plugins/getLoginConfigPath/index.js +0 -19
  31. package/dist/src/plugins/getLoginConfigPath/schemas.d.ts +0 -3
  32. package/dist/src/plugins/getLoginConfigPath/schemas.js +0 -5
  33. package/dist/src/plugins/index.d.ts +0 -8
  34. package/dist/src/plugins/index.js +0 -8
  35. package/dist/src/plugins/login/index.d.ts +0 -23
  36. package/dist/src/plugins/login/index.js +0 -95
  37. package/dist/src/plugins/login/schemas.d.ts +0 -5
  38. package/dist/src/plugins/login/schemas.js +0 -10
  39. package/dist/src/plugins/logout/index.d.ts +0 -15
  40. package/dist/src/plugins/logout/index.js +0 -18
  41. package/dist/src/plugins/logout/schemas.d.ts +0 -3
  42. package/dist/src/plugins/logout/schemas.js +0 -5
  43. package/dist/src/plugins/mcp/index.d.ts +0 -15
  44. package/dist/src/plugins/mcp/index.js +0 -24
  45. package/dist/src/plugins/mcp/schemas.d.ts +0 -5
  46. package/dist/src/plugins/mcp/schemas.js +0 -10
  47. package/dist/src/sdk.d.ts +0 -9
  48. package/dist/src/sdk.js +0 -24
  49. package/dist/src/telemetry/builders.d.ts +0 -42
  50. package/dist/src/telemetry/builders.js +0 -55
  51. package/dist/src/telemetry/events.d.ts +0 -37
  52. package/dist/src/telemetry/events.js +0 -4
  53. package/dist/src/types/sdk.d.ts +0 -5
  54. package/dist/src/types/sdk.js +0 -1
  55. package/dist/src/utils/api/client.d.ts +0 -15
  56. package/dist/src/utils/api/client.js +0 -27
  57. package/dist/src/utils/auth/login.d.ts +0 -7
  58. package/dist/src/utils/auth/login.js +0 -154
  59. package/dist/src/utils/cli-generator-utils.d.ts +0 -14
  60. package/dist/src/utils/cli-generator-utils.js +0 -122
  61. package/dist/src/utils/cli-generator.d.ts +0 -3
  62. package/dist/src/utils/cli-generator.js +0 -555
  63. package/dist/src/utils/constants.d.ts +0 -3
  64. package/dist/src/utils/constants.js +0 -5
  65. package/dist/src/utils/directory-detection.d.ts +0 -5
  66. package/dist/src/utils/directory-detection.js +0 -21
  67. package/dist/src/utils/errors.d.ts +0 -16
  68. package/dist/src/utils/errors.js +0 -19
  69. package/dist/src/utils/getCallablePromise.d.ts +0 -6
  70. package/dist/src/utils/getCallablePromise.js +0 -14
  71. package/dist/src/utils/log.d.ts +0 -8
  72. package/dist/src/utils/log.js +0 -21
  73. package/dist/src/utils/manifest-helpers.d.ts +0 -10
  74. package/dist/src/utils/manifest-helpers.js +0 -19
  75. package/dist/src/utils/package-manager-detector.d.ts +0 -16
  76. package/dist/src/utils/package-manager-detector.js +0 -77
  77. package/dist/src/utils/parameter-resolver.d.ts +0 -42
  78. package/dist/src/utils/parameter-resolver.js +0 -699
  79. package/dist/src/utils/schema-formatter.d.ts +0 -6
  80. package/dist/src/utils/schema-formatter.js +0 -115
  81. package/dist/src/utils/serializeAsync.d.ts +0 -2
  82. package/dist/src/utils/serializeAsync.js +0 -16
  83. package/dist/src/utils/spinner.d.ts +0 -1
  84. package/dist/src/utils/spinner.js +0 -21
  85. package/dist/src/utils/version-checker.d.ts +0 -17
  86. package/dist/src/utils/version-checker.js +0 -156
  87. package/dist/tsconfig.tsbuildinfo +0 -1
@@ -1,44 +0,0 @@
1
- import { z } from "zod";
2
- import type { AppItem, Manifest } from "@zapier/zapier-sdk";
3
- export declare const BuildManifestSchema: z.ZodObject<{
4
- appKeys: z.ZodArray<z.ZodString>;
5
- skipWrite: z.ZodOptional<z.ZodBoolean>;
6
- configPath: z.ZodOptional<z.ZodString>;
7
- }, z.core.$strip>;
8
- export type BuildManifestOptions = z.infer<typeof BuildManifestSchema> & {
9
- onProgress?: (event: ManifestBuildProgressEvent) => void;
10
- };
11
- export type ManifestBuildProgressEvent = {
12
- type: "apps_lookup_start";
13
- count: number;
14
- } | {
15
- type: "app_found";
16
- app: AppItem;
17
- } | {
18
- type: "apps_lookup_complete";
19
- count: number;
20
- } | {
21
- type: "app_processing_start";
22
- appKey: string;
23
- slug?: string;
24
- } | {
25
- type: "manifest_entry_built";
26
- appKey: string;
27
- manifestKey: string;
28
- version: string;
29
- } | {
30
- type: "manifest_updated";
31
- appKey: string;
32
- manifestKey: string;
33
- version: string;
34
- } | {
35
- type: "app_processing_complete";
36
- appKey: string;
37
- } | {
38
- type: "app_processing_error";
39
- appKey: string;
40
- error: string;
41
- };
42
- export interface BuildManifestResult {
43
- manifest?: Manifest;
44
- }
@@ -1,17 +0,0 @@
1
- import { z } from "zod";
2
- export const BuildManifestSchema = z
3
- .object({
4
- appKeys: z
5
- .array(z.string().min(1, "App key cannot be empty"))
6
- .min(1, "At least one app key is required")
7
- .describe("One or more app keys to build manifest entries for (e.g., 'slack', 'github', 'trello')"),
8
- skipWrite: z
9
- .boolean()
10
- .optional()
11
- .describe("If true, returns manifest entries without writing to disk. If false or omitted, writes to the manifest file."),
12
- configPath: z
13
- .string()
14
- .optional()
15
- .describe("Path to the manifest file. Only used when skipWrite is false or omitted."),
16
- })
17
- .describe("Build manifest entries for apps - can optionally write to disk or just return JSON");
@@ -1,15 +0,0 @@
1
- import type { Plugin } from "@zapier/zapier-sdk";
2
- import { BundleCodeSchema, type BundleCodeOptions } from "./schemas";
3
- export interface BundleCodePluginProvides {
4
- bundleCode: (options: BundleCodeOptions) => Promise<string>;
5
- context: {
6
- meta: {
7
- bundleCode: {
8
- inputSchema: typeof BundleCodeSchema;
9
- };
10
- };
11
- };
12
- }
13
- export declare const bundleCodePlugin: Plugin<{}, // requires no existing SDK methods
14
- {}, // requires no context
15
- BundleCodePluginProvides>;
@@ -1,80 +0,0 @@
1
- import { BundleCodeSchema } from "./schemas";
2
- import { createFunction } from "@zapier/zapier-sdk";
3
- import { buildSync } from "esbuild";
4
- import * as fs from "fs";
5
- import * as path from "path";
6
- export const bundleCodePlugin = () => {
7
- const bundleCodeWithSdk = createFunction(async function bundleCodeWithSdk(options) {
8
- return await bundleCode(options);
9
- }, BundleCodeSchema);
10
- return {
11
- bundleCode: bundleCodeWithSdk,
12
- context: {
13
- meta: {
14
- bundleCode: {
15
- categories: ["utility"],
16
- inputSchema: BundleCodeSchema,
17
- },
18
- },
19
- },
20
- };
21
- };
22
- class ZapierBundleError extends Error {
23
- constructor(message, details, originalError) {
24
- super(message);
25
- this.code = "ZAPIER_BUNDLE_ERROR";
26
- this.name = "ZapierBundleError";
27
- this.details = details;
28
- this.originalError = originalError;
29
- }
30
- }
31
- /**
32
- * Bundle TypeScript code into executable JavaScript (CLI version)
33
- */
34
- async function bundleCode(options) {
35
- const { input, output, target = "es2020", cjs = false, minify = false, string: returnString = false, } = options;
36
- // Resolve input path
37
- const resolvedInput = path.resolve(process.cwd(), input);
38
- try {
39
- // Bundle with esbuild
40
- const result = buildSync({
41
- entryPoints: [resolvedInput],
42
- bundle: true,
43
- platform: "node",
44
- target: target,
45
- format: cjs ? "cjs" : "esm",
46
- minify: minify,
47
- write: false,
48
- external: [], // Bundle everything
49
- banner: {
50
- js: "#!/usr/bin/env node",
51
- },
52
- });
53
- if (result.errors.length > 0) {
54
- const errorMessages = result.errors.map((e) => e.text);
55
- throw new ZapierBundleError(`Bundle failed: ${errorMessages.join(", ")}`, errorMessages);
56
- }
57
- const bundledCode = result.outputFiles?.[0]?.text;
58
- if (!bundledCode) {
59
- throw new ZapierBundleError("No output generated");
60
- }
61
- let finalOutput = bundledCode;
62
- if (returnString) {
63
- // Output as quoted string for node -e using JSON.stringify
64
- finalOutput = JSON.stringify(bundledCode);
65
- }
66
- // Write to file if output path specified
67
- if (output) {
68
- fs.mkdirSync(path.dirname(output), { recursive: true });
69
- fs.writeFileSync(output, finalOutput, "utf8");
70
- }
71
- return finalOutput;
72
- }
73
- catch (error) {
74
- // If it's already a ZapierBundleError, re-throw as-is
75
- if (error instanceof ZapierBundleError) {
76
- throw error;
77
- }
78
- throw new ZapierBundleError(`Bundle failed: ${error instanceof Error ? error.message : "Unknown error"}`, undefined, error instanceof Error ? error : undefined);
79
- }
80
- }
@@ -1,10 +0,0 @@
1
- import { z } from "zod";
2
- export declare const BundleCodeSchema: z.ZodObject<{
3
- input: z.ZodString;
4
- output: z.ZodOptional<z.ZodString>;
5
- string: z.ZodOptional<z.ZodBoolean>;
6
- minify: z.ZodOptional<z.ZodBoolean>;
7
- target: z.ZodOptional<z.ZodString>;
8
- cjs: z.ZodOptional<z.ZodBoolean>;
9
- }, z.core.$strip>;
10
- export type BundleCodeOptions = z.infer<typeof BundleCodeSchema>;
@@ -1,19 +0,0 @@
1
- import { z } from "zod";
2
- import { OutputPropertySchema } from "@zapier/zapier-sdk";
3
- // Bundle code schema - mirrors the original from SDK but for CLI use
4
- export const BundleCodeSchema = z
5
- .object({
6
- input: z.string().min(1).describe("Input TypeScript file path to bundle"),
7
- output: OutputPropertySchema.optional().describe("Output file path (defaults to input with .js extension)"),
8
- string: z
9
- .boolean()
10
- .optional()
11
- .describe("Return bundled code as string instead of writing to file"),
12
- minify: z.boolean().optional().describe("Minify the bundled output"),
13
- target: z.string().optional().describe("ECMAScript target version"),
14
- cjs: z
15
- .boolean()
16
- .optional()
17
- .describe("Output CommonJS format instead of ESM"),
18
- })
19
- .describe("Bundle TypeScript code into executable JavaScript");
@@ -1,13 +0,0 @@
1
- import type { Plugin, GetSdkType, ListActionsPluginProvides, ListAppsPluginProvides, ListInputFieldsPluginProvides, ListAuthenticationsPluginProvides, ManifestPluginProvides } from "@zapier/zapier-sdk";
2
- import { GenerateAppTypesSchema, type GenerateAppTypesOptions, type GenerateAppTypesResult } from "./schemas";
3
- export interface GenerateAppTypesPluginProvides {
4
- generateAppTypes: (options: GenerateAppTypesOptions) => Promise<GenerateAppTypesResult>;
5
- context: {
6
- meta: {
7
- generateAppTypes: {
8
- inputSchema: typeof GenerateAppTypesSchema;
9
- };
10
- };
11
- };
12
- }
13
- export declare const generateAppTypesPlugin: Plugin<GetSdkType<ListAppsPluginProvides & ListActionsPluginProvides & ListInputFieldsPluginProvides & ListAuthenticationsPluginProvides & ManifestPluginProvides>, {}, GenerateAppTypesPluginProvides>;
@@ -1,157 +0,0 @@
1
- import { createFunction, ZapierValidationError, ZapierUnknownError, } from "@zapier/zapier-sdk";
2
- import { GenerateAppTypesSchema, } from "./schemas";
3
- import { AstTypeGenerator } from "../../generators/ast-generator";
4
- import { getManifestKey } from "../../utils/manifest-helpers";
5
- import { mkdir, writeFile } from "fs/promises";
6
- import { join, resolve } from "path";
7
- import { detectTypesOutputDirectory } from "../../utils/directory-detection";
8
- export const generateAppTypesPlugin = ({ sdk }) => {
9
- const generateAppTypes = createFunction(async function generateAppTypes(options) {
10
- const { appKeys, authenticationIds, skipWrite = false, typesOutputDirectory = await detectTypesOutputDirectory(), onProgress, } = options;
11
- const resolvedTypesOutput = resolve(typesOutputDirectory);
12
- const result = {
13
- typeDefinitions: {},
14
- };
15
- // Get apps using listApps (which respects existing manifest for version locking)
16
- onProgress?.({ type: "apps_lookup_start", count: appKeys.length });
17
- const appsIterator = sdk.listApps({ appKeys }).items();
18
- const apps = [];
19
- for await (const app of appsIterator) {
20
- apps.push(app);
21
- onProgress?.({ type: "app_found", app });
22
- }
23
- onProgress?.({ type: "apps_lookup_complete", count: apps.length });
24
- if (apps.length === 0) {
25
- return result;
26
- }
27
- // Fetch authentications if provided
28
- const authentications = [];
29
- if (authenticationIds && authenticationIds.length > 0) {
30
- onProgress?.({
31
- type: "authentications_lookup_start",
32
- count: authenticationIds.length,
33
- });
34
- const authsIterator = sdk
35
- .listAuthentications({ authenticationIds })
36
- .items();
37
- for await (const auth of authsIterator) {
38
- authentications.push(auth);
39
- }
40
- onProgress?.({
41
- type: "authentications_lookup_complete",
42
- count: authentications.length,
43
- });
44
- }
45
- // Ensure output directory exists if we're writing files
46
- if (!skipWrite && resolvedTypesOutput) {
47
- await mkdir(resolvedTypesOutput, { recursive: true });
48
- }
49
- // Initialize writtenFiles if we're writing to disk
50
- if (!skipWrite) {
51
- result.writtenFiles = {};
52
- }
53
- // Process each app
54
- for (const app of apps) {
55
- onProgress?.({
56
- type: "app_processing_start",
57
- appKey: app.key,
58
- slug: app.slug,
59
- });
60
- try {
61
- if (!app.version) {
62
- const errorMessage = `Invalid implementation ID format: ${app.implementation_id}. Expected format: <implementationName>@<version>`;
63
- onProgress?.({
64
- type: "app_processing_error",
65
- appKey: app.key,
66
- error: errorMessage,
67
- });
68
- throw new ZapierValidationError(errorMessage, {
69
- details: {
70
- appKey: app.key,
71
- implementationId: app.implementation_id,
72
- },
73
- });
74
- }
75
- // Find matching authentication for this app if authentications were provided
76
- let authenticationId;
77
- if (authentications.length > 0) {
78
- const matchingAuth = authentications.find((auth) => {
79
- return auth.app_key === app.key;
80
- });
81
- if (matchingAuth) {
82
- authenticationId = matchingAuth.id;
83
- onProgress?.({
84
- type: "authentication_matched",
85
- appKey: app.key,
86
- authenticationId: matchingAuth.id,
87
- authenticationTitle: matchingAuth.title || "",
88
- });
89
- }
90
- else {
91
- onProgress?.({
92
- type: "authentication_not_matched",
93
- appKey: app.key,
94
- });
95
- }
96
- }
97
- const manifestKey = getManifestKey(app);
98
- // Generate type definitions
99
- const generator = new AstTypeGenerator();
100
- const typeDefinitionString = await generator.generateTypes({
101
- app,
102
- authenticationId,
103
- sdk,
104
- });
105
- result.typeDefinitions[manifestKey] = typeDefinitionString;
106
- onProgress?.({
107
- type: "type_generated",
108
- manifestKey,
109
- sizeBytes: typeDefinitionString.length,
110
- });
111
- // Write to file if skipWrite is false
112
- if (!skipWrite && resolvedTypesOutput && result.writtenFiles) {
113
- const filePath = join(resolvedTypesOutput, `${manifestKey}.d.ts`);
114
- await writeFile(filePath, typeDefinitionString, "utf8");
115
- result.writtenFiles[manifestKey] = filePath;
116
- onProgress?.({
117
- type: "file_written",
118
- manifestKey,
119
- filePath,
120
- });
121
- }
122
- onProgress?.({
123
- type: "app_processing_complete",
124
- appKey: app.key,
125
- });
126
- }
127
- catch (error) {
128
- const errorMessage = `Failed to process app ${app.key}: ${error instanceof Error ? error.message : String(error)}`;
129
- onProgress?.({
130
- type: "app_processing_error",
131
- appKey: app.key,
132
- error: errorMessage,
133
- });
134
- if (error instanceof ZapierValidationError) {
135
- throw error; // Preserve the specific error type
136
- }
137
- else {
138
- throw new ZapierUnknownError(errorMessage, {
139
- cause: error, // Works for both Error and non-Error
140
- });
141
- }
142
- }
143
- }
144
- return result;
145
- }, GenerateAppTypesSchema);
146
- return {
147
- generateAppTypes,
148
- context: {
149
- meta: {
150
- generateAppTypes: {
151
- categories: ["utility"],
152
- inputSchema: GenerateAppTypesSchema,
153
- },
154
- },
155
- },
156
- };
157
- };
@@ -1,58 +0,0 @@
1
- import { z } from "zod";
2
- import type { AppItem } from "@zapier/zapier-sdk";
3
- export declare const GenerateAppTypesSchema: z.ZodObject<{
4
- appKeys: z.ZodArray<z.ZodString>;
5
- authenticationIds: z.ZodOptional<z.ZodArray<z.ZodString>>;
6
- skipWrite: z.ZodOptional<z.ZodBoolean>;
7
- typesOutputDirectory: z.ZodOptional<z.ZodString>;
8
- }, z.core.$strip>;
9
- export type GenerateAppTypesOptions = z.infer<typeof GenerateAppTypesSchema> & {
10
- onProgress?: (event: AppTypesProgressEvent) => void;
11
- };
12
- export type AppTypesProgressEvent = {
13
- type: "apps_lookup_start";
14
- count: number;
15
- } | {
16
- type: "app_found";
17
- app: AppItem;
18
- } | {
19
- type: "apps_lookup_complete";
20
- count: number;
21
- } | {
22
- type: "authentications_lookup_start";
23
- count: number;
24
- } | {
25
- type: "authentications_lookup_complete";
26
- count: number;
27
- } | {
28
- type: "app_processing_start";
29
- appKey: string;
30
- slug?: string;
31
- } | {
32
- type: "authentication_matched";
33
- appKey: string;
34
- authenticationId: string;
35
- authenticationTitle: string;
36
- } | {
37
- type: "authentication_not_matched";
38
- appKey: string;
39
- } | {
40
- type: "type_generated";
41
- manifestKey: string;
42
- sizeBytes: number;
43
- } | {
44
- type: "file_written";
45
- manifestKey: string;
46
- filePath: string;
47
- } | {
48
- type: "app_processing_complete";
49
- appKey: string;
50
- } | {
51
- type: "app_processing_error";
52
- appKey: string;
53
- error: string;
54
- };
55
- export interface GenerateAppTypesResult {
56
- typeDefinitions: Record<string, string>;
57
- writtenFiles?: Record<string, string>;
58
- }
@@ -1,21 +0,0 @@
1
- import { z } from "zod";
2
- export const GenerateAppTypesSchema = z
3
- .object({
4
- appKeys: z
5
- .array(z.string().min(1, "App key cannot be empty"))
6
- .min(1, "At least one app key is required")
7
- .describe("One or more app keys to generate types for (e.g., 'slack', 'github', 'trello')"),
8
- authenticationIds: z
9
- .array(z.string())
10
- .optional()
11
- .describe("Authentication IDs to use for type generation (e.g., ['123', '456'])"),
12
- skipWrite: z
13
- .boolean()
14
- .optional()
15
- .describe("If true, returns type definitions without writing to disk. If false or omitted, writes type files."),
16
- typesOutputDirectory: z
17
- .string()
18
- .optional()
19
- .describe("Directory for TypeScript type files. Required when skipWrite is false or omitted."),
20
- })
21
- .describe("Generate TypeScript type definitions for apps - can optionally write to disk or just return type strings");
@@ -1,15 +0,0 @@
1
- import type { Plugin } from "@zapier/zapier-sdk";
2
- import { GetLoginConfigPathSchema, type GetLoginConfigPathOptions } from "./schemas";
3
- export interface GetLoginConfigPathPluginProvides {
4
- getLoginConfigPath: (options?: GetLoginConfigPathOptions) => Promise<string>;
5
- context: {
6
- meta: {
7
- getLoginConfigPath: {
8
- inputSchema: typeof GetLoginConfigPathSchema;
9
- };
10
- };
11
- };
12
- }
13
- export declare const getLoginConfigPathPlugin: Plugin<{}, // requires no existing SDK methods
14
- {}, // requires no context
15
- GetLoginConfigPathPluginProvides>;
@@ -1,19 +0,0 @@
1
- import { GetLoginConfigPathSchema, } from "./schemas";
2
- import { createFunction } from "@zapier/zapier-sdk";
3
- import { getConfigPath } from "@zapier/zapier-sdk-cli-login";
4
- export const getLoginConfigPathPlugin = () => {
5
- const getLoginConfigPathWithSdk = createFunction(async function getLoginConfigPathWithSdk(_options) {
6
- return getConfigPath();
7
- }, GetLoginConfigPathSchema);
8
- return {
9
- getLoginConfigPath: getLoginConfigPathWithSdk,
10
- context: {
11
- meta: {
12
- getLoginConfigPath: {
13
- categories: ["utility"],
14
- inputSchema: GetLoginConfigPathSchema,
15
- },
16
- },
17
- },
18
- };
19
- };
@@ -1,3 +0,0 @@
1
- import { z } from "zod";
2
- export declare const GetLoginConfigPathSchema: z.ZodObject<{}, z.core.$strip>;
3
- export type GetLoginConfigPathOptions = z.infer<typeof GetLoginConfigPathSchema>;
@@ -1,5 +0,0 @@
1
- import { z } from "zod";
2
- // Get login config path schema - simple command with no parameters
3
- export const GetLoginConfigPathSchema = z
4
- .object({})
5
- .describe("Show the path to the login configuration file");
@@ -1,8 +0,0 @@
1
- export { loginPlugin } from "./login";
2
- export { logoutPlugin } from "./logout";
3
- export { mcpPlugin } from "./mcp";
4
- export { bundleCodePlugin } from "./bundleCode";
5
- export { getLoginConfigPathPlugin } from "./getLoginConfigPath";
6
- export { addPlugin } from "./add";
7
- export { generateAppTypesPlugin } from "./generateAppTypes";
8
- export { buildManifestPlugin } from "./buildManifest";
@@ -1,8 +0,0 @@
1
- export { loginPlugin } from "./login";
2
- export { logoutPlugin } from "./logout";
3
- export { mcpPlugin } from "./mcp";
4
- export { bundleCodePlugin } from "./bundleCode";
5
- export { getLoginConfigPathPlugin } from "./getLoginConfigPath";
6
- export { addPlugin } from "./add";
7
- export { generateAppTypesPlugin } from "./generateAppTypes";
8
- export { buildManifestPlugin } from "./buildManifest";
@@ -1,23 +0,0 @@
1
- import type { Plugin, ResolvedCredentials } from "@zapier/zapier-sdk";
2
- import type { EventEmissionContext } from "@zapier/zapier-sdk";
3
- import { LoginSchema, type LoginOptions } from "./schemas";
4
- interface CliContext {
5
- session_id?: string | null;
6
- selected_api?: string | null;
7
- app_id?: number | null;
8
- app_version_id?: number | null;
9
- resolveCredentials: () => Promise<ResolvedCredentials | undefined>;
10
- }
11
- interface LoginPluginProvides {
12
- login: (options: LoginOptions) => Promise<void>;
13
- context: {
14
- meta: {
15
- login: {
16
- inputSchema: typeof LoginSchema;
17
- categories: string[];
18
- };
19
- };
20
- };
21
- }
22
- export declare const loginPlugin: Plugin<{}, EventEmissionContext & CliContext, LoginPluginProvides>;
23
- export type { LoginPluginProvides };
@@ -1,95 +0,0 @@
1
- import { isCredentialsObject } from "@zapier/zapier-sdk";
2
- import login from "../../utils/auth/login";
3
- import { getLoggedInUser, } from "@zapier/zapier-sdk-cli-login";
4
- import { LoginSchema } from "./schemas";
5
- import { buildCliCommandExecutedEvent } from "../../telemetry/builders";
6
- import cliPackageJson from "../../../package.json";
7
- const CLI_COMMAND_EXECUTED_EVENT_SUBJECT = "platform.sdk.CliCommandExecutedEvent";
8
- function toPkceCredentials(credentials) {
9
- if (credentials &&
10
- isCredentialsObject(credentials) &&
11
- !("clientSecret" in credentials)) {
12
- return {
13
- type: "pkce",
14
- clientId: credentials.clientId,
15
- baseUrl: credentials.baseUrl,
16
- scope: credentials.scope,
17
- };
18
- }
19
- return undefined;
20
- }
21
- export const loginPlugin = ({ context }) => {
22
- // Wrap the login function to emit telemetry events
23
- const loginWithTelemetry = async (options) => {
24
- const startTime = Date.now();
25
- let success = false;
26
- let errorMessage = null;
27
- let accountId = null;
28
- let customUserId = null;
29
- try {
30
- const timeoutSeconds = options.timeout
31
- ? parseInt(options.timeout, 10)
32
- : 300;
33
- if (isNaN(timeoutSeconds) || timeoutSeconds <= 0) {
34
- throw new Error("Timeout must be a positive number");
35
- }
36
- // Resolve credentials from options and env vars
37
- const resolvedCredentials = await context.resolveCredentials();
38
- const pkceCredentials = toPkceCredentials(resolvedCredentials);
39
- await login({
40
- timeoutMs: timeoutSeconds * 1000,
41
- credentials: pkceCredentials,
42
- });
43
- // Get user info after successful login
44
- const user = await getLoggedInUser();
45
- accountId = user.accountId;
46
- customUserId = user.customUserId;
47
- console.log(`✅ Successfully logged in as ${user.email}`);
48
- success = true;
49
- }
50
- catch (error) {
51
- success = false;
52
- errorMessage = error instanceof Error ? error.message : "Login failed";
53
- throw error;
54
- }
55
- finally {
56
- // Emit CLI command executed event if event emission is available
57
- const event = buildCliCommandExecutedEvent({
58
- data: {
59
- cli_primary_command: "login",
60
- success_flag: success,
61
- execution_duration_ms: Date.now() - startTime,
62
- exit_code: success ? 0 : 1,
63
- error_message: errorMessage,
64
- command_category: "authentication",
65
- requires_auth: false,
66
- cli_arguments: [
67
- "login",
68
- options.timeout ? `--timeout=${options.timeout}` : null,
69
- ].filter(Boolean),
70
- },
71
- context: {
72
- session_id: context.session_id,
73
- selected_api: context.selected_api,
74
- app_id: context.app_id,
75
- app_version_id: context.app_version_id,
76
- customuser_id: customUserId,
77
- account_id: accountId,
78
- },
79
- cliVersion: cliPackageJson.version,
80
- });
81
- context.eventEmission.emit(CLI_COMMAND_EXECUTED_EVENT_SUBJECT, event);
82
- }
83
- };
84
- return {
85
- login: loginWithTelemetry,
86
- context: {
87
- meta: {
88
- login: {
89
- categories: ["account"],
90
- inputSchema: LoginSchema,
91
- },
92
- },
93
- },
94
- };
95
- };
@@ -1,5 +0,0 @@
1
- import { z } from "zod";
2
- export declare const LoginSchema: z.ZodObject<{
3
- timeout: z.ZodOptional<z.ZodString>;
4
- }, z.core.$strip>;
5
- export type LoginOptions = z.infer<typeof LoginSchema>;
@@ -1,10 +0,0 @@
1
- import { z } from "zod";
2
- // Login schema
3
- export const LoginSchema = z
4
- .object({
5
- timeout: z
6
- .string()
7
- .optional()
8
- .describe("Login timeout in seconds (default: 300)"),
9
- })
10
- .describe("Log in to Zapier to access your account");
@@ -1,15 +0,0 @@
1
- import type { Plugin } from "@zapier/zapier-sdk";
2
- import { LogoutSchema, type LogoutOptions } from "./schemas";
3
- interface LogoutPluginProvides {
4
- logout: (options: LogoutOptions) => Promise<void>;
5
- context: {
6
- meta: {
7
- logout: {
8
- inputSchema: typeof LogoutSchema;
9
- categories: string[];
10
- };
11
- };
12
- };
13
- }
14
- export declare const logoutPlugin: Plugin<{}, {}, LogoutPluginProvides>;
15
- export type { LogoutPluginProvides };