@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,23 +0,0 @@
1
- export declare const bundleCodePlugin: (sdk: {
2
- context: import("@zapier/zapier-sdk").EventEmissionContext;
3
- } & {
4
- context: {
5
- meta: Record<string, import("@zapier/zapier-sdk").PluginMeta>;
6
- };
7
- }) => {
8
- bundleCode: (options?: {
9
- input: string;
10
- output?: string | undefined;
11
- string?: boolean | undefined;
12
- minify?: boolean | undefined;
13
- target?: string | undefined;
14
- cjs?: boolean | undefined;
15
- } | undefined) => Promise<string>;
16
- } & {
17
- context: {
18
- meta: {
19
- bundleCode: import("@zapier/zapier-sdk").PluginMeta<unknown>;
20
- };
21
- };
22
- };
23
- export type BundleCodePluginProvides = ReturnType<typeof bundleCodePlugin>;
@@ -1,62 +0,0 @@
1
- import { BundleCodeSchema } from "./schemas";
2
- import { createPluginMethod, definePlugin, ZapierBundleError, } 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 = definePlugin((sdk) => createPluginMethod(sdk, {
7
- name: "bundleCode",
8
- categories: ["utility"],
9
- deprecation: { message: "bundleCode is no longer maintained." },
10
- inputSchema: BundleCodeSchema,
11
- handler: async ({ options }) => bundleCode(options),
12
- }));
13
- /**
14
- * Bundle TypeScript code into executable JavaScript (CLI version)
15
- */
16
- async function bundleCode(options) {
17
- const { input, output, target = "es2020", cjs = false, minify = false, string: returnString = false, } = options;
18
- // Resolve input path
19
- const resolvedInput = path.resolve(process.cwd(), input);
20
- try {
21
- // Bundle with esbuild
22
- const result = buildSync({
23
- entryPoints: [resolvedInput],
24
- bundle: true,
25
- platform: "node",
26
- target: target,
27
- format: cjs ? "cjs" : "esm",
28
- minify: minify,
29
- write: false,
30
- external: [], // Bundle everything
31
- banner: {
32
- js: "#!/usr/bin/env node",
33
- },
34
- });
35
- if (result.errors.length > 0) {
36
- const errorMessages = result.errors.map((e) => e.text);
37
- throw new ZapierBundleError(`Bundle failed: ${errorMessages.join(", ")}`, { buildErrors: errorMessages });
38
- }
39
- const bundledCode = result.outputFiles?.[0]?.text;
40
- if (!bundledCode) {
41
- throw new ZapierBundleError("No output generated");
42
- }
43
- let finalOutput = bundledCode;
44
- if (returnString) {
45
- // Output as quoted string for node -e using JSON.stringify
46
- finalOutput = JSON.stringify(bundledCode);
47
- }
48
- // Write to file if output path specified
49
- if (output) {
50
- fs.mkdirSync(path.dirname(output), { recursive: true });
51
- fs.writeFileSync(output, finalOutput, "utf8");
52
- }
53
- return finalOutput;
54
- }
55
- catch (error) {
56
- // If it's already a ZapierBundleError, re-throw as-is
57
- if (error instanceof ZapierBundleError) {
58
- throw error;
59
- }
60
- throw new ZapierBundleError(`Bundle failed: ${error instanceof Error ? error.message : "Unknown error"}`, { cause: error instanceof Error ? error : undefined });
61
- }
62
- }
@@ -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,21 +0,0 @@
1
- import type { PluginMeta } from "@zapier/zapier-sdk";
2
- /**
3
- * CLI-specific metadata overrides. Tags `fetch` with a deprecation so the
4
- * CLI help hides it and a deprecation warning fires when it's invoked.
5
- */
6
- export declare const cliOverridesPlugin: (sdk: {
7
- context: {
8
- meta: {
9
- fetch?: PluginMeta;
10
- };
11
- };
12
- } & {
13
- context: {
14
- meta: Record<string, PluginMeta>;
15
- };
16
- }) => {
17
- context: {
18
- meta: Record<string, PluginMeta<unknown>>;
19
- };
20
- };
21
- export type CliOverridesProvides = ReturnType<typeof cliOverridesPlugin>;
@@ -1,17 +0,0 @@
1
- import { definePlugin } from "@zapier/zapier-sdk";
2
- /**
3
- * CLI-specific metadata overrides. Tags `fetch` with a deprecation so the
4
- * CLI help hides it and a deprecation warning fires when it's invoked.
5
- */
6
- export const cliOverridesPlugin = definePlugin((sdk) => {
7
- const meta = {};
8
- if (sdk.context.meta.fetch) {
9
- meta.fetch = {
10
- ...sdk.context.meta.fetch,
11
- deprecation: {
12
- message: "This command is deprecated and will be removed soon. Use `curl` instead. Learn more: https://docs.zapier.com/sdk/cli-reference#curl",
13
- },
14
- };
15
- }
16
- return { context: { meta } };
17
- });
@@ -1,76 +0,0 @@
1
- import { type CurlOptions } from "./schemas";
2
- export declare const curlPlugin: (sdk: {
3
- fetch: (url: string | URL, init?: import("@zapier/zapier-sdk").ZapierFetchInitOptions) => Promise<Response>;
4
- } & {
5
- context: {
6
- meta: Record<string, import("@zapier/zapier-sdk").PluginMeta>;
7
- };
8
- }) => {
9
- curl: (options: CurlOptions) => Promise<undefined>;
10
- context: {
11
- meta: {
12
- curl: {
13
- description: string;
14
- categories: string[];
15
- inputSchema: import("zod").ZodObject<{
16
- url: import("zod").ZodString;
17
- request: import("zod").ZodOptional<import("zod").ZodEnum<{
18
- GET: "GET";
19
- POST: "POST";
20
- DELETE: "DELETE";
21
- PUT: "PUT";
22
- PATCH: "PATCH";
23
- HEAD: "HEAD";
24
- OPTIONS: "OPTIONS";
25
- }>>;
26
- header: import("zod").ZodOptional<import("zod").ZodArray<import("zod").ZodString>>;
27
- data: import("zod").ZodOptional<import("zod").ZodArray<import("zod").ZodString>>;
28
- dataRaw: import("zod").ZodOptional<import("zod").ZodArray<import("zod").ZodString>>;
29
- dataAscii: import("zod").ZodOptional<import("zod").ZodArray<import("zod").ZodString>>;
30
- dataBinary: import("zod").ZodOptional<import("zod").ZodArray<import("zod").ZodString>>;
31
- dataUrlencode: import("zod").ZodOptional<import("zod").ZodArray<import("zod").ZodString>>;
32
- json: import("zod").ZodOptional<import("zod").ZodString>;
33
- form: import("zod").ZodOptional<import("zod").ZodArray<import("zod").ZodString>>;
34
- formString: import("zod").ZodOptional<import("zod").ZodArray<import("zod").ZodString>>;
35
- get: import("zod").ZodOptional<import("zod").ZodBoolean>;
36
- head: import("zod").ZodOptional<import("zod").ZodBoolean>;
37
- location: import("zod").ZodOptional<import("zod").ZodBoolean>;
38
- include: import("zod").ZodOptional<import("zod").ZodBoolean>;
39
- output: import("zod").ZodOptional<import("zod").ZodString>;
40
- remoteName: import("zod").ZodOptional<import("zod").ZodBoolean>;
41
- verbose: import("zod").ZodOptional<import("zod").ZodBoolean>;
42
- silent: import("zod").ZodOptional<import("zod").ZodBoolean>;
43
- showError: import("zod").ZodOptional<import("zod").ZodBoolean>;
44
- fail: import("zod").ZodOptional<import("zod").ZodBoolean>;
45
- failWithBody: import("zod").ZodOptional<import("zod").ZodBoolean>;
46
- writeOut: import("zod").ZodOptional<import("zod").ZodString>;
47
- maxTime: import("zod").ZodOptional<import("zod").ZodNumber>;
48
- user: import("zod").ZodOptional<import("zod").ZodString>;
49
- compressed: import("zod").ZodOptional<import("zod").ZodBoolean>;
50
- connection: import("zod").ZodOptional<import("zod").ZodUnion<readonly [import("zod").ZodString, import("zod").ZodNumber]>>;
51
- connectionId: import("zod").ZodOptional<import("zod").ZodUnion<readonly [import("zod").ZodString, import("zod").ZodNumber]>>;
52
- }, import("zod/v4/core").$strip>;
53
- aliases: {
54
- request: string;
55
- header: string;
56
- data: string;
57
- form: string;
58
- get: string;
59
- head: string;
60
- location: string;
61
- include: string;
62
- output: string;
63
- remoteName: string;
64
- verbose: string;
65
- silent: string;
66
- showError: string;
67
- writeOut: string;
68
- maxTime: string;
69
- user: string;
70
- fail: string;
71
- };
72
- };
73
- };
74
- };
75
- };
76
- export type CurlPluginProvides = ReturnType<typeof curlPlugin>;
@@ -1,236 +0,0 @@
1
- import { definePlugin } from "@zapier/zapier-sdk";
2
- import { createWriteStream } from "fs";
3
- import { promises as fs } from "fs";
4
- import { dirname } from "path";
5
- import { CurlSchema } from "./schemas";
6
- import { ZapierCurlExitError, parseHeaderLine, basicAuthHeader, deriveRemoteFilename, formatWriteOut, appendQueryParams, readAllStdin, resolveDataArgText, resolveDataArgBinary, buildFormData, } from "./utils";
7
- export const curlPlugin = definePlugin((sdk) => {
8
- async function curl(options) {
9
- const { url: rawUrl, request, header = [], data = [], dataRaw = [], dataAscii = [], dataBinary = [], dataUrlencode = [], json, form = [], formString = [], get: forceGet, head: forceHead, location, include, output, remoteName, verbose, silent, showError, fail, failWithBody, writeOut, maxTime, user, compressed, connection: connectionParam, connectionId, } = options;
10
- const connection = connectionParam ?? connectionId;
11
- const parsedUrl = new URL(rawUrl);
12
- const headers = {};
13
- for (const h of header) {
14
- const parsed = parseHeaderLine(h);
15
- if (parsed) {
16
- headers[parsed.key] = parsed.value;
17
- }
18
- }
19
- if (user) {
20
- headers["Authorization"] = basicAuthHeader(user);
21
- }
22
- if (compressed) {
23
- headers["Accept-Encoding"] = "gzip, deflate, br";
24
- }
25
- const rawTextDataArgs = [...data, ...dataRaw, ...dataAscii];
26
- const rawBinaryDataArgs = [...dataBinary];
27
- const rawUrlencodeArgs = [...dataUrlencode];
28
- const hasForm = form.length > 0 || formString.length > 0;
29
- const hasJson = json !== undefined;
30
- const hasAnyData = hasJson ||
31
- hasForm ||
32
- rawTextDataArgs.length > 0 ||
33
- rawBinaryDataArgs.length > 0 ||
34
- rawUrlencodeArgs.length > 0;
35
- let method = "GET";
36
- if (forceHead) {
37
- method = "HEAD";
38
- }
39
- else if (request) {
40
- method = request;
41
- }
42
- else if (forceGet) {
43
- method = "GET";
44
- }
45
- else if (hasAnyData) {
46
- method = "POST";
47
- }
48
- let body;
49
- let effectiveUrl = parsedUrl;
50
- if (hasJson) {
51
- if (!headers["Content-Type"]) {
52
- headers["Content-Type"] = "application/json";
53
- }
54
- if (!headers["Accept"]) {
55
- headers["Accept"] = "application/json";
56
- }
57
- body = json;
58
- }
59
- else if (hasForm) {
60
- body = await buildFormData(form, formString);
61
- }
62
- else {
63
- const resolvedTextParts = [];
64
- for (const raw of rawTextDataArgs) {
65
- resolvedTextParts.push(await resolveDataArgText(raw));
66
- }
67
- const resolvedUrlEncodeParts = [];
68
- for (const raw of rawUrlencodeArgs) {
69
- // @file => read file, URL-encode contents
70
- if (raw.startsWith("@")) {
71
- const content = await resolveDataArgText(raw);
72
- resolvedUrlEncodeParts.push(encodeURIComponent(content));
73
- continue;
74
- }
75
- const atIdx = raw.indexOf("@");
76
- const eqIdx = raw.indexOf("=");
77
- if (eqIdx !== -1) {
78
- // name=value => encode both
79
- const key = raw.slice(0, eqIdx);
80
- const value = raw.slice(eqIdx + 1);
81
- resolvedUrlEncodeParts.push(`${encodeURIComponent(key)}=${encodeURIComponent(value)}`);
82
- }
83
- else if (atIdx !== -1) {
84
- // name@file => read file, encode contents as value
85
- const key = raw.slice(0, atIdx);
86
- const filePath = raw.slice(atIdx + 1);
87
- const buf = filePath === "-"
88
- ? await readAllStdin()
89
- : await fs.readFile(filePath);
90
- resolvedUrlEncodeParts.push(`${encodeURIComponent(key)}=${encodeURIComponent(buf.toString("utf8"))}`);
91
- }
92
- else {
93
- resolvedUrlEncodeParts.push(encodeURIComponent(raw));
94
- }
95
- }
96
- const resolvedBinaryParts = [];
97
- for (const raw of rawBinaryDataArgs) {
98
- resolvedBinaryParts.push(await resolveDataArgBinary(raw));
99
- }
100
- const allTextParts = [...resolvedTextParts, ...resolvedUrlEncodeParts];
101
- if (forceGet && allTextParts.length > 0) {
102
- effectiveUrl = appendQueryParams(parsedUrl, allTextParts);
103
- }
104
- else if (resolvedBinaryParts.length > 0) {
105
- body = Buffer.concat(resolvedBinaryParts);
106
- }
107
- else if (allTextParts.length > 0) {
108
- body = allTextParts.join("&");
109
- if (!headers["Content-Type"]) {
110
- headers["Content-Type"] = "application/x-www-form-urlencoded";
111
- }
112
- }
113
- }
114
- // curl defaults to NOT following redirects
115
- const redirect = location ? "follow" : "manual";
116
- if (verbose && !silent) {
117
- process.stderr.write(`> ${method} ${effectiveUrl.toString()}\n`);
118
- for (const [k, v] of Object.entries(headers)) {
119
- process.stderr.write(`> ${k}: ${v}\n`);
120
- }
121
- process.stderr.write(">\n");
122
- }
123
- const start = performance.now();
124
- const response = await sdk.fetch(effectiveUrl.toString(), {
125
- method,
126
- headers,
127
- body,
128
- redirect,
129
- connection,
130
- maxTime,
131
- });
132
- const timeTotalSeconds = (performance.now() - start) / 1000;
133
- if (verbose && !silent) {
134
- process.stderr.write(`< HTTP ${response.status} ${response.statusText}\n`);
135
- response.headers.forEach((value, key) => {
136
- process.stderr.write(`< ${key}: ${value}\n`);
137
- });
138
- process.stderr.write("<\n");
139
- }
140
- const isHttpError = response.status >= 400;
141
- const shouldFail = (fail || failWithBody) && isHttpError;
142
- const shouldOutputBody = !shouldFail || !!failWithBody;
143
- const headerText = include
144
- ? `HTTP ${response.status} ${response.statusText}\n${Array.from(response.headers.entries())
145
- .map(([k, v]) => `${k}: ${v}`)
146
- .join("\n")}\n\n`
147
- : "";
148
- let bodyBytes = 0;
149
- const buf = shouldOutputBody
150
- ? Buffer.from(await response.arrayBuffer())
151
- : Buffer.alloc(0);
152
- bodyBytes = buf.length;
153
- const outputFile = output && output !== "-"
154
- ? output
155
- : remoteName
156
- ? deriveRemoteFilename(parsedUrl)
157
- : undefined;
158
- if (outputFile) {
159
- const dir = dirname(outputFile);
160
- if (dir !== ".") {
161
- await fs.mkdir(dir, { recursive: true });
162
- }
163
- const ws = createWriteStream(outputFile);
164
- if (headerText) {
165
- ws.write(headerText);
166
- }
167
- if (buf.length) {
168
- ws.write(buf);
169
- }
170
- await new Promise((resolve, reject) => {
171
- ws.end(() => resolve());
172
- ws.on("error", reject);
173
- });
174
- }
175
- else {
176
- if (headerText) {
177
- process.stdout.write(headerText);
178
- }
179
- if (buf.length) {
180
- process.stdout.write(buf);
181
- }
182
- }
183
- if (writeOut) {
184
- const formatted = formatWriteOut({
185
- template: writeOut,
186
- urlEffective: response.url || effectiveUrl.toString(),
187
- httpCode: response.status,
188
- timeTotalSeconds,
189
- sizeDownloadBytes: bodyBytes,
190
- contentType: response.headers.get("content-type"),
191
- });
192
- process.stdout.write(formatted);
193
- }
194
- if (shouldFail) {
195
- if (!silent || showError) {
196
- process.stderr.write(`curl: (22) The requested URL returned error: ${response.status}\n`);
197
- }
198
- throw new ZapierCurlExitError("HTTP request failed", 22);
199
- }
200
- return undefined;
201
- }
202
- return {
203
- curl,
204
- context: {
205
- meta: {
206
- curl: {
207
- description: "Make authenticated HTTP requests to any API through Zapier. " +
208
- "Pass a connection ID to automatically inject the user's stored credentials " +
209
- "(OAuth tokens, API keys, etc.) into the outgoing request. " +
210
- "Use it in place of the native curl command with additional Zapier-specific options.",
211
- categories: ["http"],
212
- inputSchema: CurlSchema,
213
- aliases: {
214
- request: "X",
215
- header: "H",
216
- data: "d",
217
- form: "F",
218
- get: "G",
219
- head: "I",
220
- location: "L",
221
- include: "i",
222
- output: "o",
223
- remoteName: "O",
224
- verbose: "v",
225
- silent: "s",
226
- showError: "S",
227
- writeOut: "w",
228
- maxTime: "m",
229
- user: "u",
230
- fail: "f",
231
- },
232
- },
233
- },
234
- },
235
- };
236
- });
@@ -1,40 +0,0 @@
1
- import { z } from "zod";
2
- export declare const CurlSchema: z.ZodObject<{
3
- url: z.ZodString;
4
- request: z.ZodOptional<z.ZodEnum<{
5
- GET: "GET";
6
- POST: "POST";
7
- DELETE: "DELETE";
8
- PUT: "PUT";
9
- PATCH: "PATCH";
10
- HEAD: "HEAD";
11
- OPTIONS: "OPTIONS";
12
- }>>;
13
- header: z.ZodOptional<z.ZodArray<z.ZodString>>;
14
- data: z.ZodOptional<z.ZodArray<z.ZodString>>;
15
- dataRaw: z.ZodOptional<z.ZodArray<z.ZodString>>;
16
- dataAscii: z.ZodOptional<z.ZodArray<z.ZodString>>;
17
- dataBinary: z.ZodOptional<z.ZodArray<z.ZodString>>;
18
- dataUrlencode: z.ZodOptional<z.ZodArray<z.ZodString>>;
19
- json: z.ZodOptional<z.ZodString>;
20
- form: z.ZodOptional<z.ZodArray<z.ZodString>>;
21
- formString: z.ZodOptional<z.ZodArray<z.ZodString>>;
22
- get: z.ZodOptional<z.ZodBoolean>;
23
- head: z.ZodOptional<z.ZodBoolean>;
24
- location: z.ZodOptional<z.ZodBoolean>;
25
- include: z.ZodOptional<z.ZodBoolean>;
26
- output: z.ZodOptional<z.ZodString>;
27
- remoteName: z.ZodOptional<z.ZodBoolean>;
28
- verbose: z.ZodOptional<z.ZodBoolean>;
29
- silent: z.ZodOptional<z.ZodBoolean>;
30
- showError: z.ZodOptional<z.ZodBoolean>;
31
- fail: z.ZodOptional<z.ZodBoolean>;
32
- failWithBody: z.ZodOptional<z.ZodBoolean>;
33
- writeOut: z.ZodOptional<z.ZodString>;
34
- maxTime: z.ZodOptional<z.ZodNumber>;
35
- user: z.ZodOptional<z.ZodString>;
36
- compressed: z.ZodOptional<z.ZodBoolean>;
37
- connection: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>>;
38
- connectionId: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>>;
39
- }, z.core.$strip>;
40
- export type CurlOptions = z.infer<typeof CurlSchema>;
@@ -1,108 +0,0 @@
1
- import { z } from "zod";
2
- export const CurlSchema = z
3
- .object({
4
- url: z.string().describe("Request URL"),
5
- request: z
6
- .enum(["GET", "POST", "PUT", "DELETE", "PATCH", "HEAD", "OPTIONS"])
7
- .optional()
8
- .describe("HTTP method (defaults to GET, or POST if data is provided)"),
9
- header: z
10
- .array(z.string())
11
- .optional()
12
- .describe("HTTP headers in 'Key: Value' format (repeatable)"),
13
- data: z
14
- .array(z.string())
15
- .optional()
16
- .describe("HTTP POST data (repeatable, joined with &)"),
17
- dataRaw: z
18
- .array(z.string())
19
- .optional()
20
- .describe("HTTP POST data without special interpretation (repeatable)"),
21
- dataAscii: z
22
- .array(z.string())
23
- .optional()
24
- .describe("HTTP POST ASCII data (repeatable)"),
25
- dataBinary: z
26
- .array(z.string())
27
- .optional()
28
- .describe("HTTP POST binary data (repeatable)"),
29
- dataUrlencode: z
30
- .array(z.string())
31
- .optional()
32
- .describe("HTTP POST data, URL-encoded (repeatable)"),
33
- json: z
34
- .string()
35
- .optional()
36
- .describe("Send JSON body (sets Content-Type and Accept headers)"),
37
- form: z
38
- .array(z.string())
39
- .optional()
40
- .describe("Multipart form data as 'name=value' (repeatable)"),
41
- formString: z
42
- .array(z.string())
43
- .optional()
44
- .describe("Multipart form string field (repeatable)"),
45
- get: z
46
- .boolean()
47
- .optional()
48
- .describe("Force GET method and append data to query string"),
49
- head: z.boolean().optional().describe("Fetch headers only (HEAD request)"),
50
- location: z.boolean().optional().describe("Follow redirects"),
51
- include: z
52
- .boolean()
53
- .optional()
54
- .describe("Include response headers in output"),
55
- output: z
56
- .string()
57
- .optional()
58
- .describe("Write output to file instead of stdout"),
59
- remoteName: z
60
- .boolean()
61
- .optional()
62
- .describe("Write output to file named like the remote file"),
63
- verbose: z
64
- .boolean()
65
- .optional()
66
- .describe("Verbose output (show request/response headers on stderr)"),
67
- silent: z.boolean().optional().describe("Silent mode (suppress errors)"),
68
- showError: z
69
- .boolean()
70
- .optional()
71
- .describe("Show errors even when in silent mode"),
72
- fail: z
73
- .boolean()
74
- .optional()
75
- .describe("Fail silently on HTTP errors (exit code 22)"),
76
- failWithBody: z
77
- .boolean()
78
- .optional()
79
- .describe("Fail on HTTP errors but still output the body"),
80
- writeOut: z
81
- .string()
82
- .optional()
83
- .describe("Output format string after completion (e.g., '%{http_code}')"),
84
- maxTime: z
85
- .number()
86
- .int()
87
- .positive()
88
- .optional()
89
- .describe("Maximum seconds to wait for a response. Honored on a best-effort basis; the server may silently enforce a lower ceiling."),
90
- user: z
91
- .string()
92
- .optional()
93
- .describe("Basic auth credentials as 'user:password'"),
94
- compressed: z
95
- .boolean()
96
- .optional()
97
- .describe("Request compressed response (sends Accept-Encoding header)"),
98
- connection: z
99
- .union([z.string(), z.number()])
100
- .optional()
101
- .describe("Zapier connection ID or alias for authentication"),
102
- /** @deprecated Use `connection` instead. */
103
- connectionId: z
104
- .union([z.string(), z.number()])
105
- .optional()
106
- .meta({ deprecated: true }),
107
- })
108
- .describe("Make HTTP requests through Zapier Relay with curl-like options");
@@ -1,34 +0,0 @@
1
- import { ZapierError } from "@zapier/zapier-sdk";
2
- /**
3
- * Thrown when a curl-style invocation fails — captures the exit code so
4
- * the CLI can surface it (mirrors curl's own non-zero exit codes for
5
- * different failure modes).
6
- */
7
- export declare class ZapierCurlExitError extends ZapierError {
8
- readonly name = "ZapierCurlExitError";
9
- readonly code: "ZAPIER_CURL_EXIT_ERROR";
10
- exitCode: number;
11
- constructor(message: string, exitCode: number);
12
- }
13
- /** @deprecated Use {@link ZapierCurlExitError} instead. */
14
- export declare const CurlExitError: typeof ZapierCurlExitError;
15
- export declare function parseHeaderLine(input: string): {
16
- key: string;
17
- value: string;
18
- } | null;
19
- export declare function basicAuthHeader(userpass: string): string;
20
- export declare function deriveRemoteFilename(url: URL): string;
21
- export declare function decodeWriteOutEscapes(input: string): string;
22
- export declare function formatWriteOut(params: {
23
- template: string;
24
- urlEffective: string;
25
- httpCode: number;
26
- timeTotalSeconds: number;
27
- sizeDownloadBytes: number;
28
- contentType?: string | null;
29
- }): string;
30
- export declare function appendQueryParams(url: URL, dataParts: string[]): URL;
31
- export declare function readAllStdin(): Promise<Buffer>;
32
- export declare function resolveDataArgText(raw: string): Promise<string>;
33
- export declare function resolveDataArgBinary(raw: string): Promise<Buffer>;
34
- export declare function buildFormData(formArgs: string[], formStringArgs: string[]): Promise<FormData>;