@zapier/zapier-sdk 0.49.0 → 0.50.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,20 @@
1
1
  # @zapier/zapier-sdk
2
2
 
3
+ ## 0.50.0
4
+
5
+ ### Minor Changes
6
+
7
+ - cd8f37b: Collapse the approval-flow surface into a single tri-state `approvalMode` option.
8
+
9
+ What changed:
10
+ - `approvalMode` is now `"disabled" | "poll" | "throw"` (was `"poll" | "fail"`).
11
+ - `"disabled"` is the default. While the approval flow is alpha, callers must opt in explicitly via `approvalMode: "poll"` or `approvalMode: "throw"` (or the `ZAPIER_APPROVAL_MODE` env var). On an approval-required response, `"disabled"` throws a `ZapierApprovalError` with `status: "approval_required"` without creating an approval.
12
+ - The `isInteractive` SDK option and the `ZAPIER_IS_INTERACTIVE` env var have been removed. Their role is subsumed by `approvalMode`: choosing `"poll"` / `"throw"` is the explicit opt-in that previously required `isInteractive: true`.
13
+ - `"fail"` has been renamed to `"throw"` (both the option value and the `ZAPIER_APPROVAL_MODE` env var value). The behavior is unchanged: throw a `ZapierApprovalError` carrying the approval URL so the caller can surface it.
14
+ - `approvalMode`, `approvalTimeoutMs`, and `maxApprovalRetries` are now part of the public API (no longer marked `internal: true`).
15
+
16
+ There is no back-compat shim. `approvalMode: "fail"` and `isInteractive: <anything>` will fail Zod validation up front.
17
+
3
18
  ## 0.49.0
4
19
 
5
20
  ### Minor Changes
package/README.md CHANGED
@@ -329,17 +329,20 @@ console.log(emojiData.emoji);
329
329
 
330
330
  The `createZapierSdk(...)` factory function is the main entry point for the SDK. It provides methods for managing connections, listing apps, running actions, and more.
331
331
 
332
- | Name | Type | Required | Default | Possible Values | Description |
333
- | ----------------------------- | -------------------------- | -------- | ------- | --------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
334
- | `credentials` | `string, object, function` | ❌ | — | — | Authentication credentials. Can be a string (token or API key), a client credentials object ({ clientId, clientSecret }), a PKCE object ({ clientId }), or a function returning any of those. |
335
- | `debug` | `boolean` | ❌ | — | — | Enable debug logging. |
336
- | `baseUrl` | `string` | ❌ | — | — | Base URL for Zapier API endpoints. |
337
- | `trackingBaseUrl` | `string` | ❌ | — | — | Base URL for Zapier tracking endpoints. |
338
- | `maxNetworkRetries` | `number` | ❌ | — | — | Max retries for rate-limited requests (default: 3). |
339
- | `maxNetworkRetryDelayMs` | `number` | ❌ | — | — | Max delay in ms to wait for retry (default: 60000). |
340
- | `canIncludeSharedConnections` | `boolean` | ❌ | — | — | Allow listing shared connections. |
341
- | `canIncludeSharedTables` | `boolean` | ❌ | — | — | Allow listing shared tables. |
342
- | `canDeleteTables` | `boolean` | ❌ | — | | Allow deleting tables. |
332
+ | Name | Type | Required | Default | Possible Values | Description |
333
+ | ----------------------------- | -------------------------- | -------- | ------- | --------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
334
+ | `credentials` | `string, object, function` | ❌ | — | — | Authentication credentials. Can be a string (token or API key), a client credentials object ({ clientId, clientSecret }), a PKCE object ({ clientId }), or a function returning any of those. |
335
+ | `debug` | `boolean` | ❌ | — | — | Enable debug logging. |
336
+ | `baseUrl` | `string` | ❌ | — | — | Base URL for Zapier API endpoints. |
337
+ | `trackingBaseUrl` | `string` | ❌ | — | — | Base URL for Zapier tracking endpoints. |
338
+ | `maxNetworkRetries` | `number` | ❌ | — | — | Max retries for rate-limited requests (default: 3). |
339
+ | `maxNetworkRetryDelayMs` | `number` | ❌ | — | — | Max delay in ms to wait for retry (default: 60000). |
340
+ | `approvalTimeoutMs` | `number` | ❌ | — | — | Timeout in ms for approval polling. Default: 600000 (10 min). |
341
+ | `maxApprovalRetries` | `number` | ❌ | — | — | Maximum number of sequential approval rounds per request (one per gating policy) before giving up. Default: 2. |
342
+ | `approvalMode` | `string` | ❌ | — | `disabled`, `poll`, `throw` | Approval flow behavior. "disabled" (default) throws a ZapierApprovalError on approval-required responses without creating an approval. "poll" creates the approval, opens it in a browser, polls until resolved, and retries the original request. "throw" creates the approval and throws a ZapierApprovalError with the approval URL so the caller can surface it. Defaults to the ZAPIER_APPROVAL_MODE env var, then "disabled". |
343
+ | `canIncludeSharedConnections` | `boolean` | ❌ | — | — | Allow listing shared connections. |
344
+ | `canIncludeSharedTables` | `boolean` | ❌ | — | — | Allow listing shared tables. |
345
+ | `canDeleteTables` | `boolean` | ❌ | — | — | Allow deleting tables. |
343
346
 
344
347
  ## Named Connections
345
348
 
@@ -1 +1 @@
1
- {"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../src/api/client.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EACV,SAAS,EACT,gBAAgB,EAGjB,MAAM,SAAS,CAAC;AAyjCjB,eAAO,MAAM,eAAe,GAAI,SAAS,gBAAgB,KAAG,SAW3D,CAAC"}
1
+ {"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../src/api/client.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EACV,SAAS,EACT,gBAAgB,EAGjB,MAAM,SAAS,CAAC;AA2jCjB,eAAO,MAAM,eAAe,GAAI,SAAS,gBAAgB,KAAG,SAW3D,CAAC"}
@@ -12,7 +12,7 @@ import { getZapierBaseUrl, isLocalhostBaseUrl } from "../utils/url-utils";
12
12
  import { sleep, calculateExponentialBackoffMs } from "../utils/retry-utils";
13
13
  import { isPlainObject } from "../utils/type-guard-utils";
14
14
  import { ZapierApiError, ZapierApprovalError, ZapierAuthenticationError, ZapierTimeoutError, ZapierValidationError, ZapierResourceNotFoundError, ZapierRateLimitError, } from "../types/errors";
15
- import { ZAPIER_MAX_NETWORK_RETRIES, ZAPIER_MAX_NETWORK_RETRY_DELAY_MS, getZapierIsInteractive, getZapierApprovalMode, getZapierSdkService, DEFAULT_APPROVAL_TIMEOUT_MS, DEFAULT_MAX_APPROVAL_RETRIES, } from "../constants";
15
+ import { ZAPIER_MAX_NETWORK_RETRIES, ZAPIER_MAX_NETWORK_RETRY_DELAY_MS, getZapierApprovalMode, getZapierSdkService, DEFAULT_APPROVAL_TIMEOUT_MS, DEFAULT_MAX_APPROVAL_RETRIES, } from "../constants";
16
16
  import { SDK_VERSION } from "../sdk-version";
17
17
  import { openApproval } from "../utils/open-approval";
18
18
  import { z } from "zod";
@@ -249,13 +249,13 @@ class ZapierApiClient {
249
249
  // and throw `max_retries_exceeded` below.
250
250
  if (attempt === maxRetries)
251
251
  break;
252
- // Approval requires opening a URL in a browser. If the caller's session
253
- // can't do that (CI, server, headless container), surface a distinct
254
- // status so callers can branch on "retry interactively or use
255
- // approvalMode: 'fail'" vs. a real policy denial.
256
- const isInteractive = this.options.isInteractive ?? getZapierIsInteractive();
257
- if (!isInteractive) {
258
- throw new ZapierApprovalError("Approval required but session is not interactive", { status: "approval_required" });
252
+ // Resolve the mode: explicit option > env var > "disabled" (conservative
253
+ // default while the approval flow is alpha + opt-in). When disabled,
254
+ // surface a distinct status so callers can branch on "enable approvals
255
+ // explicitly" vs. a real policy denial.
256
+ const mode = this.options.approvalMode ?? getZapierApprovalMode() ?? "disabled";
257
+ if (mode === "disabled") {
258
+ throw new ZapierApprovalError("Approvals are disabled. Set approvalMode to 'poll' or 'throw' (or ZAPIER_APPROVAL_MODE) to enable.", { status: "approval_required" });
259
259
  }
260
260
  // `approvalContext` is a builder, not a value, because the SDK may
261
261
  // retry the same request across multiple approval rounds and each POST
@@ -266,10 +266,10 @@ class ZapierApiClient {
266
266
  throw new ZapierApiError(`Received 403 approval_required for ${path}, but the caller did not provide an approvalContext builder. Every approval-capable request must pass approvalContext so the SDK can create the approval with the correct policy context.`, { statusCode: 403 });
267
267
  }
268
268
  // Create the approval, open the URL (poll mode) or throw with the URL
269
- // attached (fail mode), and wait for terminal resolution. Returns only
269
+ // attached (throw mode), and wait for terminal resolution. Returns only
270
270
  // on "approved" — every other outcome throws from inside the helper.
271
271
  // On return, loop back to retry the original request.
272
- await this.runOneApprovalRound(init.approvalContext);
272
+ await this.runOneApprovalRound(init.approvalContext, mode);
273
273
  }
274
274
  // Only reachable when the final attempt returned `approval_required`
275
275
  // (see the `break` above). Every other terminal outcome throws inline.
@@ -651,10 +651,13 @@ class ZapierApiClient {
651
651
  }
652
652
  /**
653
653
  * Run a single approval round: create the approval, open the URL (poll mode)
654
- * or throw (fail mode), poll until resolved, and emit events. Throws on
654
+ * or throw (throw mode), poll until resolved, and emit events. Throws on
655
655
  * denied/timeout/unexpected status. Returns on approved.
656
+ *
657
+ * Caller is responsible for passing a non-"disabled" mode; this method
658
+ * unconditionally creates an approval.
656
659
  */
657
- async runOneApprovalRound(buildContext) {
660
+ async runOneApprovalRound(buildContext, mode) {
658
661
  const context = buildContext();
659
662
  // Route through rawFetch so the approval POST shares auth + 429 retry.
660
663
  let approvalResponse;
@@ -733,8 +736,7 @@ class ZapierApiClient {
733
736
  approvalId: approval.approval_id,
734
737
  approvalUrl: approval.approval_url,
735
738
  });
736
- const approvalMode = this.options.approvalMode ?? getZapierApprovalMode();
737
- if (approvalMode === "fail") {
739
+ if (mode === "throw") {
738
740
  throw new ZapierApprovalError("This request requires approval.", {
739
741
  approvalId: approval.approval_id,
740
742
  approvalUrl: approval.approval_url,
@@ -742,7 +744,7 @@ class ZapierApiClient {
742
744
  status: "pending",
743
745
  });
744
746
  }
745
- // approvalMode: "poll" (default) — open browser and poll
747
+ // mode === "poll" — open browser and poll
746
748
  await openApproval(approval.approval_url);
747
749
  const timeoutMs = this.options.approvalTimeoutMs ?? DEFAULT_APPROVAL_TIMEOUT_MS;
748
750
  let rawPollResult;
@@ -40,16 +40,17 @@ export interface ApiClientOptions {
40
40
  * Default is 60000 (60 seconds).
41
41
  */
42
42
  maxNetworkRetryDelayMs?: number;
43
- /**
44
- * Whether this session is interactive (user can visit approval URLs).
45
- */
46
- isInteractive?: boolean;
47
43
  /**
48
44
  * Controls how the approval flow is handled.
49
- * - "poll": (default) Opens the approval URL in a browser and polls until resolved.
50
- * - "fail": Creates the approval and throws a ZapierApprovalError immediately with the approval URL.
45
+ * - "disabled": (default when env var is unset) Throw a ZapierApprovalError
46
+ * on approval-required responses without creating an approval.
47
+ * - "poll": Create the approval, open the URL in a browser, poll until
48
+ * resolved, and retry the original request on success.
49
+ * - "throw": Create the approval and throw a ZapierApprovalError immediately
50
+ * with the approval URL so the caller can surface it.
51
+ * Defaults to the ZAPIER_APPROVAL_MODE env var, then "disabled".
51
52
  */
52
- approvalMode?: "poll" | "fail";
53
+ approvalMode?: "disabled" | "poll" | "throw";
53
54
  /**
54
55
  * Timeout in ms for approval polling. Default: 600000 (10 minutes).
55
56
  */
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/api/types.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AACH,OAAO,KAAK,EACV,gBAAgB,EAChB,yBAAyB,EAC1B,MAAM,gDAAgD,CAAC;AACxD,OAAO,KAAK,EACV,wBAAwB,EACxB,iCAAiC,EAClC,MAAM,oDAAoD,CAAC;AAC5D,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AACxD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AAC7D,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AAC5C,OAAO,KAAK,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAC7B,OAAO,KAAK,EACV,iBAAiB,EACjB,UAAU,EACV,iBAAiB,EACjB,uBAAuB,EACvB,YAAY,EACZ,YAAY,EACZ,WAAW,EACX,2BAA2B,EAC3B,uBAAuB,EACvB,iBAAiB,EACjB,iBAAiB,EACjB,SAAS,EACT,kBAAkB,EAClB,mBAAmB,EACnB,oBAAoB,EACpB,6BAA6B,EAC7B,aAAa,EACb,sBA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F,MAAM,MAAM,kBAAkB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,wBAAwB,CAAC,CAAC;AAC1E,MAAM,MAAM,mBAAmB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,yBAAyB,CAAC,CAAC;AAC5E,MAAM,MAAM,uBAAuB,GAAG,CAAC,CAAC,KAAK,CAC3C,OAAO,6BAA6B,CACrC,CAAC;AACF,MAAM,MAAM,wBAAwB,GAAG,CAAC,CAAC,KAAK,CAC5C,OAAO,8BAA8B,CACtC,CAAC"}
@@ -30,20 +30,19 @@ export declare const DEFAULT_ACTION_TIMEOUT_MS = 180000;
30
30
  */
31
31
  export declare const ZAPIER_MAX_NETWORK_RETRIES: number;
32
32
  export declare const ZAPIER_MAX_NETWORK_RETRY_DELAY_MS: number;
33
- /**
34
- * Whether this session is interactive (user can visit approval URLs).
35
- *
36
- * Read lazily so tests can set the env var after module import.
37
- */
38
- export declare function getZapierIsInteractive(): boolean;
39
33
  /**
40
34
  * Approval flow behavior from environment variable.
41
- * - "poll": (default) Opens the approval URL in a browser and polls until resolved.
42
- * - "fail": Creates the approval and throws immediately with the approval URL.
35
+ * - "disabled": (default when env var is unset) Throw a ZapierApprovalError on
36
+ * approval-required responses without creating an approval. Callers must
37
+ * explicitly opt in to approvals via "poll" or "throw".
38
+ * - "poll": Create the approval, open the URL in a browser, poll until
39
+ * resolved, and retry the original request on success.
40
+ * - "throw": Create the approval and throw a ZapierApprovalError immediately
41
+ * with the approval URL so the caller can surface it.
43
42
  *
44
43
  * Read lazily so tests can set the env var after module import.
45
44
  */
46
- export declare function getZapierApprovalMode(): "poll" | "fail" | undefined;
45
+ export declare function getZapierApprovalMode(): "disabled" | "poll" | "throw" | undefined;
47
46
  /**
48
47
  * Default timeout for approval polling (10 minutes)
49
48
  */
@@ -1 +1 @@
1
- {"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH;;GAEG;AACH,eAAO,MAAM,eAAe,QACsC,CAAC;AAEnE;;;;GAIG;AACH,wBAAgB,mBAAmB,IAAI,MAAM,GAAG,SAAS,CAExD;AAED;;GAEG;AACH,eAAO,MAAM,cAAc,QAAQ,CAAC;AAEpC;;GAEG;AACH,eAAO,MAAM,iBAAiB,MAAM,CAAC;AAErC;;GAEG;AACH,eAAO,MAAM,yBAAyB,SAAU,CAAC;AAejD;;GAEG;AACH,eAAO,MAAM,0BAA0B,QACY,CAAC;AACpD,eAAO,MAAM,iCAAiC,QACiB,CAAC;AAEhE;;;;GAIG;AACH,wBAAgB,sBAAsB,IAAI,OAAO,CAEhD;AAED;;;;;;GAMG;AACH,wBAAgB,qBAAqB,IAAI,MAAM,GAAG,MAAM,GAAG,SAAS,CAInE;AAED;;GAEG;AACH,eAAO,MAAM,2BAA2B,QAAiB,CAAC;AAE1D;;;;;GAKG;AACH,eAAO,MAAM,4BAA4B,IAAI,CAAC"}
1
+ {"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH;;GAEG;AACH,eAAO,MAAM,eAAe,QACsC,CAAC;AAEnE;;;;GAIG;AACH,wBAAgB,mBAAmB,IAAI,MAAM,GAAG,SAAS,CAExD;AAED;;GAEG;AACH,eAAO,MAAM,cAAc,QAAQ,CAAC;AAEpC;;GAEG;AACH,eAAO,MAAM,iBAAiB,MAAM,CAAC;AAErC;;GAEG;AACH,eAAO,MAAM,yBAAyB,SAAU,CAAC;AAejD;;GAEG;AACH,eAAO,MAAM,0BAA0B,QACY,CAAC;AACpD,eAAO,MAAM,iCAAiC,QACiB,CAAC;AAEhE;;;;;;;;;;;GAWG;AACH,wBAAgB,qBAAqB,IACjC,UAAU,GACV,MAAM,GACN,OAAO,GACP,SAAS,CAKZ;AAED;;GAEG;AACH,eAAO,MAAM,2BAA2B,QAAiB,CAAC;AAE1D;;;;;GAKG;AACH,eAAO,MAAM,4BAA4B,IAAI,CAAC"}
package/dist/constants.js CHANGED
@@ -43,24 +43,21 @@ function parseIntEnvVar(name) {
43
43
  */
44
44
  export const ZAPIER_MAX_NETWORK_RETRIES = parseIntEnvVar("ZAPIER_MAX_NETWORK_RETRIES") ?? 3;
45
45
  export const ZAPIER_MAX_NETWORK_RETRY_DELAY_MS = parseIntEnvVar("ZAPIER_MAX_NETWORK_RETRY_DELAY_MS") ?? 60000;
46
- /**
47
- * Whether this session is interactive (user can visit approval URLs).
48
- *
49
- * Read lazily so tests can set the env var after module import.
50
- */
51
- export function getZapierIsInteractive() {
52
- return globalThis.process?.env?.ZAPIER_IS_INTERACTIVE === "true";
53
- }
54
46
  /**
55
47
  * Approval flow behavior from environment variable.
56
- * - "poll": (default) Opens the approval URL in a browser and polls until resolved.
57
- * - "fail": Creates the approval and throws immediately with the approval URL.
48
+ * - "disabled": (default when env var is unset) Throw a ZapierApprovalError on
49
+ * approval-required responses without creating an approval. Callers must
50
+ * explicitly opt in to approvals via "poll" or "throw".
51
+ * - "poll": Create the approval, open the URL in a browser, poll until
52
+ * resolved, and retry the original request on success.
53
+ * - "throw": Create the approval and throw a ZapierApprovalError immediately
54
+ * with the approval URL so the caller can surface it.
58
55
  *
59
56
  * Read lazily so tests can set the env var after module import.
60
57
  */
61
58
  export function getZapierApprovalMode() {
62
59
  const value = globalThis.process?.env?.ZAPIER_APPROVAL_MODE;
63
- if (value === "poll" || value === "fail")
60
+ if (value === "disabled" || value === "poll" || value === "throw")
64
61
  return value;
65
62
  return undefined;
66
63
  }
@@ -150,12 +150,10 @@ function parseIntEnvVar(name) {
150
150
  }
151
151
  var ZAPIER_MAX_NETWORK_RETRIES = parseIntEnvVar("ZAPIER_MAX_NETWORK_RETRIES") ?? 3;
152
152
  var ZAPIER_MAX_NETWORK_RETRY_DELAY_MS = parseIntEnvVar("ZAPIER_MAX_NETWORK_RETRY_DELAY_MS") ?? 6e4;
153
- function getZapierIsInteractive() {
154
- return globalThis.process?.env?.ZAPIER_IS_INTERACTIVE === "true";
155
- }
156
153
  function getZapierApprovalMode() {
157
154
  const value = globalThis.process?.env?.ZAPIER_APPROVAL_MODE;
158
- if (value === "poll" || value === "fail") return value;
155
+ if (value === "disabled" || value === "poll" || value === "throw")
156
+ return value;
159
157
  return void 0;
160
158
  }
161
159
  var DEFAULT_APPROVAL_TIMEOUT_MS = 10 * 60 * 1e3;
@@ -2661,7 +2659,7 @@ async function invalidateCredentialsToken(options) {
2661
2659
  }
2662
2660
 
2663
2661
  // src/sdk-version.ts
2664
- var SDK_VERSION = (typeof process !== "undefined" && process.env ? "0.49.0" : void 0) || "unknown";
2662
+ var SDK_VERSION = (typeof process !== "undefined" && process.env ? "0.50.0" : void 0) || "unknown";
2665
2663
 
2666
2664
  // src/utils/open-url.ts
2667
2665
  var nodePrefix = "node:";
@@ -2936,10 +2934,10 @@ var ZapierApiClient = class {
2936
2934
  }
2937
2935
  if (errorType !== "approval_required") return response;
2938
2936
  if (attempt === maxRetries) break;
2939
- const isInteractive = this.options.isInteractive ?? getZapierIsInteractive();
2940
- if (!isInteractive) {
2937
+ const mode = this.options.approvalMode ?? getZapierApprovalMode() ?? "disabled";
2938
+ if (mode === "disabled") {
2941
2939
  throw new ZapierApprovalError(
2942
- "Approval required but session is not interactive",
2940
+ "Approvals are disabled. Set approvalMode to 'poll' or 'throw' (or ZAPIER_APPROVAL_MODE) to enable.",
2943
2941
  { status: "approval_required" }
2944
2942
  );
2945
2943
  }
@@ -2949,7 +2947,7 @@ var ZapierApiClient = class {
2949
2947
  { statusCode: 403 }
2950
2948
  );
2951
2949
  }
2952
- await this.runOneApprovalRound(init.approvalContext);
2950
+ await this.runOneApprovalRound(init.approvalContext, mode);
2953
2951
  }
2954
2952
  throw new ZapierApprovalError(
2955
2953
  `Exceeded maximum approval retries (${maxRetries}) for ${path}`,
@@ -3268,10 +3266,13 @@ var ZapierApiClient = class {
3268
3266
  }
3269
3267
  /**
3270
3268
  * Run a single approval round: create the approval, open the URL (poll mode)
3271
- * or throw (fail mode), poll until resolved, and emit events. Throws on
3269
+ * or throw (throw mode), poll until resolved, and emit events. Throws on
3272
3270
  * denied/timeout/unexpected status. Returns on approved.
3271
+ *
3272
+ * Caller is responsible for passing a non-"disabled" mode; this method
3273
+ * unconditionally creates an approval.
3273
3274
  */
3274
- async runOneApprovalRound(buildContext) {
3275
+ async runOneApprovalRound(buildContext, mode) {
3275
3276
  const context = buildContext();
3276
3277
  let approvalResponse;
3277
3278
  try {
@@ -3346,8 +3347,7 @@ var ZapierApiClient = class {
3346
3347
  approvalId: approval.approval_id,
3347
3348
  approvalUrl: approval.approval_url
3348
3349
  });
3349
- const approvalMode = this.options.approvalMode ?? getZapierApprovalMode();
3350
- if (approvalMode === "fail") {
3350
+ if (mode === "throw") {
3351
3351
  throw new ZapierApprovalError("This request requires approval.", {
3352
3352
  approvalId: approval.approval_id,
3353
3353
  approvalUrl: approval.approval_url,
@@ -3446,7 +3446,6 @@ var apiPlugin = definePlugin(
3446
3446
  debug = false,
3447
3447
  maxNetworkRetries = ZAPIER_MAX_NETWORK_RETRIES,
3448
3448
  maxNetworkRetryDelayMs = ZAPIER_MAX_NETWORK_RETRY_DELAY_MS,
3449
- isInteractive,
3450
3449
  approvalTimeoutMs,
3451
3450
  maxApprovalRetries,
3452
3451
  approvalMode,
@@ -3461,7 +3460,6 @@ var apiPlugin = definePlugin(
3461
3460
  onEvent,
3462
3461
  maxNetworkRetries,
3463
3462
  maxNetworkRetryDelayMs,
3464
- isInteractive,
3465
3463
  approvalTimeoutMs,
3466
3464
  maxApprovalRetries,
3467
3465
  approvalMode,
@@ -10167,16 +10165,13 @@ var BaseSdkOptionsSchema = zod.z.object({
10167
10165
  * Default is 60000 (60 seconds).
10168
10166
  */
10169
10167
  maxNetworkRetryDelayMs: zod.z.number().optional().describe("Max delay in ms to wait for retry (default: 60000).").meta({ valueHint: "ms" }),
10170
- isInteractive: zod.z.boolean().optional().describe(
10171
- "Whether this session is interactive (user can visit approval URLs). Defaults to ZAPIER_IS_INTERACTIVE env var."
10172
- ).meta({ internal: true }),
10173
- approvalTimeoutMs: zod.z.number().optional().describe("Timeout in ms for approval polling. Default: 600000 (10 min).").meta({ valueHint: "ms", internal: true }),
10168
+ approvalTimeoutMs: zod.z.number().optional().describe("Timeout in ms for approval polling. Default: 600000 (10 min).").meta({ valueHint: "ms" }),
10174
10169
  maxApprovalRetries: zod.z.number().optional().describe(
10175
10170
  "Maximum number of sequential approval rounds per request (one per gating policy) before giving up. Default: 2."
10176
- ).meta({ internal: true }),
10177
- approvalMode: zod.z.enum(["poll", "fail"]).optional().describe(
10178
- 'Approval flow behavior. "poll" opens browser and polls (default). "fail" creates the approval and throws immediately with the approval URL.'
10179
- ).meta({ internal: true }),
10171
+ ),
10172
+ approvalMode: zod.z.enum(["disabled", "poll", "throw"]).optional().describe(
10173
+ 'Approval flow behavior. "disabled" (default) throws a ZapierApprovalError on approval-required responses without creating an approval. "poll" creates the approval, opens it in a browser, polls until resolved, and retries the original request. "throw" creates the approval and throws a ZapierApprovalError with the approval URL so the caller can surface it. Defaults to the ZAPIER_APPROVAL_MODE env var, then "disabled".'
10174
+ ),
10180
10175
  // Internal
10181
10176
  manifestPath: zod.z.string().optional().describe("Path to a .zapierrc manifest file for app version locking.").meta({ internal: true }),
10182
10177
  manifest: zod.z.custom().optional().describe("Manifest for app version locking.").meta({ internal: true }),
@@ -10338,7 +10333,6 @@ exports.getTablePlugin = getTablePlugin;
10338
10333
  exports.getTableRecordPlugin = getTableRecordPlugin;
10339
10334
  exports.getTokenFromCliLogin = getTokenFromCliLogin;
10340
10335
  exports.getZapierApprovalMode = getZapierApprovalMode;
10341
- exports.getZapierIsInteractive = getZapierIsInteractive;
10342
10336
  exports.getZapierSdkService = getZapierSdkService;
10343
10337
  exports.injectCliLogin = injectCliLogin;
10344
10338
  exports.inputFieldKeyResolver = inputFieldKeyResolver;
@@ -1,5 +1,5 @@
1
- import { B as BaseSdkOptions, W as WithAddPlugin, P as PluginMeta, Z as ZapierSdkOptions$1, E as EventEmissionContext, A as ApiClient, M as Manifest, R as ResolvedAppLocator, U as UpdateManifestEntryOptions, a as UpdateManifestEntryResult, b as AddActionEntryOptions, c as AddActionEntryResult, d as ActionEntry, f as findManifestEntry, r as readManifestFromFile, C as CapabilitiesContext, e as PaginatedSdkResult, F as FieldsetItem, g as PositionalMetadata, h as ZapierFetchInitOptions, D as DrainTriggerInboxOptions, i as DynamicResolver, j as WatchTriggerInboxOptions, k as ActionProxy, l as ZapierSdkApps } from './index-C2vsvjgN.mjs';
2
- export { u as Action, ce as ActionExecutionOptions, y as ActionExecutionResult, z as ActionField, H as ActionFieldChoice, aS as ActionItem, bt as ActionKeyProperty, b1 as ActionKeyPropertySchema, bu as ActionProperty, b2 as ActionPropertySchema, aq as ActionResolverItem, bF as ActionTimeoutMsProperty, bd as ActionTimeoutMsPropertySchema, ar as ActionTypeItem, bs as ActionTypeProperty, b0 as ActionTypePropertySchema, bS as ApiError, dz as ApiEvent, cY as ApiPluginOptions, c_ as ApiPluginProvides, v as App, cf as AppFactoryInput, aQ as AppItem, bq as AppKeyProperty, a_ as AppKeyPropertySchema, br as AppProperty, a$ as AppPropertySchema, az as ApplicationLifecycleEventData, c7 as ApprovalStatus, cd as AppsPluginProvides, bK as AppsProperty, bi as AppsPropertySchema, a0 as ArrayResolver, dy as AuthEvent, by as AuthenticationIdProperty, b5 as AuthenticationIdPropertySchema, av as BaseEvent, aj as BaseSdkOptionsSchema, a8 as BatchOptions, cL as CONTEXT_CACHE_MAX_SIZE, cK as CONTEXT_CACHE_TTL_MS, x as Choice, dF as ClientCredentialsObject, dQ as ClientCredentialsObjectSchema, K as Connection, dY as ConnectionEntry, dX as ConnectionEntrySchema, bw as ConnectionIdProperty, b4 as ConnectionIdPropertySchema, aR as ConnectionItem, bx as ConnectionProperty, b6 as ConnectionPropertySchema, d_ as ConnectionsMap, dZ as ConnectionsMapSchema, e0 as ConnectionsPluginProvides, bM as ConnectionsProperty, bk as ConnectionsPropertySchema, O as ConnectionsResponse, cx as CreateClientCredentialsPluginProvides, en as CreateTableFieldsPluginProvides, eh as CreateTablePluginProvides, ev as CreateTableRecordsPluginProvides, dC as Credentials, dV as CredentialsFunction, dU as CredentialsFunctionSchema, dE as CredentialsObject, dS as CredentialsObjectSchema, dW as CredentialsSchema, e5 as DEFAULT_ACTION_TIMEOUT_MS, ea as DEFAULT_APPROVAL_TIMEOUT_MS, cU as DEFAULT_CONFIG_PATH, eb as DEFAULT_MAX_APPROVAL_RETRIES, e4 as DEFAULT_PAGE_SIZE, bD as DebugProperty, bb as DebugPropertySchema, cz as DeleteClientCredentialsPluginProvides, ep as DeleteTableFieldsPluginProvides, ej as DeleteTablePluginProvides, ex as DeleteTableRecordsPluginProvides, o as DrainTriggerInboxCallback, p as DrainTriggerInboxErrorObserver, aA as EnhancedErrorEventData, bT as ErrorOptions, dB as EventCallback, ay as EventContext, ax as EventEmissionProvides, ch as FetchPluginProvides, w as Field, bJ as FieldsProperty, bh as FieldsPropertySchema, a3 as FieldsResolver, s as FindFirstAuthenticationPluginProvides, cH as FindFirstConnectionPluginProvides, t as FindUniqueAuthenticationPluginProvides, cJ as FindUniqueConnectionPluginProvides, Y as FormatMetadata, X as FormattedItem, ai as FunctionDeprecation, aX as FunctionOptions, ah as FunctionRegistryEntry, cr as GetActionInputFieldsSchemaPluginProvides, cD as GetActionPluginProvides, cB as GetAppPluginProvides, G as GetAuthenticationPluginProvides, cF as GetConnectionPluginProvides, cX as GetProfilePluginProvides, ef as GetTablePluginProvides, er as GetTableRecordPluginProvides, aU as InfoFieldItem, aT as InputFieldItem, bv as InputFieldProperty, b3 as InputFieldPropertySchema, bz as InputsProperty, b7 as InputsPropertySchema, bR as LeaseLimitProperty, bp as LeaseLimitPropertySchema, bP as LeaseProperty, bn as LeasePropertySchema, bQ as LeaseSecondsProperty, bo as LeaseSecondsPropertySchema, L as LeasedTriggerMessageItem, bA as LimitProperty, b8 as LimitPropertySchema, cp as ListActionInputFieldChoicesPluginProvides, cn as ListActionInputFieldsPluginProvides, cl as ListActionsPluginProvides, cj as ListAppsPluginProvides, q as ListAuthenticationsPluginProvides, cv as ListClientCredentialsPluginProvides, ct as ListConnectionsPluginProvides, el as ListTableFieldsPluginProvides, et as ListTableRecordsPluginProvides, ed as ListTablesPluginProvides, dA as LoadingEvent, e3 as MAX_PAGE_LIMIT, cV as ManifestEntry, cQ as ManifestPluginOptions, cT as ManifestPluginProvides, aw as MethodCalledEvent, aB as MethodCalledEventData, N as Need, I as NeedsRequest, J as NeedsResponse, bB as OffsetProperty, b9 as OffsetPropertySchema, _ as OutputFormatter, bC as OutputProperty, ba as OutputPropertySchema, aZ as PaginatedSdkFunction, bE as ParamsProperty, bc as ParamsPropertySchema, dG as PkceCredentialsObject, dR as PkceCredentialsObjectSchema, ak as Plugin, al as PluginProvides, at as PollOptions, c5 as RateLimitInfo, bH as RecordProperty, bf as RecordPropertySchema, bI as RecordsProperty, bg as RecordsPropertySchema, ad as RelayFetchSchema, ac as RelayRequestSchema, as as RequestOptions, cP as RequestPluginProvides, dk as ResolveAuthTokenOptions, dL as ResolveCredentialsOptions, dD as ResolvedCredentials, dT as ResolvedCredentialsSchema, $ as Resolver, a1 as ResolverMetadata, aV as RootFieldItem, cN as RunActionPluginProvides, dx as SdkEvent, aY as SdkPage, a2 as StaticResolver, bG as TableProperty, be as TablePropertySchema, bL as TablesProperty, bj as TablesPropertySchema, bO as TriggerInboxNameProperty, bm as TriggerInboxNamePropertySchema, bN as TriggerInboxProperty, bl as TriggerInboxPropertySchema, T as TriggerMessageStatus, ez as UpdateTableRecordsPluginProvides, Q as UserProfile, aW as UserProfileItem, e1 as ZAPIER_BASE_URL, e6 as ZAPIER_MAX_NETWORK_RETRIES, e7 as ZAPIER_MAX_NETWORK_RETRY_DELAY_MS, m as ZapierAbortDrainSignal, c3 as ZapierActionError, bV as ZapierApiError, bW as ZapierAppNotFoundError, c8 as ZapierApprovalError, bZ as ZapierAuthenticationError, c1 as ZapierBundleError, dt as ZapierCache, du as ZapierCacheEntry, dv as ZapierCacheSetOptions, c0 as ZapierConfigurationError, c4 as ZapierConflictError, bU as ZapierError, b_ as ZapierNotFoundError, c6 as ZapierRateLimitError, c9 as ZapierRelayError, n as ZapierReleaseTriggerMessageSignal, b$ as ZapierResourceNotFoundError, cb as ZapierSignal, c2 as ZapierTimeoutError, bY as ZapierUnknownError, bX as ZapierValidationError, d1 as actionKeyResolver, d0 as actionTypeResolver, cZ as apiPlugin, c$ as appKeyResolver, cc as appsPlugin, d3 as authenticationIdGenericResolver, d2 as authenticationIdResolver, a7 as batch, aL as buildApplicationLifecycleEvent, a9 as buildCapabilityMessage, aN as buildErrorEvent, aM as buildErrorEventWithContext, aP as buildMethodCalledEvent, dl as clearTokenCache, d7 as clientCredentialsNameResolver, d8 as clientIdResolver, ap as composePlugins, d3 as connectionIdGenericResolver, d2 as connectionIdResolver, d$ as connectionsPlugin, aO as createBaseEvent, cw as createClientCredentialsPlugin, V as createFunction, dw as createMemoryCache, ag as createOptionsPlugin, ao as createPaginatedPluginMethod, an as createPluginMethod, af as createSdk, em as createTableFieldsPlugin, eg as createTablePlugin, eu as createTableRecordsPlugin, ae as createZapierSdkWithoutRegistry, am as definePlugin, cy as deleteClientCredentialsPlugin, eo as deleteTableFieldsPlugin, ei as deleteTablePlugin, ew as deleteTableRecordsPlugin, cg as fetchPlugin, cG as findFirstConnectionPlugin, cI as findUniqueConnectionPlugin, ca as formatErrorMessage, aC as generateEventId, cq as getActionInputFieldsSchemaPlugin, cC as getActionPlugin, cA as getAppPlugin, dO as getBaseUrlFromCredentials, aI as getCiPlatform, dP as getClientIdFromCredentials, cE as getConnectionPlugin, aK as getCpuTime, aD as getCurrentTimestamp, aJ as getMemoryUsage, aF as getOsInfo, aG as getPlatformVersions, cR as getPreferredManifestEntryKey, cW as getProfilePlugin, aE as getReleaseId, ee as getTablePlugin, eq as getTableRecordPlugin, dq as getTokenFromCliLogin, e9 as getZapierApprovalMode, e8 as getZapierIsInteractive, e2 as getZapierSdkService, dn as injectCliLogin, d6 as inputFieldKeyResolver, d5 as inputsAllOptionalResolver, d4 as inputsResolver, dm as invalidateCachedToken, ds as invalidateCredentialsToken, aH as isCi, dp as isCliLoginAvailable, dH as isClientCredentials, dK as isCredentialsFunction, dJ as isCredentialsObject, dI as isPkceCredentials, S as isPositional, co as listActionInputFieldChoicesPlugin, cm as listActionInputFieldsPlugin, ck as listActionsPlugin, ci as listAppsPlugin, cu as listClientCredentialsPlugin, cs as listConnectionsPlugin, ek as listTableFieldsPlugin, es as listTableRecordsPlugin, ec as listTablesPlugin, aa as logDeprecation, cS as manifestPlugin, au as registryPlugin, cO as requestPlugin, ab as resetDeprecationWarnings, dr as resolveAuthToken, dN as resolveCredentials, dM as resolveCredentialsFromEnv, cM as runActionPlugin, a4 as runWithTelemetryContext, dd as tableFieldIdsResolver, df as tableFieldsResolver, di as tableFiltersResolver, d9 as tableIdResolver, de as tableNameResolver, db as tableRecordIdResolver, dc as tableRecordIdsResolver, dg as tableRecordsResolver, dj as tableSortResolver, dh as tableUpdateRecordsResolver, a5 as toSnakeCase, a6 as toTitleCase, da as triggerInboxResolver, ey as updateTableRecordsPlugin } from './index-C2vsvjgN.mjs';
1
+ import { B as BaseSdkOptions, W as WithAddPlugin, P as PluginMeta, Z as ZapierSdkOptions$1, E as EventEmissionContext, A as ApiClient, M as Manifest, R as ResolvedAppLocator, U as UpdateManifestEntryOptions, a as UpdateManifestEntryResult, b as AddActionEntryOptions, c as AddActionEntryResult, d as ActionEntry, f as findManifestEntry, r as readManifestFromFile, C as CapabilitiesContext, e as PaginatedSdkResult, F as FieldsetItem, g as PositionalMetadata, h as ZapierFetchInitOptions, D as DrainTriggerInboxOptions, i as DynamicResolver, j as WatchTriggerInboxOptions, k as ActionProxy, l as ZapierSdkApps } from './index-BQ2ii0Bs.mjs';
2
+ export { u as Action, ce as ActionExecutionOptions, y as ActionExecutionResult, z as ActionField, H as ActionFieldChoice, aS as ActionItem, bt as ActionKeyProperty, b1 as ActionKeyPropertySchema, bu as ActionProperty, b2 as ActionPropertySchema, aq as ActionResolverItem, bF as ActionTimeoutMsProperty, bd as ActionTimeoutMsPropertySchema, ar as ActionTypeItem, bs as ActionTypeProperty, b0 as ActionTypePropertySchema, bS as ApiError, dz as ApiEvent, cY as ApiPluginOptions, c_ as ApiPluginProvides, v as App, cf as AppFactoryInput, aQ as AppItem, bq as AppKeyProperty, a_ as AppKeyPropertySchema, br as AppProperty, a$ as AppPropertySchema, az as ApplicationLifecycleEventData, c7 as ApprovalStatus, cd as AppsPluginProvides, bK as AppsProperty, bi as AppsPropertySchema, a0 as ArrayResolver, dy as AuthEvent, by as AuthenticationIdProperty, b5 as AuthenticationIdPropertySchema, av as BaseEvent, aj as BaseSdkOptionsSchema, a8 as BatchOptions, cL as CONTEXT_CACHE_MAX_SIZE, cK as CONTEXT_CACHE_TTL_MS, x as Choice, dF as ClientCredentialsObject, dQ as ClientCredentialsObjectSchema, K as Connection, dY as ConnectionEntry, dX as ConnectionEntrySchema, bw as ConnectionIdProperty, b4 as ConnectionIdPropertySchema, aR as ConnectionItem, bx as ConnectionProperty, b6 as ConnectionPropertySchema, d_ as ConnectionsMap, dZ as ConnectionsMapSchema, e0 as ConnectionsPluginProvides, bM as ConnectionsProperty, bk as ConnectionsPropertySchema, O as ConnectionsResponse, cx as CreateClientCredentialsPluginProvides, em as CreateTableFieldsPluginProvides, eg as CreateTablePluginProvides, eu as CreateTableRecordsPluginProvides, dC as Credentials, dV as CredentialsFunction, dU as CredentialsFunctionSchema, dE as CredentialsObject, dS as CredentialsObjectSchema, dW as CredentialsSchema, e5 as DEFAULT_ACTION_TIMEOUT_MS, e9 as DEFAULT_APPROVAL_TIMEOUT_MS, cU as DEFAULT_CONFIG_PATH, ea as DEFAULT_MAX_APPROVAL_RETRIES, e4 as DEFAULT_PAGE_SIZE, bD as DebugProperty, bb as DebugPropertySchema, cz as DeleteClientCredentialsPluginProvides, eo as DeleteTableFieldsPluginProvides, ei as DeleteTablePluginProvides, ew as DeleteTableRecordsPluginProvides, o as DrainTriggerInboxCallback, p as DrainTriggerInboxErrorObserver, aA as EnhancedErrorEventData, bT as ErrorOptions, dB as EventCallback, ay as EventContext, ax as EventEmissionProvides, ch as FetchPluginProvides, w as Field, bJ as FieldsProperty, bh as FieldsPropertySchema, a3 as FieldsResolver, s as FindFirstAuthenticationPluginProvides, cH as FindFirstConnectionPluginProvides, t as FindUniqueAuthenticationPluginProvides, cJ as FindUniqueConnectionPluginProvides, Y as FormatMetadata, X as FormattedItem, ai as FunctionDeprecation, aX as FunctionOptions, ah as FunctionRegistryEntry, cr as GetActionInputFieldsSchemaPluginProvides, cD as GetActionPluginProvides, cB as GetAppPluginProvides, G as GetAuthenticationPluginProvides, cF as GetConnectionPluginProvides, cX as GetProfilePluginProvides, ee as GetTablePluginProvides, eq as GetTableRecordPluginProvides, aU as InfoFieldItem, aT as InputFieldItem, bv as InputFieldProperty, b3 as InputFieldPropertySchema, bz as InputsProperty, b7 as InputsPropertySchema, bR as LeaseLimitProperty, bp as LeaseLimitPropertySchema, bP as LeaseProperty, bn as LeasePropertySchema, bQ as LeaseSecondsProperty, bo as LeaseSecondsPropertySchema, L as LeasedTriggerMessageItem, bA as LimitProperty, b8 as LimitPropertySchema, cp as ListActionInputFieldChoicesPluginProvides, cn as ListActionInputFieldsPluginProvides, cl as ListActionsPluginProvides, cj as ListAppsPluginProvides, q as ListAuthenticationsPluginProvides, cv as ListClientCredentialsPluginProvides, ct as ListConnectionsPluginProvides, ek as ListTableFieldsPluginProvides, es as ListTableRecordsPluginProvides, ec as ListTablesPluginProvides, dA as LoadingEvent, e3 as MAX_PAGE_LIMIT, cV as ManifestEntry, cQ as ManifestPluginOptions, cT as ManifestPluginProvides, aw as MethodCalledEvent, aB as MethodCalledEventData, N as Need, I as NeedsRequest, J as NeedsResponse, bB as OffsetProperty, b9 as OffsetPropertySchema, _ as OutputFormatter, bC as OutputProperty, ba as OutputPropertySchema, aZ as PaginatedSdkFunction, bE as ParamsProperty, bc as ParamsPropertySchema, dG as PkceCredentialsObject, dR as PkceCredentialsObjectSchema, ak as Plugin, al as PluginProvides, at as PollOptions, c5 as RateLimitInfo, bH as RecordProperty, bf as RecordPropertySchema, bI as RecordsProperty, bg as RecordsPropertySchema, ad as RelayFetchSchema, ac as RelayRequestSchema, as as RequestOptions, cP as RequestPluginProvides, dk as ResolveAuthTokenOptions, dL as ResolveCredentialsOptions, dD as ResolvedCredentials, dT as ResolvedCredentialsSchema, $ as Resolver, a1 as ResolverMetadata, aV as RootFieldItem, cN as RunActionPluginProvides, dx as SdkEvent, aY as SdkPage, a2 as StaticResolver, bG as TableProperty, be as TablePropertySchema, bL as TablesProperty, bj as TablesPropertySchema, bO as TriggerInboxNameProperty, bm as TriggerInboxNamePropertySchema, bN as TriggerInboxProperty, bl as TriggerInboxPropertySchema, T as TriggerMessageStatus, ey as UpdateTableRecordsPluginProvides, Q as UserProfile, aW as UserProfileItem, e1 as ZAPIER_BASE_URL, e6 as ZAPIER_MAX_NETWORK_RETRIES, e7 as ZAPIER_MAX_NETWORK_RETRY_DELAY_MS, m as ZapierAbortDrainSignal, c3 as ZapierActionError, bV as ZapierApiError, bW as ZapierAppNotFoundError, c8 as ZapierApprovalError, bZ as ZapierAuthenticationError, c1 as ZapierBundleError, dt as ZapierCache, du as ZapierCacheEntry, dv as ZapierCacheSetOptions, c0 as ZapierConfigurationError, c4 as ZapierConflictError, bU as ZapierError, b_ as ZapierNotFoundError, c6 as ZapierRateLimitError, c9 as ZapierRelayError, n as ZapierReleaseTriggerMessageSignal, b$ as ZapierResourceNotFoundError, cb as ZapierSignal, c2 as ZapierTimeoutError, bY as ZapierUnknownError, bX as ZapierValidationError, d1 as actionKeyResolver, d0 as actionTypeResolver, cZ as apiPlugin, c$ as appKeyResolver, cc as appsPlugin, d3 as authenticationIdGenericResolver, d2 as authenticationIdResolver, a7 as batch, aL as buildApplicationLifecycleEvent, a9 as buildCapabilityMessage, aN as buildErrorEvent, aM as buildErrorEventWithContext, aP as buildMethodCalledEvent, dl as clearTokenCache, d7 as clientCredentialsNameResolver, d8 as clientIdResolver, ap as composePlugins, d3 as connectionIdGenericResolver, d2 as connectionIdResolver, d$ as connectionsPlugin, aO as createBaseEvent, cw as createClientCredentialsPlugin, V as createFunction, dw as createMemoryCache, ag as createOptionsPlugin, ao as createPaginatedPluginMethod, an as createPluginMethod, af as createSdk, el as createTableFieldsPlugin, ef as createTablePlugin, et as createTableRecordsPlugin, ae as createZapierSdkWithoutRegistry, am as definePlugin, cy as deleteClientCredentialsPlugin, en as deleteTableFieldsPlugin, eh as deleteTablePlugin, ev as deleteTableRecordsPlugin, cg as fetchPlugin, cG as findFirstConnectionPlugin, cI as findUniqueConnectionPlugin, ca as formatErrorMessage, aC as generateEventId, cq as getActionInputFieldsSchemaPlugin, cC as getActionPlugin, cA as getAppPlugin, dO as getBaseUrlFromCredentials, aI as getCiPlatform, dP as getClientIdFromCredentials, cE as getConnectionPlugin, aK as getCpuTime, aD as getCurrentTimestamp, aJ as getMemoryUsage, aF as getOsInfo, aG as getPlatformVersions, cR as getPreferredManifestEntryKey, cW as getProfilePlugin, aE as getReleaseId, ed as getTablePlugin, ep as getTableRecordPlugin, dq as getTokenFromCliLogin, e8 as getZapierApprovalMode, e2 as getZapierSdkService, dn as injectCliLogin, d6 as inputFieldKeyResolver, d5 as inputsAllOptionalResolver, d4 as inputsResolver, dm as invalidateCachedToken, ds as invalidateCredentialsToken, aH as isCi, dp as isCliLoginAvailable, dH as isClientCredentials, dK as isCredentialsFunction, dJ as isCredentialsObject, dI as isPkceCredentials, S as isPositional, co as listActionInputFieldChoicesPlugin, cm as listActionInputFieldsPlugin, ck as listActionsPlugin, ci as listAppsPlugin, cu as listClientCredentialsPlugin, cs as listConnectionsPlugin, ej as listTableFieldsPlugin, er as listTableRecordsPlugin, eb as listTablesPlugin, aa as logDeprecation, cS as manifestPlugin, au as registryPlugin, cO as requestPlugin, ab as resetDeprecationWarnings, dr as resolveAuthToken, dN as resolveCredentials, dM as resolveCredentialsFromEnv, cM as runActionPlugin, a4 as runWithTelemetryContext, dd as tableFieldIdsResolver, df as tableFieldsResolver, di as tableFiltersResolver, d9 as tableIdResolver, de as tableNameResolver, db as tableRecordIdResolver, dc as tableRecordIdsResolver, dg as tableRecordsResolver, dj as tableSortResolver, dh as tableUpdateRecordsResolver, a5 as toSnakeCase, a6 as toTitleCase, da as triggerInboxResolver, ex as updateTableRecordsPlugin } from './index-BQ2ii0Bs.mjs';
3
3
  import * as zod_v4_core from 'zod/v4/core';
4
4
  import * as zod from 'zod';
5
5
  import '@zapier/zapier-sdk-core/v0/schemas/connections';
@@ -148,12 +148,10 @@ function parseIntEnvVar(name) {
148
148
  }
149
149
  var ZAPIER_MAX_NETWORK_RETRIES = parseIntEnvVar("ZAPIER_MAX_NETWORK_RETRIES") ?? 3;
150
150
  var ZAPIER_MAX_NETWORK_RETRY_DELAY_MS = parseIntEnvVar("ZAPIER_MAX_NETWORK_RETRY_DELAY_MS") ?? 6e4;
151
- function getZapierIsInteractive() {
152
- return globalThis.process?.env?.ZAPIER_IS_INTERACTIVE === "true";
153
- }
154
151
  function getZapierApprovalMode() {
155
152
  const value = globalThis.process?.env?.ZAPIER_APPROVAL_MODE;
156
- if (value === "poll" || value === "fail") return value;
153
+ if (value === "disabled" || value === "poll" || value === "throw")
154
+ return value;
157
155
  return void 0;
158
156
  }
159
157
  var DEFAULT_APPROVAL_TIMEOUT_MS = 10 * 60 * 1e3;
@@ -2659,7 +2657,7 @@ async function invalidateCredentialsToken(options) {
2659
2657
  }
2660
2658
 
2661
2659
  // src/sdk-version.ts
2662
- var SDK_VERSION = (typeof process !== "undefined" && process.env ? "0.49.0" : void 0) || "unknown";
2660
+ var SDK_VERSION = (typeof process !== "undefined" && process.env ? "0.50.0" : void 0) || "unknown";
2663
2661
 
2664
2662
  // src/utils/open-url.ts
2665
2663
  var nodePrefix = "node:";
@@ -2934,10 +2932,10 @@ var ZapierApiClient = class {
2934
2932
  }
2935
2933
  if (errorType !== "approval_required") return response;
2936
2934
  if (attempt === maxRetries) break;
2937
- const isInteractive = this.options.isInteractive ?? getZapierIsInteractive();
2938
- if (!isInteractive) {
2935
+ const mode = this.options.approvalMode ?? getZapierApprovalMode() ?? "disabled";
2936
+ if (mode === "disabled") {
2939
2937
  throw new ZapierApprovalError(
2940
- "Approval required but session is not interactive",
2938
+ "Approvals are disabled. Set approvalMode to 'poll' or 'throw' (or ZAPIER_APPROVAL_MODE) to enable.",
2941
2939
  { status: "approval_required" }
2942
2940
  );
2943
2941
  }
@@ -2947,7 +2945,7 @@ var ZapierApiClient = class {
2947
2945
  { statusCode: 403 }
2948
2946
  );
2949
2947
  }
2950
- await this.runOneApprovalRound(init.approvalContext);
2948
+ await this.runOneApprovalRound(init.approvalContext, mode);
2951
2949
  }
2952
2950
  throw new ZapierApprovalError(
2953
2951
  `Exceeded maximum approval retries (${maxRetries}) for ${path}`,
@@ -3266,10 +3264,13 @@ var ZapierApiClient = class {
3266
3264
  }
3267
3265
  /**
3268
3266
  * Run a single approval round: create the approval, open the URL (poll mode)
3269
- * or throw (fail mode), poll until resolved, and emit events. Throws on
3267
+ * or throw (throw mode), poll until resolved, and emit events. Throws on
3270
3268
  * denied/timeout/unexpected status. Returns on approved.
3269
+ *
3270
+ * Caller is responsible for passing a non-"disabled" mode; this method
3271
+ * unconditionally creates an approval.
3271
3272
  */
3272
- async runOneApprovalRound(buildContext) {
3273
+ async runOneApprovalRound(buildContext, mode) {
3273
3274
  const context = buildContext();
3274
3275
  let approvalResponse;
3275
3276
  try {
@@ -3344,8 +3345,7 @@ var ZapierApiClient = class {
3344
3345
  approvalId: approval.approval_id,
3345
3346
  approvalUrl: approval.approval_url
3346
3347
  });
3347
- const approvalMode = this.options.approvalMode ?? getZapierApprovalMode();
3348
- if (approvalMode === "fail") {
3348
+ if (mode === "throw") {
3349
3349
  throw new ZapierApprovalError("This request requires approval.", {
3350
3350
  approvalId: approval.approval_id,
3351
3351
  approvalUrl: approval.approval_url,
@@ -3444,7 +3444,6 @@ var apiPlugin = definePlugin(
3444
3444
  debug = false,
3445
3445
  maxNetworkRetries = ZAPIER_MAX_NETWORK_RETRIES,
3446
3446
  maxNetworkRetryDelayMs = ZAPIER_MAX_NETWORK_RETRY_DELAY_MS,
3447
- isInteractive,
3448
3447
  approvalTimeoutMs,
3449
3448
  maxApprovalRetries,
3450
3449
  approvalMode,
@@ -3459,7 +3458,6 @@ var apiPlugin = definePlugin(
3459
3458
  onEvent,
3460
3459
  maxNetworkRetries,
3461
3460
  maxNetworkRetryDelayMs,
3462
- isInteractive,
3463
3461
  approvalTimeoutMs,
3464
3462
  maxApprovalRetries,
3465
3463
  approvalMode,
@@ -10165,16 +10163,13 @@ var BaseSdkOptionsSchema = z.object({
10165
10163
  * Default is 60000 (60 seconds).
10166
10164
  */
10167
10165
  maxNetworkRetryDelayMs: z.number().optional().describe("Max delay in ms to wait for retry (default: 60000).").meta({ valueHint: "ms" }),
10168
- isInteractive: z.boolean().optional().describe(
10169
- "Whether this session is interactive (user can visit approval URLs). Defaults to ZAPIER_IS_INTERACTIVE env var."
10170
- ).meta({ internal: true }),
10171
- approvalTimeoutMs: z.number().optional().describe("Timeout in ms for approval polling. Default: 600000 (10 min).").meta({ valueHint: "ms", internal: true }),
10166
+ approvalTimeoutMs: z.number().optional().describe("Timeout in ms for approval polling. Default: 600000 (10 min).").meta({ valueHint: "ms" }),
10172
10167
  maxApprovalRetries: z.number().optional().describe(
10173
10168
  "Maximum number of sequential approval rounds per request (one per gating policy) before giving up. Default: 2."
10174
- ).meta({ internal: true }),
10175
- approvalMode: z.enum(["poll", "fail"]).optional().describe(
10176
- 'Approval flow behavior. "poll" opens browser and polls (default). "fail" creates the approval and throws immediately with the approval URL.'
10177
- ).meta({ internal: true }),
10169
+ ),
10170
+ approvalMode: z.enum(["disabled", "poll", "throw"]).optional().describe(
10171
+ 'Approval flow behavior. "disabled" (default) throws a ZapierApprovalError on approval-required responses without creating an approval. "poll" creates the approval, opens it in a browser, polls until resolved, and retries the original request. "throw" creates the approval and throws a ZapierApprovalError with the approval URL so the caller can surface it. Defaults to the ZAPIER_APPROVAL_MODE env var, then "disabled".'
10172
+ ),
10178
10173
  // Internal
10179
10174
  manifestPath: z.string().optional().describe("Path to a .zapierrc manifest file for app version locking.").meta({ internal: true }),
10180
10175
  manifest: z.custom().optional().describe("Manifest for app version locking.").meta({ internal: true }),
@@ -10204,4 +10199,4 @@ function createZapierSdk2(options = {}) {
10204
10199
  return createSdk().addPlugin(createOptionsPlugin(options)).addPlugin(eventEmissionPlugin).addPlugin(apiPlugin).addPlugin(manifestPlugin).addPlugin(capabilitiesPlugin).addPlugin(connectionsPlugin).addPlugin(listAppsPlugin).addPlugin(getAppPlugin).addPlugin(listActionsPlugin).addPlugin(getActionPlugin).addPlugin(listActionInputFieldsPlugin).addPlugin(getActionInputFieldsSchemaPlugin).addPlugin(listActionInputFieldChoicesPlugin).addPlugin(listInputFieldsDeprecatedPlugin).addPlugin(getInputFieldsSchemaDeprecatedPlugin).addPlugin(listInputFieldChoicesDeprecatedPlugin).addPlugin(runActionPlugin).addPlugin(listConnectionsPlugin).addPlugin(getConnectionPlugin).addPlugin(findFirstConnectionPlugin).addPlugin(findUniqueConnectionPlugin).addPlugin(listAuthenticationsPlugin).addPlugin(getAuthenticationPlugin).addPlugin(findFirstAuthenticationPlugin).addPlugin(findUniqueAuthenticationPlugin).addPlugin(listClientCredentialsPlugin).addPlugin(createClientCredentialsPlugin).addPlugin(deleteClientCredentialsPlugin).addPlugin(fetchPlugin).addPlugin(requestPlugin).addPlugin(createTriggerInboxPlugin).addPlugin(ensureTriggerInboxPlugin).addPlugin(listTriggerInboxesPlugin).addPlugin(getTriggerInboxPlugin).addPlugin(updateTriggerInboxPlugin).addPlugin(deleteTriggerInboxPlugin).addPlugin(pauseTriggerInboxPlugin).addPlugin(resumeTriggerInboxPlugin).addPlugin(listTriggerInboxMessagesPlugin).addPlugin(leaseTriggerInboxMessagesPlugin).addPlugin(ackTriggerInboxMessagesPlugin).addPlugin(releaseTriggerInboxMessagesPlugin).addPlugin(drainTriggerInboxPlugin).addPlugin(watchTriggerInboxPlugin).addPlugin(listTriggerInputFieldsPlugin).addPlugin(listTriggerInputFieldChoicesPlugin).addPlugin(getTriggerInputFieldsSchemaPlugin).addPlugin(listTablesPlugin).addPlugin(getTablePlugin).addPlugin(deleteTablePlugin).addPlugin(createTablePlugin).addPlugin(listTableFieldsPlugin).addPlugin(createTableFieldsPlugin).addPlugin(deleteTableFieldsPlugin).addPlugin(getTableRecordPlugin).addPlugin(listTableRecordsPlugin).addPlugin(createTableRecordsPlugin).addPlugin(deleteTableRecordsPlugin).addPlugin(updateTableRecordsPlugin).addPlugin(appsPlugin).addPlugin(getProfilePlugin);
10205
10200
  }
10206
10201
 
10207
- export { ActionKeyPropertySchema, ActionPropertySchema, ActionTimeoutMsPropertySchema, ActionTypePropertySchema, AppKeyPropertySchema, AppPropertySchema, AppsPropertySchema, AuthenticationIdPropertySchema, BaseSdkOptionsSchema, CONTEXT_CACHE_MAX_SIZE, CONTEXT_CACHE_TTL_MS, ClientCredentialsObjectSchema, ConnectionEntrySchema, ConnectionIdPropertySchema, ConnectionPropertySchema, ConnectionsMapSchema, ConnectionsPropertySchema, CredentialsFunctionSchema, CredentialsObjectSchema, CredentialsSchema, DEFAULT_ACTION_TIMEOUT_MS, DEFAULT_APPROVAL_TIMEOUT_MS, DEFAULT_CONFIG_PATH, DEFAULT_MAX_APPROVAL_RETRIES, DEFAULT_PAGE_SIZE, DebugPropertySchema, FieldsPropertySchema, InputFieldPropertySchema, InputsPropertySchema, LeaseLimitPropertySchema, LeasePropertySchema, LeaseSecondsPropertySchema, LimitPropertySchema, MAX_PAGE_LIMIT, OffsetPropertySchema, OutputPropertySchema, ParamsPropertySchema, PkceCredentialsObjectSchema, RecordPropertySchema, RecordsPropertySchema, RelayFetchSchema, RelayRequestSchema, ResolvedCredentialsSchema, TablePropertySchema, TablesPropertySchema, TriggerInboxNamePropertySchema, TriggerInboxPropertySchema, ZAPIER_BASE_URL, ZAPIER_MAX_NETWORK_RETRIES, ZAPIER_MAX_NETWORK_RETRY_DELAY_MS, ZapierAbortDrainSignal, ZapierActionError, ZapierApiError, ZapierAppNotFoundError, ZapierApprovalError, ZapierAuthenticationError, ZapierBundleError, ZapierConfigurationError, ZapierConflictError, ZapierError, ZapierNotFoundError, ZapierRateLimitError, ZapierRelayError, ZapierReleaseTriggerMessageSignal, ZapierResourceNotFoundError, ZapierSignal, ZapierTimeoutError, ZapierUnknownError, ZapierValidationError, actionKeyResolver, actionTypeResolver, apiPlugin, appKeyResolver, appsPlugin, connectionIdGenericResolver as authenticationIdGenericResolver, connectionIdResolver as authenticationIdResolver, batch, buildApplicationLifecycleEvent, buildCapabilityMessage, buildErrorEvent, buildErrorEventWithContext, buildMethodCalledEvent, clearTokenCache, clientCredentialsNameResolver, clientIdResolver, composePlugins, connectionIdGenericResolver, connectionIdResolver, connectionsPlugin, createBaseEvent, createClientCredentialsPlugin, createFunction, createMemoryCache, createOptionsPlugin, createPaginatedPluginMethod, createPluginMethod, createSdk, createTableFieldsPlugin, createTablePlugin, createTableRecordsPlugin, createZapierSdk2 as createZapierSdk, createZapierSdkWithoutRegistry, definePlugin, deleteClientCredentialsPlugin, deleteTableFieldsPlugin, deleteTablePlugin, deleteTableRecordsPlugin, fetchPlugin, findFirstConnectionPlugin, findManifestEntry, findUniqueConnectionPlugin, formatErrorMessage, generateEventId, getActionInputFieldsSchemaPlugin, getActionPlugin, getAppPlugin, getBaseUrlFromCredentials, getCiPlatform, getClientIdFromCredentials, getConnectionPlugin, getCpuTime, getCurrentTimestamp, getMemoryUsage, getOsInfo, getPlatformVersions, getPreferredManifestEntryKey, getProfilePlugin, getReleaseId, getTablePlugin, getTableRecordPlugin, getTokenFromCliLogin, getZapierApprovalMode, getZapierIsInteractive, getZapierSdkService, injectCliLogin, inputFieldKeyResolver, inputsAllOptionalResolver, inputsResolver, invalidateCachedToken, invalidateCredentialsToken, isCi, isCliLoginAvailable, isClientCredentials, isCredentialsFunction, isCredentialsObject, isPkceCredentials, isPositional, listActionInputFieldChoicesPlugin, listActionInputFieldsPlugin, listActionsPlugin, listAppsPlugin, listClientCredentialsPlugin, listConnectionsPlugin, listTableFieldsPlugin, listTableRecordsPlugin, listTablesPlugin, logDeprecation, manifestPlugin, readManifestFromFile, registryPlugin, requestPlugin, resetDeprecationWarnings, resolveAuthToken, resolveCredentials, resolveCredentialsFromEnv, runActionPlugin, runWithTelemetryContext, tableFieldIdsResolver, tableFieldsResolver, tableFiltersResolver, tableIdResolver, tableNameResolver, tableRecordIdResolver, tableRecordIdsResolver, tableRecordsResolver, tableSortResolver, tableUpdateRecordsResolver, toSnakeCase, toTitleCase, triggerInboxResolver, updateTableRecordsPlugin };
10202
+ export { ActionKeyPropertySchema, ActionPropertySchema, ActionTimeoutMsPropertySchema, ActionTypePropertySchema, AppKeyPropertySchema, AppPropertySchema, AppsPropertySchema, AuthenticationIdPropertySchema, BaseSdkOptionsSchema, CONTEXT_CACHE_MAX_SIZE, CONTEXT_CACHE_TTL_MS, ClientCredentialsObjectSchema, ConnectionEntrySchema, ConnectionIdPropertySchema, ConnectionPropertySchema, ConnectionsMapSchema, ConnectionsPropertySchema, CredentialsFunctionSchema, CredentialsObjectSchema, CredentialsSchema, DEFAULT_ACTION_TIMEOUT_MS, DEFAULT_APPROVAL_TIMEOUT_MS, DEFAULT_CONFIG_PATH, DEFAULT_MAX_APPROVAL_RETRIES, DEFAULT_PAGE_SIZE, DebugPropertySchema, FieldsPropertySchema, InputFieldPropertySchema, InputsPropertySchema, LeaseLimitPropertySchema, LeasePropertySchema, LeaseSecondsPropertySchema, LimitPropertySchema, MAX_PAGE_LIMIT, OffsetPropertySchema, OutputPropertySchema, ParamsPropertySchema, PkceCredentialsObjectSchema, RecordPropertySchema, RecordsPropertySchema, RelayFetchSchema, RelayRequestSchema, ResolvedCredentialsSchema, TablePropertySchema, TablesPropertySchema, TriggerInboxNamePropertySchema, TriggerInboxPropertySchema, ZAPIER_BASE_URL, ZAPIER_MAX_NETWORK_RETRIES, ZAPIER_MAX_NETWORK_RETRY_DELAY_MS, ZapierAbortDrainSignal, ZapierActionError, ZapierApiError, ZapierAppNotFoundError, ZapierApprovalError, ZapierAuthenticationError, ZapierBundleError, ZapierConfigurationError, ZapierConflictError, ZapierError, ZapierNotFoundError, ZapierRateLimitError, ZapierRelayError, ZapierReleaseTriggerMessageSignal, ZapierResourceNotFoundError, ZapierSignal, ZapierTimeoutError, ZapierUnknownError, ZapierValidationError, actionKeyResolver, actionTypeResolver, apiPlugin, appKeyResolver, appsPlugin, connectionIdGenericResolver as authenticationIdGenericResolver, connectionIdResolver as authenticationIdResolver, batch, buildApplicationLifecycleEvent, buildCapabilityMessage, buildErrorEvent, buildErrorEventWithContext, buildMethodCalledEvent, clearTokenCache, clientCredentialsNameResolver, clientIdResolver, composePlugins, connectionIdGenericResolver, connectionIdResolver, connectionsPlugin, createBaseEvent, createClientCredentialsPlugin, createFunction, createMemoryCache, createOptionsPlugin, createPaginatedPluginMethod, createPluginMethod, createSdk, createTableFieldsPlugin, createTablePlugin, createTableRecordsPlugin, createZapierSdk2 as createZapierSdk, createZapierSdkWithoutRegistry, definePlugin, deleteClientCredentialsPlugin, deleteTableFieldsPlugin, deleteTablePlugin, deleteTableRecordsPlugin, fetchPlugin, findFirstConnectionPlugin, findManifestEntry, findUniqueConnectionPlugin, formatErrorMessage, generateEventId, getActionInputFieldsSchemaPlugin, getActionPlugin, getAppPlugin, getBaseUrlFromCredentials, getCiPlatform, getClientIdFromCredentials, getConnectionPlugin, getCpuTime, getCurrentTimestamp, getMemoryUsage, getOsInfo, getPlatformVersions, getPreferredManifestEntryKey, getProfilePlugin, getReleaseId, getTablePlugin, getTableRecordPlugin, getTokenFromCliLogin, getZapierApprovalMode, getZapierSdkService, injectCliLogin, inputFieldKeyResolver, inputsAllOptionalResolver, inputsResolver, invalidateCachedToken, invalidateCredentialsToken, isCi, isCliLoginAvailable, isClientCredentials, isCredentialsFunction, isCredentialsObject, isPkceCredentials, isPositional, listActionInputFieldChoicesPlugin, listActionInputFieldsPlugin, listActionsPlugin, listAppsPlugin, listClientCredentialsPlugin, listConnectionsPlugin, listTableFieldsPlugin, listTableRecordsPlugin, listTablesPlugin, logDeprecation, manifestPlugin, readManifestFromFile, registryPlugin, requestPlugin, resetDeprecationWarnings, resolveAuthToken, resolveCredentials, resolveCredentialsFromEnv, runActionPlugin, runWithTelemetryContext, tableFieldIdsResolver, tableFieldsResolver, tableFiltersResolver, tableIdResolver, tableNameResolver, tableRecordIdResolver, tableRecordIdsResolver, tableRecordsResolver, tableSortResolver, tableUpdateRecordsResolver, toSnakeCase, toTitleCase, triggerInboxResolver, updateTableRecordsPlugin };