@zapier/zapier-sdk-cli 0.16.1 → 0.16.3

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 (60) hide show
  1. package/CHANGELOG.md +18 -0
  2. package/dist/cli.cjs +7 -7
  3. package/dist/cli.mjs +7 -7
  4. package/dist/index.cjs +1 -1
  5. package/dist/index.mjs +1 -1
  6. package/dist/package.json +8 -2
  7. package/dist/src/cli.js +2 -1
  8. package/dist/src/utils/cli-generator.js +8 -7
  9. package/dist/tsconfig.tsbuildinfo +1 -1
  10. package/package.json +11 -5
  11. package/src/cli.test.ts +0 -28
  12. package/src/cli.ts +0 -96
  13. package/src/generators/ast-generator.test.ts +0 -908
  14. package/src/generators/ast-generator.ts +0 -774
  15. package/src/index.ts +0 -12
  16. package/src/plugins/add/index.test.ts +0 -58
  17. package/src/plugins/add/index.ts +0 -177
  18. package/src/plugins/add/schemas.ts +0 -35
  19. package/src/plugins/buildManifest/index.test.ts +0 -679
  20. package/src/plugins/buildManifest/index.ts +0 -131
  21. package/src/plugins/buildManifest/schemas.ts +0 -55
  22. package/src/plugins/bundleCode/index.ts +0 -128
  23. package/src/plugins/bundleCode/schemas.ts +0 -24
  24. package/src/plugins/generateAppTypes/index.test.ts +0 -679
  25. package/src/plugins/generateAppTypes/index.ts +0 -227
  26. package/src/plugins/generateAppTypes/schemas.ts +0 -61
  27. package/src/plugins/getLoginConfigPath/index.ts +0 -45
  28. package/src/plugins/getLoginConfigPath/schemas.ts +0 -10
  29. package/src/plugins/index.ts +0 -8
  30. package/src/plugins/login/index.ts +0 -135
  31. package/src/plugins/login/schemas.ts +0 -13
  32. package/src/plugins/logout/index.ts +0 -37
  33. package/src/plugins/logout/schemas.ts +0 -8
  34. package/src/plugins/mcp/index.ts +0 -43
  35. package/src/plugins/mcp/schemas.ts +0 -13
  36. package/src/sdk.ts +0 -45
  37. package/src/telemetry/builders.ts +0 -113
  38. package/src/telemetry/events.ts +0 -39
  39. package/src/types/sdk.ts +0 -8
  40. package/src/utils/api/client.ts +0 -44
  41. package/src/utils/auth/login.ts +0 -214
  42. package/src/utils/cli-generator-utils.ts +0 -169
  43. package/src/utils/cli-generator.test.ts +0 -347
  44. package/src/utils/cli-generator.ts +0 -807
  45. package/src/utils/constants.ts +0 -9
  46. package/src/utils/directory-detection.ts +0 -23
  47. package/src/utils/errors.ts +0 -26
  48. package/src/utils/getCallablePromise.ts +0 -21
  49. package/src/utils/log.ts +0 -23
  50. package/src/utils/manifest-helpers.ts +0 -25
  51. package/src/utils/package-manager-detector.ts +0 -83
  52. package/src/utils/parameter-resolver.ts +0 -1075
  53. package/src/utils/schema-formatter.ts +0 -153
  54. package/src/utils/serializeAsync.ts +0 -26
  55. package/src/utils/spinner.ts +0 -23
  56. package/src/utils/version-checker.test.ts +0 -239
  57. package/src/utils/version-checker.ts +0 -237
  58. package/tsconfig.build.json +0 -18
  59. package/tsconfig.json +0 -19
  60. package/tsup.config.ts +0 -23
@@ -1,131 +0,0 @@
1
- import type {
2
- Plugin,
3
- GetSdkType,
4
- GetContextType,
5
- ListAppsPluginProvides,
6
- ManifestPluginProvides,
7
- AppItem,
8
- Manifest,
9
- } from "@zapier/zapier-sdk";
10
- import {
11
- createFunction,
12
- ZapierValidationError,
13
- ZapierUnknownError,
14
- } from "@zapier/zapier-sdk";
15
- import {
16
- BuildManifestSchema,
17
- type BuildManifestOptions,
18
- type BuildManifestResult,
19
- } from "./schemas";
20
- import { createManifestEntry } from "../../utils/manifest-helpers";
21
-
22
- export interface BuildManifestPluginProvides {
23
- buildManifest: (
24
- options: BuildManifestOptions,
25
- ) => Promise<BuildManifestResult>;
26
- context: {
27
- meta: {
28
- buildManifest: {
29
- inputSchema: typeof BuildManifestSchema;
30
- };
31
- };
32
- };
33
- }
34
-
35
- export const buildManifestPlugin: Plugin<
36
- GetSdkType<ListAppsPluginProvides>,
37
- GetContextType<ManifestPluginProvides>,
38
- BuildManifestPluginProvides
39
- > = ({ sdk, context }) => {
40
- const buildManifest = createFunction(async function buildManifest(
41
- options: BuildManifestOptions,
42
- ): Promise<BuildManifestResult> {
43
- const { appKeys, skipWrite = false, configPath, onProgress } = options;
44
-
45
- // Get apps using listApps (which respects existing manifest for version locking)
46
- onProgress?.({ type: "apps_lookup_start", count: appKeys.length });
47
- const appsIterator = sdk.listApps({ appKeys }).items();
48
- const apps: AppItem[] = [];
49
- for await (const app of appsIterator) {
50
- apps.push(app);
51
- onProgress?.({ type: "app_found", app });
52
- }
53
- onProgress?.({ type: "apps_lookup_complete", count: apps.length });
54
-
55
- if (apps.length === 0) {
56
- return {};
57
- }
58
-
59
- let updatedManifest: Manifest | undefined;
60
-
61
- // Process each app
62
- for (const app of apps) {
63
- onProgress?.({
64
- type: "app_processing_start",
65
- appKey: app.key,
66
- slug: app.slug,
67
- });
68
-
69
- try {
70
- const manifestEntry = createManifestEntry(app);
71
-
72
- onProgress?.({
73
- type: "manifest_entry_built",
74
- appKey: app.key,
75
- manifestKey: manifestEntry.implementationName,
76
- version: manifestEntry.version || "",
77
- });
78
-
79
- const { key: updatedManifestKey, manifest } =
80
- await context.updateManifestEntry({
81
- appKey: app.key,
82
- entry: manifestEntry,
83
- configPath,
84
- skipWrite,
85
- manifest: updatedManifest,
86
- });
87
-
88
- updatedManifest = manifest;
89
-
90
- onProgress?.({
91
- type: "manifest_updated",
92
- appKey: app.key,
93
- manifestKey: updatedManifestKey,
94
- version: manifestEntry.version || "",
95
- });
96
-
97
- onProgress?.({ type: "app_processing_complete", appKey: app.key });
98
- } catch (error) {
99
- const errorMessage = `Failed to process app ${app.key}: ${error instanceof Error ? error.message : String(error)}`;
100
-
101
- onProgress?.({
102
- type: "app_processing_error",
103
- appKey: app.key,
104
- error: errorMessage,
105
- });
106
-
107
- if (error instanceof ZapierValidationError) {
108
- throw error; // Preserve the specific error type
109
- } else {
110
- throw new ZapierUnknownError(errorMessage, {
111
- cause: error, // Works for both Error and non-Error
112
- });
113
- }
114
- }
115
- }
116
-
117
- return { manifest: updatedManifest };
118
- }, BuildManifestSchema);
119
-
120
- return {
121
- buildManifest,
122
- context: {
123
- meta: {
124
- buildManifest: {
125
- categories: ["utility"],
126
- inputSchema: BuildManifestSchema,
127
- },
128
- },
129
- },
130
- };
131
- };
@@ -1,55 +0,0 @@
1
- import { z } from "zod";
2
- import type { AppItem, Manifest } from "@zapier/zapier-sdk";
3
-
4
- export const BuildManifestSchema = z
5
- .object({
6
- appKeys: z
7
- .array(z.string().min(1, "App key cannot be empty"))
8
- .min(1, "At least one app key is required")
9
- .describe(
10
- "One or more app keys to build manifest entries for (e.g., 'slack', 'github', 'trello')",
11
- ),
12
- skipWrite: z
13
- .boolean()
14
- .optional()
15
- .describe(
16
- "If true, returns manifest entries without writing to disk. If false or omitted, writes to the manifest file.",
17
- ),
18
- configPath: z
19
- .string()
20
- .optional()
21
- .describe(
22
- "Path to the manifest file. Only used when skipWrite is false or omitted.",
23
- ),
24
- })
25
- .describe(
26
- "Build manifest entries for apps - can optionally write to disk or just return JSON",
27
- );
28
-
29
- export type BuildManifestOptions = z.infer<typeof BuildManifestSchema> & {
30
- onProgress?: (event: ManifestBuildProgressEvent) => void;
31
- };
32
-
33
- export type ManifestBuildProgressEvent =
34
- | { type: "apps_lookup_start"; count: number }
35
- | { type: "app_found"; app: AppItem }
36
- | { type: "apps_lookup_complete"; count: number }
37
- | { type: "app_processing_start"; appKey: string; slug?: string }
38
- | {
39
- type: "manifest_entry_built";
40
- appKey: string;
41
- manifestKey: string;
42
- version: string;
43
- }
44
- | {
45
- type: "manifest_updated";
46
- appKey: string;
47
- manifestKey: string;
48
- version: string;
49
- }
50
- | { type: "app_processing_complete"; appKey: string }
51
- | { type: "app_processing_error"; appKey: string; error: string };
52
-
53
- export interface BuildManifestResult {
54
- manifest?: Manifest;
55
- }
@@ -1,128 +0,0 @@
1
- import type { Plugin } from "@zapier/zapier-sdk";
2
- import { BundleCodeSchema, type BundleCodeOptions } from "./schemas";
3
- import { createFunction } from "@zapier/zapier-sdk";
4
- import { buildSync } from "esbuild";
5
- import * as fs from "fs";
6
- import * as path from "path";
7
-
8
- export interface BundleCodePluginProvides {
9
- bundleCode: (options: BundleCodeOptions) => Promise<string>;
10
- context: {
11
- meta: {
12
- bundleCode: {
13
- inputSchema: typeof BundleCodeSchema;
14
- };
15
- };
16
- };
17
- }
18
-
19
- export const bundleCodePlugin: Plugin<
20
- {}, // requires no existing SDK methods
21
- {}, // requires no context
22
- BundleCodePluginProvides
23
- > = () => {
24
- const bundleCodeWithSdk = createFunction(async function bundleCodeWithSdk(
25
- options: BundleCodeOptions,
26
- ): Promise<string> {
27
- return await bundleCode(options);
28
- }, BundleCodeSchema);
29
-
30
- return {
31
- bundleCode: bundleCodeWithSdk,
32
- context: {
33
- meta: {
34
- bundleCode: {
35
- categories: ["utility"],
36
- inputSchema: BundleCodeSchema,
37
- },
38
- },
39
- },
40
- };
41
- };
42
-
43
- class ZapierBundleError extends Error {
44
- public readonly code = "ZAPIER_BUNDLE_ERROR";
45
- public readonly details?: string[];
46
- public readonly originalError?: Error;
47
-
48
- constructor(message: string, details?: string[], originalError?: Error) {
49
- super(message);
50
- this.name = "ZapierBundleError";
51
- this.details = details;
52
- this.originalError = originalError;
53
- }
54
- }
55
-
56
- /**
57
- * Bundle TypeScript code into executable JavaScript (CLI version)
58
- */
59
- async function bundleCode(options: BundleCodeOptions): Promise<string> {
60
- const {
61
- input,
62
- output,
63
- target = "es2020",
64
- cjs = false,
65
- minify = false,
66
- string: returnString = false,
67
- } = options;
68
-
69
- // Resolve input path
70
- const resolvedInput = path.resolve(process.cwd(), input);
71
-
72
- try {
73
- // Bundle with esbuild
74
- const result = buildSync({
75
- entryPoints: [resolvedInput],
76
- bundle: true,
77
- platform: "node",
78
- target: target,
79
- format: cjs ? "cjs" : "esm",
80
- minify: minify,
81
- write: false,
82
- external: [], // Bundle everything
83
- banner: {
84
- js: "#!/usr/bin/env node",
85
- },
86
- });
87
-
88
- if (result.errors.length > 0) {
89
- const errorMessages = result.errors.map((e) => e.text);
90
- throw new ZapierBundleError(
91
- `Bundle failed: ${errorMessages.join(", ")}`,
92
- errorMessages,
93
- );
94
- }
95
-
96
- const bundledCode = result.outputFiles?.[0]?.text;
97
- if (!bundledCode) {
98
- throw new ZapierBundleError("No output generated");
99
- }
100
-
101
- let finalOutput = bundledCode;
102
-
103
- if (returnString) {
104
- // Output as quoted string for node -e using JSON.stringify
105
- finalOutput = JSON.stringify(bundledCode);
106
- }
107
-
108
- // Write to file if output path specified
109
- if (output) {
110
- fs.mkdirSync(path.dirname(output), { recursive: true });
111
- fs.writeFileSync(output, finalOutput, "utf8");
112
- }
113
-
114
- return finalOutput;
115
- } catch (error) {
116
- // If it's already a ZapierBundleError, re-throw as-is
117
- if (error instanceof ZapierBundleError) {
118
- throw error;
119
- }
120
- throw new ZapierBundleError(
121
- `Bundle failed: ${
122
- error instanceof Error ? error.message : "Unknown error"
123
- }`,
124
- undefined,
125
- error instanceof Error ? error : undefined,
126
- );
127
- }
128
- }
@@ -1,24 +0,0 @@
1
- import { z } from "zod";
2
- import { OutputPropertySchema } from "@zapier/zapier-sdk";
3
-
4
- // Bundle code schema - mirrors the original from SDK but for CLI use
5
- export const BundleCodeSchema = z
6
- .object({
7
- input: z.string().min(1).describe("Input TypeScript file path to bundle"),
8
- output: OutputPropertySchema.optional().describe(
9
- "Output file path (defaults to input with .js extension)",
10
- ),
11
- string: z
12
- .boolean()
13
- .optional()
14
- .describe("Return bundled code as string instead of writing to file"),
15
- minify: z.boolean().optional().describe("Minify the bundled output"),
16
- target: z.string().optional().describe("ECMAScript target version"),
17
- cjs: z
18
- .boolean()
19
- .optional()
20
- .describe("Output CommonJS format instead of ESM"),
21
- })
22
- .describe("Bundle TypeScript code into executable JavaScript");
23
-
24
- export type BundleCodeOptions = z.infer<typeof BundleCodeSchema>;