@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
package/dist/package.json DELETED
@@ -1,121 +0,0 @@
1
- {
2
- "name": "@zapier/zapier-sdk-cli",
3
- "version": "0.59.1",
4
- "description": "Command line interface for Zapier SDK",
5
- "main": "dist/index.cjs",
6
- "module": "dist/index.mjs",
7
- "types": "dist/index.d.ts",
8
- "exports": {
9
- ".": {
10
- "source": "./src/index.ts",
11
- "require": {
12
- "types": "./dist/index.d.ts",
13
- "default": "./dist/index.cjs"
14
- },
15
- "import": {
16
- "types": "./dist/index.d.mts",
17
- "default": "./dist/index.mjs"
18
- }
19
- },
20
- "./login": {
21
- "source": "./src/login.ts",
22
- "require": {
23
- "types": "./dist/login.d.ts",
24
- "default": "./dist/login.cjs"
25
- },
26
- "import": {
27
- "types": "./dist/login.d.mts",
28
- "default": "./dist/login.mjs"
29
- }
30
- },
31
- "./experimental": {
32
- "source": "./src/experimental.ts",
33
- "require": {
34
- "types": "./dist/experimental.d.ts",
35
- "default": "./dist/experimental.cjs"
36
- },
37
- "import": {
38
- "types": "./dist/experimental.d.mts",
39
- "default": "./dist/experimental.mjs"
40
- }
41
- }
42
- },
43
- "bin": {
44
- "zapier-sdk": "./bin/zapier-sdk.mjs",
45
- "zapier-sdk-cli": "./bin/zapier-sdk.mjs",
46
- "zapier-sdk-experimental": "./bin/zapier-sdk-experimental.mjs"
47
- },
48
- "scripts": {
49
- "test": "vitest",
50
- "build": "tsup",
51
- "clean": "rm -rf dist",
52
- "rebuild": "pnpm clean && pnpm build",
53
- "dev": "tsx src/cli.ts",
54
- "typecheck": "tsc --project tsconfig.build.json --noEmit",
55
- "prepublishOnly": "node ../../scripts/check-version.js"
56
- },
57
- "keywords": [
58
- "zapier",
59
- "cli",
60
- "sdk"
61
- ],
62
- "author": "",
63
- "license": "SEE LICENSE IN LICENSE",
64
- "files": [
65
- "dist",
66
- "bin",
67
- "templates",
68
- "README.md",
69
- "CHANGELOG.md",
70
- "AGENTS.md",
71
- "CLAUDE.md"
72
- ],
73
- "repository": {
74
- "type": "git",
75
- "url": "https://gitlab.com/zapier/zapier-sdk/zapier-sdk.git",
76
- "directory": "packages/zapier-sdk-cli"
77
- },
78
- "homepage": "https://docs.zapier.com/sdk/using-the-cli",
79
- "publishConfig": {
80
- "access": "public"
81
- },
82
- "dependencies": {
83
- "@inquirer/search": "^3.2.2",
84
- "@zapier/policy-schema": "0.15.0",
85
- "@zapier/zapier-sdk": "workspace:*",
86
- "@zapier/zapier-sdk-mcp": "workspace:*",
87
- "chalk": "^5.3.0",
88
- "cli-table3": "^0.6.5",
89
- "commander": "^12.0.0",
90
- "conf": "^14.0.0",
91
- "cross-keychain": "^1.1.0",
92
- "esbuild": "^0.25.5",
93
- "express": "^5.1.0",
94
- "handlebars": "^4.7.8",
95
- "ink": "7.0.5",
96
- "inquirer": "^12.6.3",
97
- "is-installed-globally": "^1.0.0",
98
- "jsonwebtoken": "^9.0.2",
99
- "open": "^10.2.0",
100
- "ora": "^8.2.0",
101
- "package-json": "^10.0.1",
102
- "pkce-challenge": "^5.0.0",
103
- "proper-lockfile": "^4.1.2",
104
- "react": "19.2.6",
105
- "semver": "^7.7.3",
106
- "typescript": "^5.8.3",
107
- "wrap-ansi": "^10.0.0",
108
- "zod": "4.3.6"
109
- },
110
- "devDependencies": {
111
- "@types/express": "^5.0.3",
112
- "@types/inquirer": "^9.0.8",
113
- "@types/jsonwebtoken": "^9.0.10",
114
- "@types/node": "^24.0.1",
115
- "@types/proper-lockfile": "^4.1.4",
116
- "@types/react": "19.2.15",
117
- "@types/semver": "^7.7.1",
118
- "tsup": "^8.5.0",
119
- "vitest": "^4.1.4"
120
- }
121
- }
package/dist/src/cli.d.ts DELETED
@@ -1,2 +0,0 @@
1
- #!/usr/bin/env node
2
- export {};
package/dist/src/cli.js DELETED
@@ -1,219 +0,0 @@
1
- #!/usr/bin/env node
2
- import { Command, CommanderError } from "commander";
3
- import { generateCliCommands } from "./utils/cli-generator";
4
- import { createZapierCliSdk as createStableCliSdk } from "./sdk";
5
- import { createZapierCliSdk as createExperimentalCliSdk } from "./experimental";
6
- import { resolveExtensions } from "./utils/extensions";
7
- import packageJson from "../package.json" with { type: "json" };
8
- import { ZapierCliError } from "./utils/errors";
9
- import { checkAndNotifyUpdates } from "./utils/version-checker";
10
- import { BaseSdkOptionsSchema } from "@zapier/zapier-sdk";
11
- import { z } from "zod";
12
- import { ReservedCliParameter, getReservedCliOption, } from "./utils/cli-options";
13
- import { createApprovalProgressRenderer } from "./utils/approval-progress";
14
- const EXIT_GRACE_PERIOD_MS = 500;
15
- const program = new Command();
16
- const versionOption = getReservedCliOption(ReservedCliParameter.Version);
17
- const helpOption = getReservedCliOption(ReservedCliParameter.Help);
18
- program
19
- .name("zapier-sdk")
20
- .description("CLI for Zapier SDK")
21
- .version(packageJson.version, `${versionOption.short}, ${versionOption.flag}`, versionOption.description)
22
- .option("--debug", "Enable debug logging")
23
- .option("--base-url <url>", "Base URL for Zapier API endpoints")
24
- .option("--credentials <token>", "Authentication token")
25
- .option("--credentials-client-id <id>", "OAuth client ID for authentication")
26
- .option("--credentials-client-secret <secret>", "OAuth client secret for authentication")
27
- .option("--credentials-base-url <url>", "Base URL for authentication endpoints")
28
- .option("--tracking-base-url <url>", "Base URL for Zapier tracking endpoints")
29
- .option("--max-network-retries <count>", "Max retries for rate-limited requests (default: 3)")
30
- .option("--max-network-retry-delay-ms <ms>", "Max delay in ms to wait for rate limit retry (default: 60000)")
31
- .option("--max-concurrent-requests <count>", "Max concurrent in-flight HTTP requests (default: 200). Pass 'Infinity' to disable.")
32
- // Registered so Commander accepts --experimental without rejecting it as
33
- // unknown. The actual factory selection happens before Commander parses,
34
- // by peeking at argv directly. Equivalent to using the
35
- // `zapier-sdk-experimental` bin or setting `ZAPIER_EXPERIMENTAL=1`.
36
- .option("--experimental", "Use the experimental SDK / CLI surface");
37
- // Dynamically register boolean flags from BaseSdkOptionsSchema
38
- const booleanFlags = [];
39
- for (const [key, fieldSchema] of Object.entries(
40
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
41
- BaseSdkOptionsSchema.shape)) {
42
- let inner = fieldSchema;
43
- if (inner instanceof z.ZodOptional) {
44
- inner = inner._zod.def.innerType;
45
- }
46
- if (inner instanceof z.ZodBoolean && key !== "debug") {
47
- const kebab = key.replace(/([A-Z])/g, "-$1").toLowerCase();
48
- const description = fieldSchema.description ?? inner.description ?? "";
49
- booleanFlags.push({ camelName: key, kebabFlag: `--${kebab}` });
50
- program.option(`--${kebab}`, description);
51
- }
52
- }
53
- program.helpOption(`${helpOption.short}, ${helpOption.flag}`, helpOption.description);
54
- // Check for debug flag early (support both flag and env var)
55
- const isDebugMode = process.env.DEBUG === "true" || process.argv.includes("--debug");
56
- // Helper to get flag value from argv. Handles both Commander forms:
57
- // `--flag value` (returns the next argv entry) and `--flag=value` (returns
58
- // the part after the equals). Returns undefined only when the flag is
59
- // genuinely absent — an explicit empty string still returns "".
60
- function getFlagValue(flagName) {
61
- const prefix = `${flagName}=`;
62
- for (let i = 0; i < process.argv.length; i++) {
63
- const arg = process.argv[i];
64
- if (arg === flagName)
65
- return process.argv[i + 1];
66
- if (arg.startsWith(prefix))
67
- return arg.slice(prefix.length);
68
- }
69
- return undefined;
70
- }
71
- // Extract options from process.argv for early SDK creation
72
- // We need to create the SDK before parsing to generate commands from schemas
73
- const baseUrl = getFlagValue("--base-url");
74
- const credentialsToken = getFlagValue("--credentials");
75
- const credentialsClientId = getFlagValue("--credentials-client-id");
76
- const credentialsClientSecret = getFlagValue("--credentials-client-secret");
77
- const credentialsBaseUrl = getFlagValue("--credentials-base-url");
78
- const trackingBaseUrl = getFlagValue("--tracking-base-url");
79
- const maxNetworkRetriesStr = getFlagValue("--max-network-retries");
80
- const maxNetworkRetries = maxNetworkRetriesStr
81
- ? parseInt(maxNetworkRetriesStr, 10)
82
- : undefined;
83
- const maxNetworkRetryDelayMsStr = getFlagValue("--max-network-retry-delay-ms");
84
- const maxNetworkRetryDelayMs = maxNetworkRetryDelayMsStr
85
- ? parseInt(maxNetworkRetryDelayMsStr, 10)
86
- : undefined;
87
- const maxConcurrentRequestsStr = getFlagValue("--max-concurrent-requests");
88
- // "Infinity" is the explicit disable sentinel. parseInt of an all-digit
89
- // overflow value (e.g. "9".repeat(309)) also returns ±Infinity, which
90
- // would otherwise look like the sentinel and silently disable throttling
91
- // — coerce non-finite parseInt results to NaN so the SDK boundary's
92
- // fall-back-to-default branch handles them.
93
- let maxConcurrentRequests;
94
- if (maxConcurrentRequestsStr === undefined) {
95
- maxConcurrentRequests = undefined;
96
- }
97
- else if (maxConcurrentRequestsStr === "Infinity") {
98
- maxConcurrentRequests = Infinity;
99
- }
100
- else {
101
- const parsed = parseInt(maxConcurrentRequestsStr, 10);
102
- maxConcurrentRequests = Number.isFinite(parsed) ? parsed : NaN;
103
- }
104
- // Build credentials object from flags
105
- function buildCredentialsFromFlags() {
106
- // If a direct token is provided, use it
107
- if (credentialsToken) {
108
- return credentialsToken;
109
- }
110
- // If client ID is provided, build a credentials object
111
- if (credentialsClientId) {
112
- if (credentialsClientSecret) {
113
- // Client credentials flow
114
- return {
115
- type: "client_credentials",
116
- clientId: credentialsClientId,
117
- clientSecret: credentialsClientSecret,
118
- ...(credentialsBaseUrl && { baseUrl: credentialsBaseUrl }),
119
- };
120
- }
121
- else {
122
- // PKCE flow (no secret)
123
- return {
124
- type: "pkce",
125
- clientId: credentialsClientId,
126
- ...(credentialsBaseUrl && { baseUrl: credentialsBaseUrl }),
127
- };
128
- }
129
- }
130
- // No credentials from flags - will fall back to env vars or stored login
131
- return undefined;
132
- }
133
- const credentials = buildCredentialsFromFlags();
134
- // Extract boolean flags from argv
135
- const flagOverrides = {};
136
- for (const { camelName, kebabFlag } of booleanFlags) {
137
- if (process.argv.includes(kebabFlag)) {
138
- flagOverrides[camelName] = true;
139
- }
140
- }
141
- // Pick which CLI SDK factory to use BEFORE Commander parses anything,
142
- // because the registry of available commands differs by factory:
143
- // experimental commands literally don't exist in the stable factory's
144
- // registry. Two equivalent triggers, either of which selects experimental:
145
- //
146
- // - `--experimental` appears in argv (passed by the user, or pushed by
147
- // the `zapier-sdk-experimental` bin shim)
148
- // - `ZAPIER_EXPERIMENTAL=1` is set in the environment
149
- //
150
- // The bin shim works by pushing `--experimental` onto argv before
151
- // importing this file, so this single argv check covers both `zapier-sdk
152
- // --experimental` and the dedicated `zapier-sdk-experimental` bin.
153
- const useExperimental = process.argv.includes("--experimental") ||
154
- process.env.ZAPIER_EXPERIMENTAL === "1" ||
155
- process.env.ZAPIER_EXPERIMENTAL === "true";
156
- const createZapierCliSdk = useExperimental
157
- ? createExperimentalCliSdk
158
- : createStableCliSdk;
159
- const approvalProgress = createApprovalProgressRenderer({
160
- enabled: process.stderr.isTTY === true,
161
- });
162
- // Override Commander's default exit behavior to handle our custom errors
163
- program.exitOverride();
164
- (async () => {
165
- let exitCode = 0;
166
- // Resolve extension packages declared via the ZAPIER_SDK_EXTENSIONS env
167
- // var. Pre-resolving here keeps createZapierCliSdk synchronous for
168
- // programmatic callers.
169
- const extensions = await resolveExtensions();
170
- // Create CLI SDK instance with all plugins and URL options
171
- const sdk = createZapierCliSdk({
172
- debug: isDebugMode,
173
- credentials,
174
- baseUrl,
175
- trackingBaseUrl,
176
- maxNetworkRetries,
177
- maxNetworkRetryDelayMs,
178
- maxConcurrentRequests,
179
- onEvent: approvalProgress.onEvent,
180
- ...flagOverrides,
181
- extensions,
182
- });
183
- // Generate CLI commands from SDK schemas (including CLI plugins and extensions)
184
- generateCliCommands(program, sdk);
185
- // Start version checking non-blocking
186
- const versionCheckPromise = checkAndNotifyUpdates({
187
- packageName: packageJson.name,
188
- currentVersion: packageJson.version,
189
- });
190
- try {
191
- await program.parseAsync();
192
- }
193
- catch (error) {
194
- if (error instanceof ZapierCliError) {
195
- exitCode = error.exitCode;
196
- }
197
- else if (error instanceof CommanderError) {
198
- exitCode = error.exitCode;
199
- }
200
- else {
201
- // For any other unexpected errors, exit with code 1
202
- console.error("Unexpected error:", error);
203
- exitCode = 1;
204
- }
205
- }
206
- // Wait for version checking to complete
207
- await versionCheckPromise;
208
- // Flush the exit telemetry event before we force-terminate. The async
209
- // transport needs an explicit await because process.on("exit") only
210
- // allows synchronous work.
211
- await sdk.context.eventEmission.close(exitCode);
212
- // Force exit after a short grace period. We can't rely on process.exitCode
213
- // alone because background handles (stdin, pending file closes) keep the
214
- // event loop alive indefinitely. The unref'd timer won't prevent natural
215
- // exit, but guarantees the process terminates if the loop doesn't drain.
216
- const exitTimeout = setTimeout(() => process.exit(exitCode), EXIT_GRACE_PERIOD_MS);
217
- exitTimeout.unref();
218
- process.exitCode = exitCode;
219
- })();
@@ -1,33 +0,0 @@
1
- /**
2
- * Experimental CLI SDK factory.
3
- *
4
- * Mirror of `./sdk.ts`, but built on top of
5
- * `@zapier/zapier-sdk/experimental` so the underlying SDK has every
6
- * `meta.experimental: true` plugin registered. The CLI's runtime
7
- * entry point (`cli.ts`) chooses between this and the stable factory
8
- * based on three equivalent triggers detected before Commander parses:
9
- * the `zapier-sdk-experimental` bin name (via `argv[1]`), the
10
- * `--experimental` flag, or the `ZAPIER_EXPERIMENTAL=1` env var.
11
- *
12
- * Plugin chain matches `./sdk.ts` literally, with future CLI-only
13
- * experimental plugins inserted at appropriate positions. Both
14
- * factories are kept in sync by shape tests.
15
- */
16
- import { type Plugin, type PluginProvides, type ZapierSdkOptions } from "@zapier/zapier-sdk/experimental";
17
- import type { ZapierSdkCli } from "./types/sdk";
18
- export interface ZapierCliSdkOptions extends ZapierSdkOptions {
19
- /**
20
- * Extra plugins discovered from `@zapier/zapier-sdk` extension packages.
21
- * Pre-resolved by `cli.ts` (`utils/extensions.ts`) so this factory stays
22
- * synchronous. Each plugin is layered onto the chain after all built-in
23
- * CLI plugins, so its functions appear in `getRegistry({ package: "cli" })`
24
- * automatically.
25
- */
26
- extensions?: Plugin<unknown, PluginProvides>[];
27
- }
28
- /**
29
- * Create a Zapier CLI SDK with experimental plugins registered. The
30
- * returned shape is a superset of the stable CLI SDK — same plugins
31
- * plus any marked experimental.
32
- */
33
- export declare function createZapierCliSdk(options?: ZapierCliSdkOptions): ZapierSdkCli;
@@ -1,86 +0,0 @@
1
- /**
2
- * Experimental CLI SDK factory.
3
- *
4
- * Mirror of `./sdk.ts`, but built on top of
5
- * `@zapier/zapier-sdk/experimental` so the underlying SDK has every
6
- * `meta.experimental: true` plugin registered. The CLI's runtime
7
- * entry point (`cli.ts`) chooses between this and the stable factory
8
- * based on three equivalent triggers detected before Commander parses:
9
- * the `zapier-sdk-experimental` bin name (via `argv[1]`), the
10
- * `--experimental` flag, or the `ZAPIER_EXPERIMENTAL=1` env var.
11
- *
12
- * Plugin chain matches `./sdk.ts` literally, with future CLI-only
13
- * experimental plugins inserted at appropriate positions. Both
14
- * factories are kept in sync by shape tests.
15
- */
16
- import * as cliLogin from "./login";
17
- import { addPlugin, createZapierSdkStack, injectCliLogin, } from "@zapier/zapier-sdk/experimental";
18
- import { loginPlugin, signupPlugin, logoutPlugin, mcpPlugin, bundleCodePlugin, getLoginConfigPathPlugin, addAppsPlugin, generateAppTypesPlugin, buildManifestPlugin, feedbackPlugin, curlPlugin, cliOverridesPlugin, initPlugin, drainTriggerInboxCliPlugin, watchTriggerInboxCliPlugin, } from "./plugins/index";
19
- import packageJson from "../package.json" with { type: "json" };
20
- injectCliLogin(cliLogin);
21
- /**
22
- * Create a Zapier CLI SDK with experimental plugins registered. The
23
- * returned shape is a superset of the stable CLI SDK — same plugins
24
- * plus any marked experimental.
25
- */
26
- export function createZapierCliSdk(options = {}) {
27
- const { extensions = [], ...sdkOptions } = options;
28
- // Stash the resolved extensions on context so `mcpPlugin` can forward
29
- // them to `startMcpServer`. Without this, MCP would build a vanilla SDK
30
- // with no extensions and the CLI/MCP surfaces would diverge.
31
- const extensionsContextPlugin = () => ({
32
- context: { extensions },
33
- });
34
- // Tell the MCP plugin the CLI is in experimental mode so `mcp`
35
- // launches a server built against `@zapier/zapier-sdk/experimental`.
36
- // Without this, `zapier-sdk-experimental mcp` would silently expose
37
- // only the stable surface — the README claim wouldn't match reality.
38
- const experimentalContextPlugin = () => ({
39
- context: { experimental: true },
40
- });
41
- const sdk = createZapierSdkStack({
42
- ...sdkOptions,
43
- eventEmission: { ...sdkOptions.eventEmission, callContext: "cli" },
44
- callerPackage: { name: packageJson.name, version: packageJson.version },
45
- })
46
- .use(extensionsContextPlugin)
47
- .use(experimentalContextPlugin)
48
- .use(generateAppTypesPlugin)
49
- .use(buildManifestPlugin)
50
- .use(bundleCodePlugin)
51
- .use(getLoginConfigPathPlugin)
52
- .use(addAppsPlugin)
53
- .use(feedbackPlugin)
54
- .use(curlPlugin)
55
- .use(initPlugin)
56
- // Trigger inbox commands: the SDK's `drainTriggerInbox` and
57
- // `watchTriggerInbox` are eager, callback-driven methods. Both CLI
58
- // plugins override them to layer presentation flags (`--json`,
59
- // interactive prompt, `--exec-shell` wrapping) around the same
60
- // `onMessage` callback. `override: true` is the documented opt-in
61
- // for intentional same-name replacement.
62
- .use(drainTriggerInboxCliPlugin, { override: true })
63
- .use(watchTriggerInboxCliPlugin, { override: true })
64
- .use(mcpPlugin)
65
- .use(loginPlugin)
66
- .use(signupPlugin)
67
- .use(logoutPlugin)
68
- // cliOverridesPlugin patches existing meta entries (e.g. flags `fetch`
69
- // as deprecated) without re-registering the method. `.use` throws on
70
- // meta-key collisions by default, so the intent has to be explicit.
71
- .use(cliOverridesPlugin, { override: true })
72
- .toSdk();
73
- // Construct extensions defensively. See `./sdk.ts` for the rationale;
74
- // `addPlugin` mutates the sdk in place, atomically (validate-then-
75
- // apply), so a failed extension leaves the sdk in its prior state
76
- // and skipping is safe.
77
- for (const ext of extensions) {
78
- try {
79
- addPlugin(sdk, ext);
80
- }
81
- catch (err) {
82
- console.warn(`Extension plugin failed to construct: ${err.message}; skipping.`);
83
- }
84
- }
85
- return sdk;
86
- }
@@ -1,41 +0,0 @@
1
- import type { ListActionsPluginProvides, ListActionInputFieldsPluginProvides, ManifestPluginProvides, AppItem } from "@zapier/zapier-sdk";
2
- interface GenerateTypesOptions {
3
- app: AppItem;
4
- connectionId?: string | number;
5
- }
6
- /**
7
- * AST-based TypeScript type generator using the TypeScript Compiler API
8
- */
9
- export declare class AstTypeGenerator {
10
- private readonly factory;
11
- private readonly printer;
12
- /**
13
- * Generate TypeScript types using AST for a specific app
14
- */
15
- generateTypes(options: GenerateTypesOptions & {
16
- sdk: ListActionsPluginProvides & ListActionInputFieldsPluginProvides & ManifestPluginProvides;
17
- }): Promise<string>;
18
- private createSourceFile;
19
- private createImportStatement;
20
- private createTypeImportStatement;
21
- private groupActionsByType;
22
- private createInputInterface;
23
- private createActionInterface;
24
- private createAppProxyInterface;
25
- private createFetchMethodProperty;
26
- private createAppFactoryInterface;
27
- private createAppWithFactoryType;
28
- private createModuleAugmentation;
29
- private mapFieldTypeToTypeNode;
30
- private capitalize;
31
- private sanitizeActionName;
32
- private sanitizeFieldName;
33
- private escapeComment;
34
- private createPropertyName;
35
- private isValidIdentifier;
36
- private getPreferredProgrammaticKey;
37
- private getPreferredAppName;
38
- private sanitizeToIdentifier;
39
- private getAllKeys;
40
- }
41
- export {};