@zapier/zapier-sdk-cli 0.59.1 → 0.59.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 (174) hide show
  1. package/CHANGELOG.md +38 -0
  2. package/dist/cli.cjs +51 -36
  3. package/dist/cli.mjs +53 -38
  4. package/dist/experimental.cjs +11 -3
  5. package/dist/experimental.mjs +12 -4
  6. package/dist/index.cjs +12 -4
  7. package/dist/index.mjs +13 -5
  8. package/package.json +3 -3
  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,16 +0,0 @@
1
- interface CliOption {
2
- name: string;
3
- flag: string;
4
- short?: string;
5
- description: string;
6
- }
7
- export declare enum ReservedCliParameter {
8
- Version = "version",
9
- Help = "help"
10
- }
11
- /** CLI options at the framework level, not defined by any SDK command. */
12
- export declare const RESERVED_CLI_OPTIONS: readonly Readonly<CliOption>[];
13
- export declare function getReservedCliOption(name: ReservedCliParameter): Readonly<CliOption>;
14
- /** CLI options automatically added to every SDK-generated command. */
15
- export declare const SHARED_COMMAND_CLI_OPTIONS: readonly Readonly<CliOption>[];
16
- export {};
@@ -1,34 +0,0 @@
1
- export var ReservedCliParameter;
2
- (function (ReservedCliParameter) {
3
- ReservedCliParameter["Version"] = "version";
4
- ReservedCliParameter["Help"] = "help";
5
- })(ReservedCliParameter || (ReservedCliParameter = {}));
6
- /** CLI options at the framework level, not defined by any SDK command. */
7
- export const RESERVED_CLI_OPTIONS = [
8
- {
9
- name: ReservedCliParameter.Version,
10
- flag: "--version",
11
- short: "-V",
12
- description: "Display version number",
13
- },
14
- {
15
- name: ReservedCliParameter.Help,
16
- flag: "--help",
17
- short: "-h",
18
- description: "Display help for command",
19
- },
20
- ];
21
- export function getReservedCliOption(name) {
22
- const option = RESERVED_CLI_OPTIONS.find((opt) => opt.name === name);
23
- if (!option)
24
- throw new Error(`Reserved CLI option not found: ${name}`);
25
- return option;
26
- }
27
- /** CLI options automatically added to every SDK-generated command. */
28
- export const SHARED_COMMAND_CLI_OPTIONS = [
29
- {
30
- name: "json",
31
- flag: "--json",
32
- description: "Output raw JSON instead of formatted results",
33
- },
34
- ];
@@ -1,53 +0,0 @@
1
- import type { FunctionRegistryEntry, SdkPage, ZapierSdk } from "@zapier/zapier-sdk";
2
- export interface JsonErrorEntry {
3
- code: string;
4
- message: string;
5
- reason?: string;
6
- }
7
- export interface JsonEnvelope {
8
- data: unknown;
9
- nextCursor?: string;
10
- errors: JsonErrorEntry[];
11
- }
12
- type PagedSource = AsyncIterable<SdkPage> | PromiseLike<SdkPage>;
13
- export interface CliRenderer {
14
- renderPaginatedList(source: PagedSource, functionInfo: FunctionRegistryEntry): Promise<void>;
15
- renderCollectedList(items: unknown[], options: {
16
- maxItems?: number;
17
- userSpecifiedMaxItems?: boolean;
18
- functionInfo?: FunctionRegistryEntry;
19
- }): Promise<void>;
20
- renderItem(value: unknown, options?: {
21
- outputFile?: unknown;
22
- commandName?: string;
23
- functionInfo?: FunctionRegistryEntry;
24
- }): void;
25
- renderResponse(response: Response): Promise<void>;
26
- renderError(error: unknown): never;
27
- }
28
- /**
29
- * Per-invocation context the interactive renderer threads into the registry
30
- * formatter. `sdk` and `params` are passed to `formatter.fetch(...)` so a
31
- * formatter can enrich items by calling back into the SDK (for example, the
32
- * table-record formatter resolves field IDs to human-readable names).
33
- */
34
- export interface RendererContext {
35
- sdk?: ZapierSdk;
36
- params?: Record<string, unknown>;
37
- }
38
- export declare function buildJsonErrors(error: unknown): JsonErrorEntry[];
39
- /**
40
- * Replacer for JSON.stringify that coerces Error instances to a plain
41
- * object with `{ name, message, stack }`. Without this, `JSON.stringify`
42
- * renders an Error as `{}` (its useful properties are non-enumerable),
43
- * which surfaces in any command that returns Error-like values — most
44
- * notably `drainTriggerInbox` whose `errors[].reason` is typed `unknown`
45
- * and is usually an Error.
46
- *
47
- * Walks recursively because the replacer is invoked for every nested
48
- * key/value pair, not just the top-level value.
49
- */
50
- export declare function jsonReplacer(_key: string, value: unknown): unknown;
51
- export declare function createJsonRenderer(): CliRenderer;
52
- export declare function createInteractiveRenderer(context?: RendererContext): CliRenderer;
53
- export {};
@@ -1,265 +0,0 @@
1
- import { ZapierCliMissingParametersError, ZapierCliExitError } from "./errors";
2
- import { formatErrorMessage, ZapierError } from "@zapier/zapier-sdk";
3
- import { getApprovalReason } from "./approval-errors";
4
- import { formatItemsFromSchema, formatJsonOutput } from "./schema-formatter";
5
- import { toKebabCase } from "./string-utils";
6
- import chalk from "chalk";
7
- import inquirer from "inquirer";
8
- // ============================================================================
9
- // Shared error formatting
10
- // ============================================================================
11
- function formatMissingParamsError(error) {
12
- return [
13
- "Missing required parameters:",
14
- ...error.params.map(({ name, isPositional }) => isPositional
15
- ? ` • <${toKebabCase(name)}>`
16
- : ` • --${toKebabCase(name)}`),
17
- ].join("\n");
18
- }
19
- // ============================================================================
20
- // Shared error serialization (used by JSON renderer)
21
- // ============================================================================
22
- export function buildJsonErrors(error) {
23
- if (error instanceof ZapierCliMissingParametersError) {
24
- return error.params.map(({ name, isPositional }) => ({
25
- code: error.code,
26
- message: isPositional
27
- ? `<${toKebabCase(name)}> is required in non-interactive mode`
28
- : `--${toKebabCase(name)} is required in non-interactive mode`,
29
- }));
30
- }
31
- const code = error instanceof ZapierError ? error.code : "UNKNOWN_ERROR";
32
- const message = error instanceof Error ? error.message : String(error);
33
- const reason = getApprovalReason(error);
34
- return [
35
- {
36
- code,
37
- message,
38
- ...(reason ? { reason } : {}),
39
- },
40
- ];
41
- }
42
- // ============================================================================
43
- // HTTP response unwrapping
44
- // ============================================================================
45
- async function unwrapHttpResponse(response) {
46
- const text = await response.text().catch(() => "[unable to read body]");
47
- try {
48
- return {
49
- statusCode: response.status,
50
- headers: Object.fromEntries(response.headers.entries()),
51
- body: JSON.parse(text),
52
- };
53
- }
54
- catch {
55
- throw new Error(`Failed to parse response as JSON (status: ${response.status}). Body: ${text.slice(0, 500)}`);
56
- }
57
- }
58
- // ============================================================================
59
- // JSON renderer
60
- // ============================================================================
61
- /**
62
- * Replacer for JSON.stringify that coerces Error instances to a plain
63
- * object with `{ name, message, stack }`. Without this, `JSON.stringify`
64
- * renders an Error as `{}` (its useful properties are non-enumerable),
65
- * which surfaces in any command that returns Error-like values — most
66
- * notably `drainTriggerInbox` whose `errors[].reason` is typed `unknown`
67
- * and is usually an Error.
68
- *
69
- * Walks recursively because the replacer is invoked for every nested
70
- * key/value pair, not just the top-level value.
71
- */
72
- export function jsonReplacer(_key, value) {
73
- if (value instanceof Error) {
74
- return {
75
- name: value.name,
76
- message: value.message,
77
- ...(value.stack ? { stack: value.stack } : {}),
78
- };
79
- }
80
- return value;
81
- }
82
- function outputJson(envelope) {
83
- console.log(JSON.stringify(envelope, jsonReplacer, 2));
84
- }
85
- export function createJsonRenderer() {
86
- return {
87
- async renderPaginatedList(source, _functionInfo) {
88
- let page;
89
- if (Symbol.asyncIterator in Object(source)) {
90
- const iter = source[Symbol.asyncIterator]();
91
- const result = await iter.next();
92
- page = result.done ? undefined : result.value;
93
- }
94
- else {
95
- page = await source;
96
- }
97
- const data = Array.isArray(page?.data) ? page.data : [];
98
- outputJson({
99
- data,
100
- ...(page?.nextCursor && { nextCursor: page.nextCursor }),
101
- errors: [],
102
- });
103
- },
104
- async renderCollectedList(items, _options) {
105
- outputJson({ data: items, errors: [] });
106
- },
107
- renderItem(value, options) {
108
- if (value === undefined && !options?.outputFile) {
109
- return;
110
- }
111
- outputJson({
112
- data: options?.outputFile
113
- ? { outputFile: options.outputFile }
114
- : (value ?? null),
115
- errors: [],
116
- });
117
- },
118
- async renderResponse(response) {
119
- // Leave envelope as is for backwards compatibility
120
- // until we fully deprecate fetch from CLI
121
- console.log(JSON.stringify(await unwrapHttpResponse(response), null, 2));
122
- },
123
- renderError(error) {
124
- outputJson({ data: null, errors: buildJsonErrors(error) });
125
- throw new ZapierCliExitError(error instanceof Error ? error.message : String(error), 1);
126
- },
127
- };
128
- }
129
- // ============================================================================
130
- // Interactive renderer
131
- // ============================================================================
132
- function getItemName(functionInfo) {
133
- if (functionInfo?.itemType)
134
- return `${functionInfo.itemType} items`;
135
- return "items";
136
- }
137
- function getListTitle(functionInfo) {
138
- if (functionInfo.itemType)
139
- return `Available ${functionInfo.itemType} items`;
140
- return "items";
141
- }
142
- export function createInteractiveRenderer(context = {}) {
143
- async function renderItemsForDisplay(items, functionInfo, startingNumber = 0) {
144
- if (functionInfo?.inputSchema) {
145
- // `formatter` on the registry entry is typed `unknown` so the registry
146
- // layer stays SDK-agnostic; cast back to the CLI-side shape here at the
147
- // boundary where we actually use it.
148
- await formatItemsFromSchema(functionInfo, items, startingNumber, {
149
- formatter: functionInfo.formatter,
150
- sdk: context.sdk,
151
- params: context.params,
152
- });
153
- }
154
- else {
155
- items.forEach((item, index) => {
156
- const obj = item;
157
- const name = obj?.name || obj?.key || obj?.id || "Item";
158
- console.log(`${chalk.gray(`${startingNumber + index + 1}.`)} ${chalk.cyan(String(name))}`);
159
- if (obj?.description)
160
- console.log(` ${chalk.dim(String(obj.description))}`);
161
- console.log();
162
- });
163
- }
164
- }
165
- return {
166
- async renderPaginatedList(source, functionInfo) {
167
- const itemName = getItemName(functionInfo);
168
- if (!(Symbol.asyncIterator in Object(source))) {
169
- const items = source?.data;
170
- if (!Array.isArray(items) || items.length === 0) {
171
- console.log(chalk.yellow(`No ${itemName} found.`));
172
- return;
173
- }
174
- await renderItemsForDisplay(items, functionInfo, 0);
175
- console.log(chalk.green(`\n✅ Showing ${items.length} ${itemName}`));
176
- return;
177
- }
178
- let totalShown = 0;
179
- let pageCount = 0;
180
- console.log(chalk.blue(`📋 ${getListTitle(functionInfo)}\n`));
181
- for await (const page of source) {
182
- const items = page.data ?? [];
183
- pageCount++;
184
- if (items.length === 0 && pageCount === 1) {
185
- console.log(chalk.yellow(`No ${itemName} found.`));
186
- return;
187
- }
188
- if (items.length === 0)
189
- break;
190
- if (pageCount > 1) {
191
- console.clear();
192
- console.log(chalk.blue(`📋 ${getListTitle(functionInfo)}\n`));
193
- }
194
- await renderItemsForDisplay(items, functionInfo, totalShown);
195
- totalShown += items.length;
196
- console.log(chalk.green(`\n✅ Showing ${totalShown} ${itemName} (page ${pageCount})`));
197
- if (page.nextCursor) {
198
- const { continueReading } = await inquirer.prompt([
199
- {
200
- type: "confirm",
201
- name: "continueReading",
202
- message: "Load next page?",
203
- default: true,
204
- },
205
- ]);
206
- if (!continueReading)
207
- break;
208
- }
209
- else {
210
- break;
211
- }
212
- }
213
- console.log(chalk.gray(`\n📄 Finished browsing ${itemName}`));
214
- },
215
- async renderCollectedList(items, { maxItems, userSpecifiedMaxItems, functionInfo } = {}) {
216
- if (!Array.isArray(items)) {
217
- formatJsonOutput(items);
218
- return;
219
- }
220
- const itemName = getItemName(functionInfo);
221
- if (items.length === 0) {
222
- console.log(chalk.yellow(`No ${itemName} found.`));
223
- return;
224
- }
225
- console.log(chalk.green(`\n✅ Found ${items.length} ${itemName}:\n`));
226
- await renderItemsForDisplay(items, functionInfo);
227
- if (userSpecifiedMaxItems && maxItems) {
228
- console.log(chalk.gray(`\n📄 Showing up to ${maxItems} ${itemName} (--max-items ${maxItems})`));
229
- }
230
- else {
231
- console.log(chalk.gray(`\n📄 All available ${itemName} shown`));
232
- }
233
- },
234
- renderItem(value, options) {
235
- if (options?.outputFile) {
236
- const label = options.commandName
237
- ? `✅ ${options.commandName} completed successfully!`
238
- : "✅ Done!";
239
- console.log(chalk.green(label));
240
- console.log(chalk.gray(`Output written to: ${options.outputFile}`));
241
- }
242
- else {
243
- formatJsonOutput(value);
244
- }
245
- },
246
- async renderResponse(response) {
247
- formatJsonOutput(await unwrapHttpResponse(response));
248
- },
249
- renderError(error) {
250
- if (error instanceof ZapierCliMissingParametersError) {
251
- console.error(chalk.red("❌ " + formatMissingParamsError(error)));
252
- console.error("\n" + chalk.dim("Use --help to see available options"));
253
- throw new ZapierCliExitError(error.message, 1);
254
- }
255
- if (error instanceof ZapierError) {
256
- const formattedMessage = formatErrorMessage(error);
257
- console.error(chalk.red("❌ Error:"), formattedMessage);
258
- throw new ZapierCliExitError(formattedMessage, 1);
259
- }
260
- const msg = error instanceof Error ? error.message : "Unknown error";
261
- console.error(chalk.red("❌ Error:"), msg);
262
- throw new ZapierCliExitError(msg, 1);
263
- },
264
- };
265
- }
@@ -1,3 +0,0 @@
1
- export { AUTH_MODE_HEADER } from "../login";
2
- export declare const LOGIN_PORTS: number[];
3
- export declare const LOGIN_TIMEOUT_MS = 300000;
@@ -1,5 +0,0 @@
1
- // Import shared OAuth constants from login package
2
- export { AUTH_MODE_HEADER } from "../login";
3
- // CLI-specific constants
4
- export const LOGIN_PORTS = [49505, 50575, 52804, 55981, 61010, 63851];
5
- export const LOGIN_TIMEOUT_MS = 300000; // 5 minutes
@@ -1,5 +0,0 @@
1
- /**
2
- * Detect the best default directory for TypeScript types
3
- * Looks for src or lib directories, falls back to current directory
4
- */
5
- export declare function detectTypesOutputDirectory(): Promise<string>;
@@ -1,21 +0,0 @@
1
- import { access } from "fs/promises";
2
- import { join } from "path";
3
- /**
4
- * Detect the best default directory for TypeScript types
5
- * Looks for src or lib directories, falls back to current directory
6
- */
7
- export async function detectTypesOutputDirectory() {
8
- // Check for common source directories in priority order
9
- const candidates = ["src", "lib"];
10
- for (const candidate of candidates) {
11
- try {
12
- await access(candidate);
13
- return join(candidate, "zapier", "apps");
14
- }
15
- catch {
16
- // Directory doesn't exist, continue to next candidate
17
- }
18
- }
19
- // Fall back to current directory
20
- return "./zapier/apps/";
21
- }
@@ -1,33 +0,0 @@
1
- import { ZapierError } from "@zapier/zapier-sdk";
2
- export declare abstract class ZapierCliError extends ZapierError {
3
- abstract readonly exitCode: number;
4
- }
5
- export declare class ZapierCliUserCancellationError extends ZapierCliError {
6
- readonly name = "ZapierCliUserCancellationError";
7
- readonly code = "ZAPIER_CLI_USER_CANCELLATION";
8
- readonly exitCode = 0;
9
- constructor(message?: string);
10
- }
11
- export declare class ZapierCliExitError extends ZapierCliError {
12
- readonly name = "ZapierCliExitError";
13
- readonly code = "ZAPIER_CLI_EXIT";
14
- readonly exitCode: number;
15
- constructor(message: string, exitCode?: number);
16
- }
17
- export interface MissingParam {
18
- name: string;
19
- isPositional: boolean;
20
- }
21
- export declare class ZapierCliValidationError extends ZapierCliError {
22
- readonly name = "ZapierCliValidationError";
23
- readonly code = "ZAPIER_CLI_VALIDATION_ERROR";
24
- readonly exitCode = 1;
25
- constructor(message: string);
26
- }
27
- export declare class ZapierCliMissingParametersError extends ZapierCliError {
28
- readonly name = "ZapierCliMissingParametersError";
29
- readonly code = "ZAPIER_CLI_MISSING_PARAMETERS";
30
- readonly exitCode = 1;
31
- readonly params: MissingParam[];
32
- constructor(params: MissingParam[]);
33
- }
@@ -1,36 +0,0 @@
1
- import { ZapierError } from "@zapier/zapier-sdk";
2
- export class ZapierCliError extends ZapierError {
3
- }
4
- export class ZapierCliUserCancellationError extends ZapierCliError {
5
- constructor(message = "Operation cancelled by user") {
6
- super(message);
7
- this.name = "ZapierCliUserCancellationError";
8
- this.code = "ZAPIER_CLI_USER_CANCELLATION";
9
- this.exitCode = 0;
10
- }
11
- }
12
- export class ZapierCliExitError extends ZapierCliError {
13
- constructor(message, exitCode = 1) {
14
- super(message);
15
- this.name = "ZapierCliExitError";
16
- this.code = "ZAPIER_CLI_EXIT";
17
- this.exitCode = exitCode;
18
- }
19
- }
20
- export class ZapierCliValidationError extends ZapierCliError {
21
- constructor(message) {
22
- super(message);
23
- this.name = "ZapierCliValidationError";
24
- this.code = "ZAPIER_CLI_VALIDATION_ERROR";
25
- this.exitCode = 1;
26
- }
27
- }
28
- export class ZapierCliMissingParametersError extends ZapierCliError {
29
- constructor(params) {
30
- super(`Missing required parameters: ${params.map((p) => p.name).join(", ")}`);
31
- this.name = "ZapierCliMissingParametersError";
32
- this.code = "ZAPIER_CLI_MISSING_PARAMETERS";
33
- this.exitCode = 1;
34
- this.params = params;
35
- }
36
- }
@@ -1,20 +0,0 @@
1
- import type { Plugin, PluginProvides } from "@zapier/zapier-sdk";
2
- /**
3
- * Discovers and dynamically imports SDK extension packages declared via the
4
- * `ZAPIER_SDK_EXTENSIONS` env var (comma-separated package specifiers).
5
- * Each spec is `await import()`-ed and its default export is normalized via
6
- * {@link normalizeExtension}. A failed import or unrecognized export shape
7
- * triggers a warning and skip — a broken extension never kills the CLI.
8
- *
9
- * A richer, declarative discovery path (e.g. `.zapierrc` extensions) is
10
- * tracked as a follow-up; for now the env var is the only entry point.
11
- */
12
- export declare function resolveExtensions(): Promise<Plugin<unknown, PluginProvides>[]>;
13
- /**
14
- * Translates a module's default export into a plugin array suitable for
15
- * `.addPlugin(...)`. Accepts:
16
- * - a single Plugin function → `[fn]`
17
- * - an array of Plugin functions → returned as-is
18
- * Returns `null` for unrecognized shapes (caller emits a skip warning).
19
- */
20
- export declare function normalizeExtension(exported: unknown): Plugin<unknown, PluginProvides>[] | null;
@@ -1,66 +0,0 @@
1
- const ENV_VAR = "ZAPIER_SDK_EXTENSIONS";
2
- /**
3
- * Discovers and dynamically imports SDK extension packages declared via the
4
- * `ZAPIER_SDK_EXTENSIONS` env var (comma-separated package specifiers).
5
- * Each spec is `await import()`-ed and its default export is normalized via
6
- * {@link normalizeExtension}. A failed import or unrecognized export shape
7
- * triggers a warning and skip — a broken extension never kills the CLI.
8
- *
9
- * A richer, declarative discovery path (e.g. `.zapierrc` extensions) is
10
- * tracked as a follow-up; for now the env var is the only entry point.
11
- */
12
- export async function resolveExtensions() {
13
- const seen = new Set();
14
- const specs = readEnvSpecs().filter((spec) => {
15
- if (seen.has(spec))
16
- return false;
17
- seen.add(spec);
18
- return true;
19
- });
20
- const plugins = [];
21
- for (const spec of specs) {
22
- try {
23
- const mod = await import(spec);
24
- const exported = mod.default ?? mod;
25
- const got = normalizeExtension(exported);
26
- if (got) {
27
- plugins.push(...got);
28
- }
29
- else {
30
- console.warn(`Extension '${spec}': unrecognized default export shape; skipping.`);
31
- }
32
- }
33
- catch (err) {
34
- console.warn(`Extension '${spec}' failed to load: ${err.message}`);
35
- }
36
- }
37
- return plugins;
38
- }
39
- /**
40
- * Translates a module's default export into a plugin array suitable for
41
- * `.addPlugin(...)`. Accepts:
42
- * - a single Plugin function → `[fn]`
43
- * - an array of Plugin functions → returned as-is
44
- * Returns `null` for unrecognized shapes (caller emits a skip warning).
45
- */
46
- export function normalizeExtension(exported) {
47
- if (typeof exported === "function") {
48
- return [exported];
49
- }
50
- if (Array.isArray(exported)) {
51
- if (exported.every((e) => typeof e === "function")) {
52
- return exported;
53
- }
54
- return null;
55
- }
56
- return null;
57
- }
58
- function readEnvSpecs() {
59
- const raw = process.env[ENV_VAR];
60
- if (!raw)
61
- return [];
62
- return raw
63
- .split(",")
64
- .map((s) => s.trim())
65
- .filter((s) => s.length > 0);
66
- }
@@ -1,6 +0,0 @@
1
- declare const getCallablePromise: <T>() => {
2
- promise: Promise<T>;
3
- resolve: (value: T) => void;
4
- reject: (reason: unknown) => void;
5
- };
6
- export default getCallablePromise;
@@ -1,14 +0,0 @@
1
- const getCallablePromise = () => {
2
- let resolve = () => { };
3
- let reject = () => { };
4
- const promise = new Promise((_resolve, _reject) => {
5
- resolve = _resolve;
6
- reject = _reject;
7
- });
8
- return {
9
- promise,
10
- resolve,
11
- reject,
12
- };
13
- };
14
- export default getCallablePromise;
@@ -1,8 +0,0 @@
1
- declare const log: {
2
- info: (message: string, ...args: unknown[]) => void;
3
- error: (message: string, ...args: unknown[]) => void;
4
- success: (message: string, ...args: unknown[]) => void;
5
- warn: (message: string, ...args: unknown[]) => void;
6
- debug: (message: string, ...args: unknown[]) => void;
7
- };
8
- export default log;
@@ -1,26 +0,0 @@
1
- import chalk from "chalk";
2
- // Every method here writes to stderr. The CLI reserves stdout for the
3
- // program's data payload (command output, JSON, response bodies); status,
4
- // info, warnings, errors, and debug all belong on stderr so they don't
5
- // break callers piping CLI output through jq, > redirect, or JSON.parse.
6
- // In a TTY both streams interleave, so interactive users see no change.
7
- const log = {
8
- info: (message, ...args) => {
9
- console.error(chalk.blue("ℹ"), message, ...args);
10
- },
11
- error: (message, ...args) => {
12
- console.error(chalk.red("✖"), message, ...args);
13
- },
14
- success: (message, ...args) => {
15
- console.error(chalk.green("✓"), message, ...args);
16
- },
17
- warn: (message, ...args) => {
18
- console.error(chalk.yellow("⚠"), message, ...args);
19
- },
20
- debug: (message, ...args) => {
21
- if (process.env.DEBUG === "true" || process.argv.includes("--debug")) {
22
- console.error(chalk.gray("🐛"), message, ...args);
23
- }
24
- },
25
- };
26
- export default log;
@@ -1,10 +0,0 @@
1
- import type { AppItem, ManifestEntry } from "@zapier/zapier-sdk";
2
- /**
3
- * Get the preferred key for a manifest entry
4
- * Prefers slug over implementation name
5
- */
6
- export declare function getManifestKey(app: AppItem): string;
7
- /**
8
- * Create a manifest entry from an app
9
- */
10
- export declare function createManifestEntry(app: AppItem): ManifestEntry;
@@ -1,19 +0,0 @@
1
- /**
2
- * Get the preferred key for a manifest entry
3
- * Prefers slug over implementation name
4
- */
5
- export function getManifestKey(app) {
6
- return app.slug || app.key;
7
- }
8
- /**
9
- * Create a manifest entry from an app
10
- */
11
- export function createManifestEntry(app) {
12
- if (!app.version) {
13
- throw new Error(`App ${app.key} does not have a version. Implementation ID: ${app.implementation_id}`);
14
- }
15
- return {
16
- implementationName: app.key,
17
- version: app.version,
18
- };
19
- }