@zapier/zapier-sdk-cli 0.19.0 → 0.22.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 (88) hide show
  1. package/CHANGELOG.md +8 -0
  2. package/dist/cli.cjs +2 -2
  3. package/dist/cli.mjs +2 -2
  4. package/dist/index.cjs +1 -1
  5. package/dist/index.mjs +1 -1
  6. package/package.json +4 -4
  7. package/dist/package.json +0 -78
  8. package/dist/src/cli.d.ts +0 -2
  9. package/dist/src/cli.js +0 -105
  10. package/dist/src/generators/ast-generator.d.ts +0 -41
  11. package/dist/src/generators/ast-generator.js +0 -409
  12. package/dist/src/index.d.ts +0 -4
  13. package/dist/src/index.js +0 -4
  14. package/dist/src/plugins/add/index.d.ts +0 -15
  15. package/dist/src/plugins/add/index.js +0 -103
  16. package/dist/src/plugins/add/schemas.d.ts +0 -8
  17. package/dist/src/plugins/add/schemas.js +0 -22
  18. package/dist/src/plugins/buildManifest/index.d.ts +0 -13
  19. package/dist/src/plugins/buildManifest/index.js +0 -81
  20. package/dist/src/plugins/buildManifest/schemas.d.ts +0 -44
  21. package/dist/src/plugins/buildManifest/schemas.js +0 -17
  22. package/dist/src/plugins/bundleCode/index.d.ts +0 -15
  23. package/dist/src/plugins/bundleCode/index.js +0 -80
  24. package/dist/src/plugins/bundleCode/schemas.d.ts +0 -10
  25. package/dist/src/plugins/bundleCode/schemas.js +0 -19
  26. package/dist/src/plugins/generateAppTypes/index.d.ts +0 -13
  27. package/dist/src/plugins/generateAppTypes/index.js +0 -157
  28. package/dist/src/plugins/generateAppTypes/schemas.d.ts +0 -58
  29. package/dist/src/plugins/generateAppTypes/schemas.js +0 -21
  30. package/dist/src/plugins/getLoginConfigPath/index.d.ts +0 -15
  31. package/dist/src/plugins/getLoginConfigPath/index.js +0 -19
  32. package/dist/src/plugins/getLoginConfigPath/schemas.d.ts +0 -3
  33. package/dist/src/plugins/getLoginConfigPath/schemas.js +0 -5
  34. package/dist/src/plugins/index.d.ts +0 -8
  35. package/dist/src/plugins/index.js +0 -8
  36. package/dist/src/plugins/login/index.d.ts +0 -23
  37. package/dist/src/plugins/login/index.js +0 -95
  38. package/dist/src/plugins/login/schemas.d.ts +0 -5
  39. package/dist/src/plugins/login/schemas.js +0 -10
  40. package/dist/src/plugins/logout/index.d.ts +0 -15
  41. package/dist/src/plugins/logout/index.js +0 -18
  42. package/dist/src/plugins/logout/schemas.d.ts +0 -3
  43. package/dist/src/plugins/logout/schemas.js +0 -5
  44. package/dist/src/plugins/mcp/index.d.ts +0 -15
  45. package/dist/src/plugins/mcp/index.js +0 -24
  46. package/dist/src/plugins/mcp/schemas.d.ts +0 -5
  47. package/dist/src/plugins/mcp/schemas.js +0 -10
  48. package/dist/src/sdk.d.ts +0 -9
  49. package/dist/src/sdk.js +0 -24
  50. package/dist/src/telemetry/builders.d.ts +0 -42
  51. package/dist/src/telemetry/builders.js +0 -55
  52. package/dist/src/telemetry/events.d.ts +0 -37
  53. package/dist/src/telemetry/events.js +0 -4
  54. package/dist/src/types/sdk.d.ts +0 -5
  55. package/dist/src/types/sdk.js +0 -1
  56. package/dist/src/utils/api/client.d.ts +0 -15
  57. package/dist/src/utils/api/client.js +0 -27
  58. package/dist/src/utils/auth/login.d.ts +0 -7
  59. package/dist/src/utils/auth/login.js +0 -154
  60. package/dist/src/utils/cli-generator-utils.d.ts +0 -14
  61. package/dist/src/utils/cli-generator-utils.js +0 -122
  62. package/dist/src/utils/cli-generator.d.ts +0 -3
  63. package/dist/src/utils/cli-generator.js +0 -555
  64. package/dist/src/utils/constants.d.ts +0 -3
  65. package/dist/src/utils/constants.js +0 -5
  66. package/dist/src/utils/directory-detection.d.ts +0 -5
  67. package/dist/src/utils/directory-detection.js +0 -21
  68. package/dist/src/utils/errors.d.ts +0 -16
  69. package/dist/src/utils/errors.js +0 -19
  70. package/dist/src/utils/getCallablePromise.d.ts +0 -6
  71. package/dist/src/utils/getCallablePromise.js +0 -14
  72. package/dist/src/utils/log.d.ts +0 -8
  73. package/dist/src/utils/log.js +0 -21
  74. package/dist/src/utils/manifest-helpers.d.ts +0 -10
  75. package/dist/src/utils/manifest-helpers.js +0 -19
  76. package/dist/src/utils/package-manager-detector.d.ts +0 -16
  77. package/dist/src/utils/package-manager-detector.js +0 -77
  78. package/dist/src/utils/parameter-resolver.d.ts +0 -42
  79. package/dist/src/utils/parameter-resolver.js +0 -699
  80. package/dist/src/utils/schema-formatter.d.ts +0 -6
  81. package/dist/src/utils/schema-formatter.js +0 -115
  82. package/dist/src/utils/serializeAsync.d.ts +0 -2
  83. package/dist/src/utils/serializeAsync.js +0 -16
  84. package/dist/src/utils/spinner.d.ts +0 -1
  85. package/dist/src/utils/spinner.js +0 -21
  86. package/dist/src/utils/version-checker.d.ts +0 -17
  87. package/dist/src/utils/version-checker.js +0 -156
  88. package/dist/tsconfig.tsbuildinfo +0 -1
@@ -1,6 +0,0 @@
1
- import type { z } from "zod";
2
- export declare function formatJsonOutput(data: unknown): void;
3
- export declare function formatItemsFromSchema(functionInfo: {
4
- inputSchema: z.ZodType;
5
- outputSchema?: z.ZodType;
6
- }, items: unknown[], startingNumber?: number): void;
@@ -1,115 +0,0 @@
1
- import chalk from "chalk";
2
- import util from "util";
3
- // These functions are internal to SDK, implementing basic formatting fallback
4
- // TODO: Consider exposing these utilities or implementing proper CLI formatting
5
- function getFormatMetadata(schema) {
6
- return schema?._zod
7
- ?.def?.formatMeta;
8
- }
9
- function getOutputSchema(schema) {
10
- return schema?._zod?.def
11
- ?.outputSchema;
12
- }
13
- // ============================================================================
14
- // JSON Formatting
15
- // ============================================================================
16
- export function formatJsonOutput(data) {
17
- // Don't print anything for undefined results (commands that just perform actions)
18
- if (data === undefined) {
19
- return;
20
- }
21
- // Use util.inspect for colored output
22
- console.log(util.inspect(data, { colors: true, depth: null, breakLength: 80 }));
23
- }
24
- // ============================================================================
25
- // Generic Schema-Driven Formatter
26
- // ============================================================================
27
- export function formatItemsFromSchema(functionInfo, items, startingNumber = 0) {
28
- // Get the output schema from function info or fall back to input schema output schema
29
- const outputSchema = functionInfo.outputSchema || getOutputSchema(functionInfo.inputSchema);
30
- if (!outputSchema) {
31
- // Fallback to generic formatting if no output schema
32
- formatItemsGeneric(items, startingNumber);
33
- return;
34
- }
35
- const formatMeta = getFormatMetadata(outputSchema);
36
- if (!formatMeta) {
37
- // Fallback to generic formatting if no format metadata
38
- formatItemsGeneric(items, startingNumber);
39
- return;
40
- }
41
- // Format each item using the schema metadata
42
- items.forEach((item, index) => {
43
- const formatted = formatMeta.format(item);
44
- formatSingleItem(formatted, startingNumber + index);
45
- });
46
- }
47
- function formatSingleItem(formatted, itemNumber) {
48
- // Build the main title line with optional subtitle
49
- let titleLine = `${chalk.gray(`${itemNumber + 1}.`)} ${chalk.cyan(formatted.title)}`;
50
- // Generate subtitle - always show key if available, then ID if available
51
- const subtitleParts = [];
52
- if (formatted.keys) {
53
- subtitleParts.push(...formatted.keys);
54
- }
55
- else if (formatted.key) {
56
- subtitleParts.push(formatted.key);
57
- }
58
- if (formatted.id) {
59
- subtitleParts.push(formatted.id);
60
- }
61
- // Remove duplicates while preserving order
62
- const uniqueParts = [...new Set(subtitleParts)];
63
- if (uniqueParts.length > 0) {
64
- titleLine += ` ${chalk.gray(`(${uniqueParts.join(", ")})`)}`;
65
- }
66
- console.log(titleLine);
67
- // Show description if available
68
- if (formatted.description) {
69
- console.log(` ${chalk.dim(formatted.description)}`);
70
- }
71
- // If data is provided, use JSON formatting instead of details
72
- if (formatted.data !== undefined) {
73
- formatJsonOutput(formatted.data);
74
- console.log(); // Empty line between items
75
- return;
76
- }
77
- // Format detail lines
78
- for (const detail of formatted.details) {
79
- const styledText = applyStyle(detail.text, detail.style);
80
- console.log(` ${styledText}`);
81
- }
82
- console.log(); // Empty line between items
83
- }
84
- function applyStyle(value, style) {
85
- switch (style) {
86
- case "dim":
87
- return chalk.dim(value);
88
- case "accent":
89
- return chalk.magenta(value);
90
- case "warning":
91
- return chalk.red(value);
92
- case "success":
93
- return chalk.green(value);
94
- case "normal":
95
- default:
96
- return chalk.blue(value);
97
- }
98
- }
99
- function convertGenericItemToFormattedItem(item) {
100
- const itemObj = item;
101
- return {
102
- title: itemObj.title || itemObj.name || itemObj.key || itemObj.id || "Item",
103
- id: itemObj.id,
104
- key: itemObj.key,
105
- description: itemObj.description,
106
- details: [],
107
- };
108
- }
109
- function formatItemsGeneric(items, startingNumber = 0) {
110
- // Convert generic items to FormattedItem and use formatSingleItem
111
- items.forEach((item, index) => {
112
- const formatted = convertGenericItemToFormattedItem(item);
113
- formatSingleItem(formatted, startingNumber + index);
114
- });
115
- }
@@ -1,2 +0,0 @@
1
- declare const serializeAsync: <R, A extends []>(fn: (...args: A) => Promise<R>) => ((...args: A) => Promise<R>);
2
- export default serializeAsync;
@@ -1,16 +0,0 @@
1
- import { createHash } from "node:crypto";
2
- const promises = {};
3
- const serializeAsync = (fn) => async (...args) => {
4
- const hash = createHash("sha256")
5
- .update(fn.toString(), "utf8")
6
- .digest()
7
- .toString("hex");
8
- const promise = promises[hash];
9
- if (!promise) {
10
- promises[hash] = fn(...args).finally(() => {
11
- delete promises[hash];
12
- });
13
- }
14
- return promises[hash];
15
- };
16
- export default serializeAsync;
@@ -1 +0,0 @@
1
- export declare const spinPromise: <T>(promise: Promise<T>, text: string) => Promise<T>;
@@ -1,21 +0,0 @@
1
- import ora from "ora";
2
- import { ZapierCliUserCancellationError } from "./errors";
3
- export const spinPromise = async (promise, text) => {
4
- const spinner = ora(text).start();
5
- try {
6
- const result = await promise;
7
- spinner.succeed();
8
- return result;
9
- }
10
- catch (error) {
11
- if (error instanceof ZapierCliUserCancellationError) {
12
- // For user cancellation, just stop the spinner without showing failure
13
- spinner.stop();
14
- }
15
- else {
16
- // For actual errors, show failure
17
- spinner.fail();
18
- }
19
- throw error;
20
- }
21
- };
@@ -1,17 +0,0 @@
1
- interface VersionInfo {
2
- hasUpdate: boolean;
3
- latestVersion?: string;
4
- currentVersion: string;
5
- isDeprecated: boolean;
6
- deprecationMessage?: string;
7
- }
8
- export declare function checkForUpdates({ packageName, currentVersion, }: {
9
- packageName: string;
10
- currentVersion: string;
11
- }): Promise<VersionInfo>;
12
- export declare function displayUpdateNotification(versionInfo: VersionInfo, packageName: string): void;
13
- export declare function checkAndNotifyUpdates({ packageName, currentVersion, }: {
14
- packageName: string;
15
- currentVersion: string;
16
- }): Promise<void>;
17
- export {};
@@ -1,156 +0,0 @@
1
- import packageJsonLib from "package-json";
2
- import chalk from "chalk";
3
- import log from "./log";
4
- import Conf from "conf";
5
- import { getUpdateCommand } from "./package-manager-detector";
6
- import semver from "semver";
7
- let config = null;
8
- function getConfig() {
9
- if (!config) {
10
- config = new Conf({ projectName: "zapier-sdk-cli" });
11
- }
12
- return config;
13
- }
14
- const ONE_DAY_MS = 24 * 60 * 60 * 1000;
15
- const CACHE_RESET_INTERVAL_MS = (() => {
16
- const { ZAPIER_SDK_UPDATE_CHECK_INTERVAL_MS = `${ONE_DAY_MS}` } = process.env;
17
- const interval = parseInt(ZAPIER_SDK_UPDATE_CHECK_INTERVAL_MS);
18
- if (isNaN(interval) || interval < 0) {
19
- return -1;
20
- }
21
- return interval;
22
- })();
23
- function getVersionCache() {
24
- try {
25
- const cache = getConfig().get("version_cache");
26
- const now = Date.now();
27
- // If no cache, missing timestamp, or it's been more than a day, reset the cache
28
- if (!cache ||
29
- !cache.last_reset_timestamp ||
30
- now - cache.last_reset_timestamp >= CACHE_RESET_INTERVAL_MS) {
31
- const newCache = {
32
- last_reset_timestamp: now,
33
- packages: {},
34
- };
35
- getConfig().set("version_cache", newCache);
36
- return newCache;
37
- }
38
- return cache;
39
- }
40
- catch (error) {
41
- log.debug(`Failed to read version cache: ${error}`);
42
- return {
43
- last_reset_timestamp: Date.now(),
44
- packages: {},
45
- };
46
- }
47
- }
48
- function setCachedPackageInfo(packageName, version, info) {
49
- try {
50
- const cache = getVersionCache();
51
- if (!cache.packages[packageName]) {
52
- cache.packages[packageName] = {};
53
- }
54
- cache.packages[packageName][version] = info;
55
- getConfig().set("version_cache", cache);
56
- }
57
- catch (error) {
58
- log.debug(`Failed to cache package info: ${error}`);
59
- }
60
- }
61
- function getCachedPackageInfo(packageName, version) {
62
- try {
63
- const cache = getVersionCache();
64
- return cache.packages[packageName]?.[version];
65
- }
66
- catch (error) {
67
- log.debug(`Failed to get cached package info: ${error}`);
68
- return undefined;
69
- }
70
- }
71
- async function fetchCachedPackageInfo(packageName, version) {
72
- const cacheKey = version || "latest";
73
- // Try cache first
74
- let cachedInfo = getCachedPackageInfo(packageName, cacheKey);
75
- if (cachedInfo) {
76
- return cachedInfo;
77
- }
78
- // Not in cache, fetch from npm
79
- const packageInfo = await packageJsonLib(packageName, {
80
- version,
81
- fullMetadata: true,
82
- });
83
- const info = {
84
- version: packageInfo.version,
85
- deprecated: packageInfo.deprecated,
86
- fetched_at: new Date().toISOString(),
87
- };
88
- // Cache for next time
89
- setCachedPackageInfo(packageName, cacheKey, info);
90
- return info;
91
- }
92
- export async function checkForUpdates({ packageName, currentVersion, }) {
93
- try {
94
- // Get latest version info (with caching)
95
- const latestPackageInfo = await fetchCachedPackageInfo(packageName);
96
- const latestVersion = latestPackageInfo.version;
97
- const hasUpdate = semver.gt(latestVersion, currentVersion);
98
- // Check deprecation status of the current version (with caching)
99
- let currentPackageInfo;
100
- try {
101
- currentPackageInfo = await fetchCachedPackageInfo(packageName, currentVersion);
102
- }
103
- catch (error) {
104
- // If we can't fetch the current version info, use the latest version info
105
- log.debug(`Failed to check deprecation for current version: ${error}`);
106
- currentPackageInfo = latestPackageInfo;
107
- }
108
- const isDeprecated = Boolean(currentPackageInfo.deprecated);
109
- const deprecationMessage = isDeprecated
110
- ? String(currentPackageInfo.deprecated)
111
- : undefined;
112
- return {
113
- hasUpdate,
114
- latestVersion,
115
- currentVersion,
116
- isDeprecated,
117
- deprecationMessage,
118
- };
119
- }
120
- catch (error) {
121
- // If we can't check for updates (network issues, etc.), fail silently
122
- log.debug(`Failed to check for updates: ${error}`);
123
- return {
124
- hasUpdate: false,
125
- currentVersion,
126
- isDeprecated: false,
127
- };
128
- }
129
- }
130
- export function displayUpdateNotification(versionInfo, packageName) {
131
- if (versionInfo.isDeprecated) {
132
- console.error();
133
- console.error(chalk.red.bold("⚠️ DEPRECATION WARNING") +
134
- chalk.red(` - ${packageName} v${versionInfo.currentVersion} is deprecated.`));
135
- if (versionInfo.deprecationMessage) {
136
- console.error(chalk.red(` ${versionInfo.deprecationMessage}`));
137
- }
138
- console.error(chalk.red(` Please update to the latest version.`));
139
- console.error();
140
- }
141
- // Use stderr so update notifications don't pollute stdout when piping JSON to jq
142
- if (versionInfo.hasUpdate) {
143
- console.error();
144
- console.error(chalk.yellow.bold("📦 Update available!") +
145
- chalk.yellow(` ${packageName} v${versionInfo.currentVersion} → v${versionInfo.latestVersion}`));
146
- console.error(chalk.yellow(` Run ${chalk.bold(getUpdateCommand(packageName))} to update.`));
147
- console.error();
148
- }
149
- }
150
- export async function checkAndNotifyUpdates({ packageName, currentVersion, }) {
151
- if (CACHE_RESET_INTERVAL_MS < 0) {
152
- return;
153
- }
154
- const versionInfo = await checkForUpdates({ packageName, currentVersion });
155
- displayUpdateNotification(versionInfo, packageName);
156
- }