@zapier/zapier-sdk 0.69.3 → 0.70.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 +21 -0
- package/README.md +1 -1
- package/dist/api/client.d.ts.map +1 -1
- package/dist/api/client.js +10 -1
- package/dist/api/error-classification.d.ts +7 -0
- package/dist/api/error-classification.d.ts.map +1 -1
- package/dist/api/error-classification.js +15 -2
- package/dist/api/index.d.ts +1 -1
- package/dist/api/index.d.ts.map +1 -1
- package/dist/api/sse-parser.d.ts +34 -0
- package/dist/api/sse-parser.d.ts.map +1 -1
- package/dist/api/sse-parser.js +28 -0
- package/dist/api/types.d.ts +9 -1
- package/dist/api/types.d.ts.map +1 -1
- package/dist/auth.d.ts.map +1 -1
- package/dist/auth.js +2 -2
- package/dist/experimental.cjs +117 -34
- package/dist/experimental.d.mts +2 -2
- package/dist/experimental.mjs +117 -34
- package/dist/{index-DuFFW71E.d.mts → index-C0bQ5snd.d.mts} +33 -1
- package/dist/{index-DuFFW71E.d.ts → index-C0bQ5snd.d.ts} +33 -1
- package/dist/index.cjs +32 -5
- package/dist/index.d.mts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.mjs +32 -5
- package/dist/plugins/triggers/drainTriggerInbox/index.d.ts +4 -2
- package/dist/plugins/triggers/drainTriggerInbox/index.d.ts.map +1 -1
- package/dist/plugins/triggers/drainTriggerInbox/index.js +39 -6
- package/dist/plugins/triggers/watchTriggerInbox/index.d.ts +4 -2
- package/dist/plugins/triggers/watchTriggerInbox/index.d.ts.map +1 -1
- package/dist/plugins/triggers/watchTriggerInbox/index.js +100 -16
- package/dist/plugins/triggers/watchTriggerInbox/sse.d.ts +8 -6
- package/dist/plugins/triggers/watchTriggerInbox/sse.d.ts.map +1 -1
- package/dist/plugins/triggers/watchTriggerInbox/sse.js +11 -13
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,26 @@
|
|
|
1
1
|
# @zapier/zapier-sdk
|
|
2
2
|
|
|
3
|
+
## 0.70.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- 8f20472: `watchTriggerInbox` now retries transient drain failures (5xx, 429,
|
|
8
|
+
network blips) indefinitely with bounded backoff instead of rejecting
|
|
9
|
+
on the first error; it still rejects immediately on fail-fast handler
|
|
10
|
+
errors, `initialization_failure`, and permanent HTTP errors. When those
|
|
11
|
+
retries persist long enough to saturate the backoff, it warns once on
|
|
12
|
+
stderr (re-armed on recovery) so a stalled watch isn't silent.
|
|
13
|
+
|
|
14
|
+
New `ApiClient.fetchJsonStream` (with the `JsonSseMessage` type): like
|
|
15
|
+
`fetchStream` but JSON-parses each frame, surfacing a malformed frame
|
|
16
|
+
as `{ parsed: false, data: null, raw }` instead of throwing, so one
|
|
17
|
+
bad frame can't kill a long-lived stream. A non-ok response still
|
|
18
|
+
throws the shared `ZapierError` subclasses before the first frame.
|
|
19
|
+
|
|
20
|
+
Fixed: a fail-fast handler that throws a falsy value (`throw
|
|
21
|
+
undefined`) is no longer silently swallowed, and a handler-thrown
|
|
22
|
+
AbortError now rejects the watch instead of resolving it cleanly.
|
|
23
|
+
|
|
3
24
|
## 0.69.3
|
|
4
25
|
|
|
5
26
|
### Patch Changes
|
package/README.md
CHANGED
|
@@ -3230,7 +3230,7 @@ const result = await zapier.updateTriggerInbox({
|
|
|
3230
3230
|
|
|
3231
3231
|
#### `watchTriggerInbox` 🧪 _experimental_
|
|
3232
3232
|
|
|
3233
|
-
Continuously consume a trigger inbox: drain currently-available messages via onMessage, then subscribe to SSE notifications for new arrivals until aborted. A periodic safety drain runs every maxDrainIntervalSeconds (default: 300) to guarantee forward progress if SSE events are missed. Resolves cleanly on signal abort or ZapierAbortDrainSignal from a handler
|
|
3233
|
+
Continuously consume a trigger inbox: drain currently-available messages via onMessage, then subscribe to SSE notifications for new arrivals until aborted. A periodic safety drain runs every maxDrainIntervalSeconds (default: 300) to guarantee forward progress if SSE events are missed. Resolves cleanly on signal abort or ZapierAbortDrainSignal from a handler. Transient drain failures (5xx, 429, network blips) retry indefinitely with bounded backoff until they succeed or the watch is aborted; it rejects on a fail-fast handler error, an initialization_failure, or a permanent HTTP error. Real-time wake-up health is reported on stderr: a warning when wake-ups pause and the watch falls back to the safety drain, plus (with debug) transient reconnect notices. Persistent drain failures likewise warn once on stderr while bounded-backoff retries continue.
|
|
3234
3234
|
|
|
3235
3235
|
**Parameters:**
|
|
3236
3236
|
|
package/dist/api/client.d.ts.map
CHANGED
|
@@ -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,EAIjB,MAAM,SAAS,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,EAIjB,MAAM,SAAS,CAAC;AAk0CjB,eAAO,MAAM,eAAe,GAAI,SAAS,gBAAgB,KAAG,SAW3D,CAAC"}
|
package/dist/api/client.js
CHANGED
|
@@ -13,7 +13,7 @@ import { getZapierBaseUrl, isLocalhostBaseUrl } from "../utils/url-utils";
|
|
|
13
13
|
import { sleep, calculateExponentialBackoffMs } from "../utils/retry-utils";
|
|
14
14
|
import { isPlainObject } from "../utils/type-guard-utils";
|
|
15
15
|
import { isAbortError } from "../utils/abort-utils";
|
|
16
|
-
import { createSseParserStream } from "./sse-parser";
|
|
16
|
+
import { createSseParserStream, jsonFrames, } from "./sse-parser";
|
|
17
17
|
import { ZapierApiError, ZapierApprovalError, ZapierAuthenticationError, ZapierConfigurationError, ZapierTimeoutError, ZapierValidationError, ZapierResourceNotFoundError, ZapierRateLimitError, } from "../types/errors";
|
|
18
18
|
import { MAX_CONCURRENCY_LIMIT, ZAPIER_MAX_CONCURRENT_REQUESTS, ZAPIER_MAX_NETWORK_RETRIES, ZAPIER_MAX_NETWORK_RETRY_DELAY_MS, getZapierApprovalMode, getZapierDefaultApprovalMode, getZapierSdkService, DEFAULT_APPROVAL_TIMEOUT_MS, DEFAULT_MAX_APPROVAL_RETRIES, } from "../constants";
|
|
19
19
|
import { SDK_VERSION } from "../sdk-version";
|
|
@@ -359,6 +359,15 @@ class ZapierApiClient {
|
|
|
359
359
|
* never pins a slot — see `withSemaphore`.
|
|
360
360
|
*/
|
|
361
361
|
this.fetchStream = (path, init) => this.streamSse(path, init);
|
|
362
|
+
/**
|
|
363
|
+
* Like `fetchStream`, but parses each frame's `data` as JSON. Diverges from
|
|
364
|
+
* `fetchJson` deliberately: that throws on invalid JSON, but a long-lived
|
|
365
|
+
* stream must survive a single malformed frame, so a parse failure is yielded
|
|
366
|
+
* as `{ parsed: false, data: null, raw }` rather than thrown. A non-ok
|
|
367
|
+
* response still throws the shared `ZapierError` (from `fetchStream`, before
|
|
368
|
+
* any frame), so transport / auth failures surface as usual.
|
|
369
|
+
*/
|
|
370
|
+
this.fetchJsonStream = (path, init) => jsonFrames(this.fetchStream(path, init));
|
|
362
371
|
this.get = async (path, options = {}) => {
|
|
363
372
|
return this.fetchJson("GET", path, undefined, options);
|
|
364
373
|
};
|
|
@@ -7,6 +7,13 @@
|
|
|
7
7
|
* `api.fetch` already backed off and retried it upstream, so a
|
|
8
8
|
* `ZapierRateLimitError` (also a `ZapierError`) that escapes should be retried
|
|
9
9
|
* on the normal cadence rather than treated as permanent.
|
|
10
|
+
*
|
|
11
|
+
* A `ZapierAuthenticationError` with no `statusCode` is the one carve-out: the
|
|
12
|
+
* token-exchange / credential-resolution layer throws these for setup problems
|
|
13
|
+
* (token endpoint rejected the credentials, missing keychain secret, no
|
|
14
|
+
* credentials at all) that never self-heal, so they are permanent even without
|
|
15
|
+
* a status. Auth errors that DO carry a status fall through to the rule above,
|
|
16
|
+
* so a 5xx/429 from the token endpoint still retries.
|
|
10
17
|
*/
|
|
11
18
|
export declare function isPermanentHttpError(err: unknown): boolean;
|
|
12
19
|
//# sourceMappingURL=error-classification.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"error-classification.d.ts","sourceRoot":"","sources":["../../src/api/error-classification.ts"],"names":[],"mappings":"AAEA
|
|
1
|
+
{"version":3,"file":"error-classification.d.ts","sourceRoot":"","sources":["../../src/api/error-classification.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,oBAAoB,CAAC,GAAG,EAAE,OAAO,GAAG,OAAO,CAe1D"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ZapierError } from "../types/errors";
|
|
1
|
+
import { ZapierAuthenticationError, ZapierError } from "../types/errors";
|
|
2
2
|
/**
|
|
3
3
|
* Classifies an HTTP error by status code. A 4xx is permanent for now
|
|
4
4
|
* (auth/permission/bad request); 5xx and network errors are transient. We read
|
|
@@ -8,9 +8,22 @@ import { ZapierError } from "../types/errors";
|
|
|
8
8
|
* `api.fetch` already backed off and retried it upstream, so a
|
|
9
9
|
* `ZapierRateLimitError` (also a `ZapierError`) that escapes should be retried
|
|
10
10
|
* on the normal cadence rather than treated as permanent.
|
|
11
|
+
*
|
|
12
|
+
* A `ZapierAuthenticationError` with no `statusCode` is the one carve-out: the
|
|
13
|
+
* token-exchange / credential-resolution layer throws these for setup problems
|
|
14
|
+
* (token endpoint rejected the credentials, missing keychain secret, no
|
|
15
|
+
* credentials at all) that never self-heal, so they are permanent even without
|
|
16
|
+
* a status. Auth errors that DO carry a status fall through to the rule above,
|
|
17
|
+
* so a 5xx/429 from the token endpoint still retries.
|
|
11
18
|
*/
|
|
12
19
|
export function isPermanentHttpError(err) {
|
|
13
|
-
|
|
20
|
+
if (!(err instanceof ZapierError))
|
|
21
|
+
return false;
|
|
22
|
+
if (err instanceof ZapierAuthenticationError &&
|
|
23
|
+
err.statusCode === undefined) {
|
|
24
|
+
return true;
|
|
25
|
+
}
|
|
26
|
+
const { statusCode } = err;
|
|
14
27
|
return (statusCode !== undefined &&
|
|
15
28
|
statusCode >= 400 &&
|
|
16
29
|
statusCode < 500 &&
|
package/dist/api/index.d.ts
CHANGED
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
export type { ApiClient, ApiClientOptions, RequestOptions, PollOptions, DebugLogger, Action, Field, Choice, ActionExecutionResult, ActionField, ActionFieldChoice, NeedsRequest, NeedsResponse, Connection, ConnectionsResponse, Implementation, ImplementationsResponse, } from "./types";
|
|
9
9
|
import type { ApiClient } from "./types";
|
|
10
10
|
import type { Credentials } from "../types/credentials";
|
|
11
|
-
export type { SseMessage } from "./sse-parser";
|
|
11
|
+
export type { SseMessage, JsonSseMessage } from "./sse-parser";
|
|
12
12
|
export { isJwt, getAuthorizationHeader, extractUserIdsFromJwt } from "./auth";
|
|
13
13
|
export { createDebugLogger, createDebugFetch } from "./debug";
|
|
14
14
|
export { pollUntilComplete } from "./polling";
|
package/dist/api/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/api/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAGH,YAAY,EAEV,SAAS,EACT,gBAAgB,EAChB,cAAc,EACd,WAAW,EACX,WAAW,EAEX,MAAM,EACN,KAAK,EACL,MAAM,EACN,qBAAqB,EACrB,WAAW,EACX,iBAAiB,EACjB,YAAY,EACZ,aAAa,EACb,UAAU,EACV,mBAAmB,EACnB,cAAc,EACd,uBAAuB,GACxB,MAAM,SAAS,CAAC;AAGjB,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AACzC,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AAKxD,YAAY,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAG/
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources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
data: string;
|
|
3
3
|
}
|
|
4
|
+
/**
|
|
5
|
+
* A streamed SSE frame after JSON parsing, as yielded by
|
|
6
|
+
* `ApiClient.fetchJsonStream`. Unlike `fetchJson` — which throws on invalid
|
|
7
|
+
* JSON — a long-lived stream must not die on one malformed frame, so a parse
|
|
8
|
+
* failure is reported as `{ parsed: false, data: null, raw }` rather than
|
|
9
|
+
* thrown. Callers skip `parsed: false` frames (and may inspect `raw`) and keep
|
|
10
|
+
* consuming.
|
|
11
|
+
*/
|
|
12
|
+
export type JsonSseMessage<T = unknown> = {
|
|
13
|
+
parsed: true;
|
|
14
|
+
data: T;
|
|
15
|
+
raw: string;
|
|
16
|
+
} | {
|
|
17
|
+
parsed: false;
|
|
18
|
+
data: null;
|
|
19
|
+
raw: string;
|
|
20
|
+
};
|
|
21
|
+
/**
|
|
22
|
+
* Wraps any SSE frame source, JSON-parsing each frame's `data`. A long-lived
|
|
23
|
+
* stream must not die on one malformed frame, so a parse failure is yielded as
|
|
24
|
+
* `{ parsed: false, data: null, raw }` rather than thrown; callers skip those
|
|
25
|
+
* and keep consuming. The `source` parameter is `AsyncIterable`, not a
|
|
26
|
+
* generator, so this is genuinely source-agnostic — any SSE stream qualifies.
|
|
27
|
+
*
|
|
28
|
+
* Two structural invariants the parse boundary depends on:
|
|
29
|
+
* - The `try` wraps ONLY the per-frame `JSON.parse`, so any error the `source`
|
|
30
|
+
* itself surfaces (a pre-frame throw, a mid-stream `read()` rejection, or
|
|
31
|
+
* whatever a future source throws) propagates rather than being swallowed as
|
|
32
|
+
* a `parsed: false` frame.
|
|
33
|
+
* - The `yield` sits OUTSIDE the `try`, so an exception injected at the
|
|
34
|
+
* suspended yield (`gen.throw()`) propagates and unwinds the `for await`
|
|
35
|
+
* (closing `source`), instead of being caught and re-emitted as `parsed: false`.
|
|
36
|
+
*/
|
|
37
|
+
export declare function jsonFrames<T = unknown>(source: AsyncIterable<SseMessage>): AsyncGenerator<JsonSseMessage<T>>;
|
|
4
38
|
/**
|
|
5
39
|
* Minimal Server-Sent Events frame parser as a TransformStream that turns
|
|
6
40
|
* decoded text chunks into `{ data }` messages.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sse-parser.d.ts","sourceRoot":"","sources":["../../src/api/sse-parser.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,UAAU;IACzB,IAAI,EAAE,MAAM,CAAC;CACd;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,qBAAqB,IAAI,eAAe,CAAC,MAAM,EAAE,UAAU,CAAC,CA0D3E"}
|
|
1
|
+
{"version":3,"file":"sse-parser.d.ts","sourceRoot":"","sources":["../../src/api/sse-parser.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,UAAU;IACzB,IAAI,EAAE,MAAM,CAAC;CACd;AAED;;;;;;;GAOG;AACH,MAAM,MAAM,cAAc,CAAC,CAAC,GAAG,OAAO,IAClC;IAAE,MAAM,EAAE,IAAI,CAAC;IAAC,IAAI,EAAE,CAAC,CAAC;IAAC,GAAG,EAAE,MAAM,CAAA;CAAE,GACtC;IAAE,MAAM,EAAE,KAAK,CAAC;IAAC,IAAI,EAAE,IAAI,CAAC;IAAC,GAAG,EAAE,MAAM,CAAA;CAAE,CAAC;AAE/C;;;;;;;;;;;;;;;GAeG;AACH,wBAAuB,UAAU,CAAC,CAAC,GAAG,OAAO,EAC3C,MAAM,EAAE,aAAa,CAAC,UAAU,CAAC,GAChC,cAAc,CAAC,cAAc,CAAC,CAAC,CAAC,CAAC,CAUnC;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,qBAAqB,IAAI,eAAe,CAAC,MAAM,EAAE,UAAU,CAAC,CA0D3E"}
|
package/dist/api/sse-parser.js
CHANGED
|
@@ -1,3 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Wraps any SSE frame source, JSON-parsing each frame's `data`. A long-lived
|
|
3
|
+
* stream must not die on one malformed frame, so a parse failure is yielded as
|
|
4
|
+
* `{ parsed: false, data: null, raw }` rather than thrown; callers skip those
|
|
5
|
+
* and keep consuming. The `source` parameter is `AsyncIterable`, not a
|
|
6
|
+
* generator, so this is genuinely source-agnostic — any SSE stream qualifies.
|
|
7
|
+
*
|
|
8
|
+
* Two structural invariants the parse boundary depends on:
|
|
9
|
+
* - The `try` wraps ONLY the per-frame `JSON.parse`, so any error the `source`
|
|
10
|
+
* itself surfaces (a pre-frame throw, a mid-stream `read()` rejection, or
|
|
11
|
+
* whatever a future source throws) propagates rather than being swallowed as
|
|
12
|
+
* a `parsed: false` frame.
|
|
13
|
+
* - The `yield` sits OUTSIDE the `try`, so an exception injected at the
|
|
14
|
+
* suspended yield (`gen.throw()`) propagates and unwinds the `for await`
|
|
15
|
+
* (closing `source`), instead of being caught and re-emitted as `parsed: false`.
|
|
16
|
+
*/
|
|
17
|
+
export async function* jsonFrames(source) {
|
|
18
|
+
for await (const { data } of source) {
|
|
19
|
+
let frame;
|
|
20
|
+
try {
|
|
21
|
+
frame = { parsed: true, data: JSON.parse(data), raw: data };
|
|
22
|
+
}
|
|
23
|
+
catch {
|
|
24
|
+
frame = { parsed: false, data: null, raw: data };
|
|
25
|
+
}
|
|
26
|
+
yield frame;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
1
29
|
/**
|
|
2
30
|
* Minimal Server-Sent Events frame parser as a TransformStream that turns
|
|
3
31
|
* decoded text chunks into `{ data }` messages.
|
package/dist/api/types.d.ts
CHANGED
|
@@ -14,7 +14,7 @@ import type { SdkEvent } from "../types/events";
|
|
|
14
14
|
import type { Credentials } from "../types/credentials";
|
|
15
15
|
import type { RequestContext } from "@zapier/policy-context";
|
|
16
16
|
import type { ZapierCache } from "../cache";
|
|
17
|
-
import type { SseMessage } from "./sse-parser";
|
|
17
|
+
import type { SseMessage, JsonSseMessage } from "./sse-parser";
|
|
18
18
|
import type { z } from "zod";
|
|
19
19
|
import type { NeedChoicesSchema, NeedSchema, ActionLinksSchema, ActionPermissionsSchema, ActionSchema, ChoiceSchema, FieldSchema, ActionExecutionResultSchema, ActionFieldChoiceSchema, ActionFieldSchema, UserProfileSchema, AppSchema, NeedsRequestSchema, NeedsResponseSchema, ImplementationSchema, ImplementationsResponseSchema, ServiceSchema, ServicesResponseSchema, NeedChoicesRequestSchema, NeedChoicesResponseSchema, NeedChoicesResponseMetaSchema, NeedChoicesResponseLinksSchema } from "./schemas";
|
|
20
20
|
export interface ApiClientOptions {
|
|
@@ -114,6 +114,14 @@ export interface ApiClient {
|
|
|
114
114
|
* live (response ok, body present) and before the first frame.
|
|
115
115
|
*/
|
|
116
116
|
fetchStream: (path: string, init?: FetchStreamInit) => AsyncGenerator<SseMessage>;
|
|
117
|
+
/**
|
|
118
|
+
* Like `fetchStream`, but parses each frame's `data` as JSON, yielding
|
|
119
|
+
* `{ parsed, data, raw }`. Unlike `fetchJson`, a malformed frame is never
|
|
120
|
+
* thrown — it surfaces as `{ parsed: false, data: null, raw }` so one bad
|
|
121
|
+
* frame can't kill a long-lived stream. A non-ok response still throws the
|
|
122
|
+
* shared `ZapierError` subclasses before the first frame.
|
|
123
|
+
*/
|
|
124
|
+
fetchJsonStream: <T = unknown>(path: string, init?: FetchStreamInit) => AsyncGenerator<JsonSseMessage<T>>;
|
|
117
125
|
}
|
|
118
126
|
export interface RequestOptions {
|
|
119
127
|
headers?: Record<string, string>;
|
package/dist/api/types.d.ts.map
CHANGED
|
@@ -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,KAA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AC;IACf,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,cAAc,CAAC,EAAE,MAAM,EAAE,CAAC;IAC1B,KAAK,CAAC,EAAE,WAAW,CAAC;CACrB,GAAG,OAAO,CAAC,IAAI,CAAC,CAehB"}
|
package/dist/auth.js
CHANGED
|
@@ -178,11 +178,11 @@ async function exchangeClientCredentials(options) {
|
|
|
178
178
|
},
|
|
179
179
|
timestamp: Date.now(),
|
|
180
180
|
});
|
|
181
|
-
throw new
|
|
181
|
+
throw new ZapierAuthenticationError(`Client credentials exchange failed: ${response.status} ${response.statusText}`, { statusCode: response.status });
|
|
182
182
|
}
|
|
183
183
|
const data = await response.json();
|
|
184
184
|
if (!data.access_token) {
|
|
185
|
-
throw new
|
|
185
|
+
throw new ZapierAuthenticationError("Client credentials response missing access_token");
|
|
186
186
|
}
|
|
187
187
|
onEvent?.({
|
|
188
188
|
type: "auth_success",
|
package/dist/experimental.cjs
CHANGED
|
@@ -2895,13 +2895,16 @@ async function exchangeClientCredentials(options) {
|
|
|
2895
2895
|
},
|
|
2896
2896
|
timestamp: Date.now()
|
|
2897
2897
|
});
|
|
2898
|
-
throw new
|
|
2899
|
-
`Client credentials exchange failed: ${response.status} ${response.statusText}
|
|
2898
|
+
throw new ZapierAuthenticationError(
|
|
2899
|
+
`Client credentials exchange failed: ${response.status} ${response.statusText}`,
|
|
2900
|
+
{ statusCode: response.status }
|
|
2900
2901
|
);
|
|
2901
2902
|
}
|
|
2902
2903
|
const data = await response.json();
|
|
2903
2904
|
if (!data.access_token) {
|
|
2904
|
-
throw new
|
|
2905
|
+
throw new ZapierAuthenticationError(
|
|
2906
|
+
"Client credentials response missing access_token"
|
|
2907
|
+
);
|
|
2905
2908
|
}
|
|
2906
2909
|
onEvent?.({
|
|
2907
2910
|
type: "auth_success",
|
|
@@ -3124,6 +3127,17 @@ async function invalidateCredentialsToken(options) {
|
|
|
3124
3127
|
}
|
|
3125
3128
|
|
|
3126
3129
|
// src/api/sse-parser.ts
|
|
3130
|
+
async function* jsonFrames(source) {
|
|
3131
|
+
for await (const { data } of source) {
|
|
3132
|
+
let frame;
|
|
3133
|
+
try {
|
|
3134
|
+
frame = { parsed: true, data: JSON.parse(data), raw: data };
|
|
3135
|
+
} catch {
|
|
3136
|
+
frame = { parsed: false, data: null, raw: data };
|
|
3137
|
+
}
|
|
3138
|
+
yield frame;
|
|
3139
|
+
}
|
|
3140
|
+
}
|
|
3127
3141
|
function createSseParserStream() {
|
|
3128
3142
|
let buffer = "";
|
|
3129
3143
|
let data = "";
|
|
@@ -3171,7 +3185,7 @@ function createSseParserStream() {
|
|
|
3171
3185
|
}
|
|
3172
3186
|
|
|
3173
3187
|
// src/sdk-version.ts
|
|
3174
|
-
var SDK_VERSION = (typeof process !== "undefined" && process.env ? "0.
|
|
3188
|
+
var SDK_VERSION = (typeof process !== "undefined" && process.env ? "0.70.0" : void 0) || "unknown";
|
|
3175
3189
|
|
|
3176
3190
|
// src/utils/open-url.ts
|
|
3177
3191
|
var nodePrefix = "node:";
|
|
@@ -3546,6 +3560,15 @@ var ZapierApiClient = class {
|
|
|
3546
3560
|
* never pins a slot — see `withSemaphore`.
|
|
3547
3561
|
*/
|
|
3548
3562
|
this.fetchStream = (path, init) => this.streamSse(path, init);
|
|
3563
|
+
/**
|
|
3564
|
+
* Like `fetchStream`, but parses each frame's `data` as JSON. Diverges from
|
|
3565
|
+
* `fetchJson` deliberately: that throws on invalid JSON, but a long-lived
|
|
3566
|
+
* stream must survive a single malformed frame, so a parse failure is yielded
|
|
3567
|
+
* as `{ parsed: false, data: null, raw }` rather than thrown. A non-ok
|
|
3568
|
+
* response still throws the shared `ZapierError` (from `fetchStream`, before
|
|
3569
|
+
* any frame), so transport / auth failures surface as usual.
|
|
3570
|
+
*/
|
|
3571
|
+
this.fetchJsonStream = (path, init) => jsonFrames(this.fetchStream(path, init));
|
|
3549
3572
|
this.get = async (path, options = {}) => {
|
|
3550
3573
|
return this.fetchJson("GET", path, void 0, options);
|
|
3551
3574
|
};
|
|
@@ -3752,16 +3775,16 @@ var ZapierApiClient = class {
|
|
|
3752
3775
|
if (typeof errorInfo.data === "string") {
|
|
3753
3776
|
return { message: `${fallbackMessage}: ${errorInfo.data}` };
|
|
3754
3777
|
}
|
|
3755
|
-
const
|
|
3778
|
+
const errorMessage2 = this.extractErrorMessage(errorInfo.data) || fallbackMessage;
|
|
3756
3779
|
if (this.hasErrorArray(errorInfo.data)) {
|
|
3757
3780
|
if (this.isApiErrorArray(errorInfo.data.errors)) {
|
|
3758
3781
|
return {
|
|
3759
|
-
message:
|
|
3782
|
+
message: errorMessage2,
|
|
3760
3783
|
errors: errorInfo.data.errors
|
|
3761
3784
|
};
|
|
3762
3785
|
} else {
|
|
3763
3786
|
return {
|
|
3764
|
-
message:
|
|
3787
|
+
message: errorMessage2,
|
|
3765
3788
|
errors: errorInfo.data.errors.map((e) => ({
|
|
3766
3789
|
status: errorInfo.status,
|
|
3767
3790
|
code: String(errorInfo.status),
|
|
@@ -3771,7 +3794,7 @@ var ZapierApiClient = class {
|
|
|
3771
3794
|
};
|
|
3772
3795
|
}
|
|
3773
3796
|
}
|
|
3774
|
-
return { message:
|
|
3797
|
+
return { message: errorMessage2 };
|
|
3775
3798
|
} catch {
|
|
3776
3799
|
return { message: fallbackMessage };
|
|
3777
3800
|
}
|
|
@@ -4111,7 +4134,11 @@ var createZapierApi = (options) => {
|
|
|
4111
4134
|
|
|
4112
4135
|
// src/api/error-classification.ts
|
|
4113
4136
|
function isPermanentHttpError(err) {
|
|
4114
|
-
|
|
4137
|
+
if (!(err instanceof ZapierError)) return false;
|
|
4138
|
+
if (err instanceof ZapierAuthenticationError && err.statusCode === void 0) {
|
|
4139
|
+
return true;
|
|
4140
|
+
}
|
|
4141
|
+
const { statusCode } = err;
|
|
4115
4142
|
return statusCode !== void 0 && statusCode >= 400 && statusCode < 500 && statusCode !== 429;
|
|
4116
4143
|
}
|
|
4117
4144
|
|
|
@@ -6099,11 +6126,11 @@ var runActionPlugin = definePlugin(
|
|
|
6099
6126
|
timeoutMs
|
|
6100
6127
|
});
|
|
6101
6128
|
if (result.errors && result.errors.length > 0) {
|
|
6102
|
-
const
|
|
6129
|
+
const errorMessage2 = result.errors.map(
|
|
6103
6130
|
(error) => error.detail || error.title || "Unknown error"
|
|
6104
6131
|
).join("; ");
|
|
6105
6132
|
throw new ZapierActionError(
|
|
6106
|
-
`Action execution failed: ${
|
|
6133
|
+
`Action execution failed: ${errorMessage2}`,
|
|
6107
6134
|
{ appKey, actionKey }
|
|
6108
6135
|
);
|
|
6109
6136
|
}
|
|
@@ -9277,10 +9304,10 @@ var eventEmissionPlugin = definePlugin(
|
|
|
9277
9304
|
registeredListeners.uncaughtException = uncaughtExceptionHandler;
|
|
9278
9305
|
globalThis.process.on("uncaughtException", uncaughtExceptionHandler);
|
|
9279
9306
|
const unhandledRejectionHandler = async (reason, promise) => {
|
|
9280
|
-
const
|
|
9307
|
+
const errorMessage2 = reason instanceof Error ? reason.message : typeof reason === "string" ? reason : "Unhandled promise rejection";
|
|
9281
9308
|
const errorStack = reason instanceof Error ? reason.stack : null;
|
|
9282
9309
|
let errorEvent = buildErrorEventWithContext({
|
|
9283
|
-
error_message:
|
|
9310
|
+
error_message: errorMessage2,
|
|
9284
9311
|
error_type: "UnhandledRejection",
|
|
9285
9312
|
error_stack_trace: errorStack,
|
|
9286
9313
|
error_severity: "critical",
|
|
@@ -10467,6 +10494,16 @@ async function runBatchedDrainPipeline(options) {
|
|
|
10467
10494
|
}
|
|
10468
10495
|
|
|
10469
10496
|
// src/plugins/triggers/drainTriggerInbox/index.ts
|
|
10497
|
+
var nonRetryableDrainErrors = /* @__PURE__ */ new WeakSet();
|
|
10498
|
+
function markNonRetryableDrainError(err) {
|
|
10499
|
+
if (typeof err === "object" && err !== null) {
|
|
10500
|
+
nonRetryableDrainErrors.add(err);
|
|
10501
|
+
}
|
|
10502
|
+
return err;
|
|
10503
|
+
}
|
|
10504
|
+
function isNonRetryableDrainError(err) {
|
|
10505
|
+
return typeof err === "object" && err !== null && nonRetryableDrainErrors.has(err);
|
|
10506
|
+
}
|
|
10470
10507
|
function isLeaseExpiredError(err) {
|
|
10471
10508
|
if (!(err instanceof ZapierValidationError)) return false;
|
|
10472
10509
|
return err.errors?.some((e) => e.code === "lease_expired") ?? false;
|
|
@@ -10487,6 +10524,7 @@ async function runDrainPass(options) {
|
|
|
10487
10524
|
} = options;
|
|
10488
10525
|
let firstFetch = options.firstFetch;
|
|
10489
10526
|
let abortedFromCallback = false;
|
|
10527
|
+
let handlerErrorCaptured = false;
|
|
10490
10528
|
let firstHandlerError = void 0;
|
|
10491
10529
|
const outcomes = await runBatchedDrainPipeline({
|
|
10492
10530
|
concurrency,
|
|
@@ -10508,8 +10546,10 @@ async function runDrainPass(options) {
|
|
|
10508
10546
|
}
|
|
10509
10547
|
if (lease.results.length === 0) {
|
|
10510
10548
|
if (firstFetch && lease.inbox_attributes.status === "initialization_failure") {
|
|
10511
|
-
throw
|
|
10512
|
-
|
|
10549
|
+
throw markNonRetryableDrainError(
|
|
10550
|
+
new ZapierApiError(
|
|
10551
|
+
`Trigger inbox ${inboxId} is in initialization_failure state \u2014 inspect via getTriggerInbox.`
|
|
10552
|
+
)
|
|
10513
10553
|
);
|
|
10514
10554
|
}
|
|
10515
10555
|
firstFetch = false;
|
|
@@ -10549,7 +10589,10 @@ async function runDrainPass(options) {
|
|
|
10549
10589
|
}
|
|
10550
10590
|
}
|
|
10551
10591
|
if (!continueOnError && !(err instanceof ZapierSignal)) {
|
|
10552
|
-
if (
|
|
10592
|
+
if (!handlerErrorCaptured) {
|
|
10593
|
+
firstHandlerError = err;
|
|
10594
|
+
handlerErrorCaptured = true;
|
|
10595
|
+
}
|
|
10553
10596
|
abort = true;
|
|
10554
10597
|
}
|
|
10555
10598
|
return { value: message, action, abort };
|
|
@@ -10578,7 +10621,9 @@ async function runDrainPass(options) {
|
|
|
10578
10621
|
}
|
|
10579
10622
|
}
|
|
10580
10623
|
});
|
|
10581
|
-
if (
|
|
10624
|
+
if (handlerErrorCaptured) {
|
|
10625
|
+
throw markNonRetryableDrainError(firstHandlerError);
|
|
10626
|
+
}
|
|
10582
10627
|
return { abortedFromCallback, processed: outcomes.length };
|
|
10583
10628
|
}
|
|
10584
10629
|
function requireOnMessage(onMessage) {
|
|
@@ -10652,16 +10697,12 @@ async function* readInboxEvents({
|
|
|
10652
10697
|
signal,
|
|
10653
10698
|
onOpen
|
|
10654
10699
|
}) {
|
|
10655
|
-
for await (const message of api.
|
|
10700
|
+
for await (const message of api.fetchJsonStream(
|
|
10656
10701
|
`/trigger-inbox/api/v1/inboxes/${encodeURIComponent(inboxId)}/events`,
|
|
10657
10702
|
{ method: "GET", signal, authRequired: true, onOpen }
|
|
10658
10703
|
)) {
|
|
10659
|
-
|
|
10660
|
-
|
|
10661
|
-
parsed = JSON.parse(message.data);
|
|
10662
|
-
} catch {
|
|
10663
|
-
continue;
|
|
10664
|
-
}
|
|
10704
|
+
if (!message.parsed) continue;
|
|
10705
|
+
const parsed = message.data;
|
|
10665
10706
|
if (typeof parsed === "object" && parsed !== null && typeof parsed.inbox_id === "string" && // Only wake on a frame for this inbox. Case-insensitive: the endpoint
|
|
10666
10707
|
// echoes the canonical lowercase UUID, but resolveTriggerInboxId passes
|
|
10667
10708
|
// a UUID-shaped `inbox` through unchanged, so its casing may differ.
|
|
@@ -10675,6 +10716,7 @@ async function* readInboxEvents({
|
|
|
10675
10716
|
var SSE_RECONNECT_BACKOFF_MS = [500, 1e3, 2e3, 5e3];
|
|
10676
10717
|
var DEFAULT_SAFETY_DRAIN_INTERVAL_MS = 3e5;
|
|
10677
10718
|
var SSE_HEALTHY_CONNECTION_MS = 5e3;
|
|
10719
|
+
var ERROR_BACKOFF_CAP = 4;
|
|
10678
10720
|
function createDrainLatch() {
|
|
10679
10721
|
let pending = false;
|
|
10680
10722
|
const make = () => {
|
|
@@ -10705,9 +10747,14 @@ function createDrainLatch() {
|
|
|
10705
10747
|
async function drainRunner({
|
|
10706
10748
|
drainOptions,
|
|
10707
10749
|
drainRequest,
|
|
10708
|
-
signal
|
|
10750
|
+
signal,
|
|
10751
|
+
inboxId,
|
|
10752
|
+
debug
|
|
10709
10753
|
}) {
|
|
10710
10754
|
let firstFetch = true;
|
|
10755
|
+
let consecutiveErrors = 0;
|
|
10756
|
+
let errorAttempts = 0;
|
|
10757
|
+
let drainDegraded = false;
|
|
10711
10758
|
while (!signal.aborted) {
|
|
10712
10759
|
await drainRequest.waitForRequest();
|
|
10713
10760
|
if (signal.aborted) return { kind: "aborted" };
|
|
@@ -10718,17 +10765,47 @@ async function drainRunner({
|
|
|
10718
10765
|
firstFetch
|
|
10719
10766
|
}));
|
|
10720
10767
|
} catch (error) {
|
|
10721
|
-
return { kind: "
|
|
10768
|
+
if (signal.aborted) return { kind: "aborted" };
|
|
10769
|
+
const isNonObjectThrow = typeof error !== "object" || error === null;
|
|
10770
|
+
if (isNonObjectThrow || isNonRetryableDrainError(error) || isPermanentHttpError(error)) {
|
|
10771
|
+
return { kind: "error", error };
|
|
10772
|
+
}
|
|
10773
|
+
consecutiveErrors = Math.min(consecutiveErrors + 1, ERROR_BACKOFF_CAP);
|
|
10774
|
+
errorAttempts += 1;
|
|
10775
|
+
const delay = calculateErrorBackoffMs(
|
|
10776
|
+
BASE_ERROR_BACKOFF_MS,
|
|
10777
|
+
consecutiveErrors
|
|
10778
|
+
);
|
|
10779
|
+
const statusCode = errorStatusCode(error);
|
|
10780
|
+
const httpPart = statusCode !== void 0 ? ` (HTTP ${statusCode})` : "";
|
|
10781
|
+
if (!drainDegraded && consecutiveErrors >= ERROR_BACKOFF_CAP) {
|
|
10782
|
+
console.warn(
|
|
10783
|
+
`[zapier-sdk] Draining inbox ${inboxId}${httpPart} is failing repeatedly: ${errorMessage(error)}. Continuing to retry with backoff.`
|
|
10784
|
+
);
|
|
10785
|
+
drainDegraded = true;
|
|
10786
|
+
}
|
|
10787
|
+
if (debug) {
|
|
10788
|
+
console.error(
|
|
10789
|
+
`[zapier-sdk] Retrying drain for inbox ${inboxId} (attempt ${errorAttempts}, retry in ${delay}ms)${httpPart}: ${errorMessage(error)}`
|
|
10790
|
+
);
|
|
10791
|
+
}
|
|
10792
|
+
await sleep(delay, signal);
|
|
10793
|
+
if (signal.aborted) return { kind: "aborted" };
|
|
10794
|
+
drainRequest.request();
|
|
10795
|
+
continue;
|
|
10722
10796
|
}
|
|
10723
10797
|
firstFetch = false;
|
|
10798
|
+
consecutiveErrors = 0;
|
|
10799
|
+
errorAttempts = 0;
|
|
10800
|
+
drainDegraded = false;
|
|
10724
10801
|
if (abortedFromCallback) return { kind: "abortedFromCallback" };
|
|
10725
10802
|
}
|
|
10726
10803
|
return { kind: "aborted" };
|
|
10727
10804
|
}
|
|
10728
|
-
function
|
|
10805
|
+
function errorStatusCode(err) {
|
|
10729
10806
|
return err instanceof ZapierError ? err.statusCode : void 0;
|
|
10730
10807
|
}
|
|
10731
|
-
function
|
|
10808
|
+
function errorMessage(err) {
|
|
10732
10809
|
return err instanceof Error ? err.message : String(err);
|
|
10733
10810
|
}
|
|
10734
10811
|
async function sseLoop({
|
|
@@ -10769,8 +10846,8 @@ async function sseLoop({
|
|
|
10769
10846
|
if (signal.aborted || isAbortError(err)) return;
|
|
10770
10847
|
if (isPermanentHttpError(err)) {
|
|
10771
10848
|
if (!degraded) {
|
|
10772
|
-
const statusCode =
|
|
10773
|
-
const errorMsg =
|
|
10849
|
+
const statusCode = errorStatusCode(err);
|
|
10850
|
+
const errorMsg = errorMessage(err);
|
|
10774
10851
|
const httpPart = statusCode !== void 0 ? ` (HTTP ${statusCode})` : "";
|
|
10775
10852
|
console.warn(
|
|
10776
10853
|
`[zapier-sdk] Real-time wake-ups for inbox ${inboxId}${httpPart} paused: ${errorMsg}. Falling back to the periodic safety drain.`
|
|
@@ -10789,8 +10866,8 @@ async function sseLoop({
|
|
|
10789
10866
|
const delay = SSE_RECONNECT_BACKOFF_MS[Math.min(attempt, SSE_RECONNECT_BACKOFF_MS.length - 1)];
|
|
10790
10867
|
attempt = Math.min(attempt + 1, SSE_RECONNECT_BACKOFF_MS.length - 1);
|
|
10791
10868
|
if (transientError !== void 0 && debug) {
|
|
10792
|
-
const statusCode =
|
|
10793
|
-
const errorMsg =
|
|
10869
|
+
const statusCode = errorStatusCode(transientError);
|
|
10870
|
+
const errorMsg = errorMessage(transientError);
|
|
10794
10871
|
const httpPart = statusCode !== void 0 ? ` (HTTP ${statusCode})` : "";
|
|
10795
10872
|
console.error(
|
|
10796
10873
|
`[zapier-sdk] Reconnecting real-time wake-ups for inbox ${inboxId} (attempt ${attempt}, retry in ${delay}ms)${httpPart}: ${errorMsg}`
|
|
@@ -10850,7 +10927,13 @@ var watchTriggerInboxPlugin = definePlugin(
|
|
|
10850
10927
|
signal
|
|
10851
10928
|
};
|
|
10852
10929
|
drainRequest.request();
|
|
10853
|
-
const runnerDone = drainRunner({
|
|
10930
|
+
const runnerDone = drainRunner({
|
|
10931
|
+
drainOptions,
|
|
10932
|
+
drainRequest,
|
|
10933
|
+
signal,
|
|
10934
|
+
inboxId,
|
|
10935
|
+
debug
|
|
10936
|
+
});
|
|
10854
10937
|
const sseDone = sseLoop({
|
|
10855
10938
|
api: sdk.context.api,
|
|
10856
10939
|
inboxId,
|
|
@@ -10883,7 +10966,7 @@ var watchTriggerInboxPlugin = definePlugin(
|
|
|
10883
10966
|
watchTriggerInbox: {
|
|
10884
10967
|
...triggersDefaults,
|
|
10885
10968
|
type: "create",
|
|
10886
|
-
description: "Continuously consume a trigger inbox: drain currently-available messages via onMessage, then subscribe to SSE notifications for new arrivals until aborted. A periodic safety drain runs every maxDrainIntervalSeconds (default: 300) to guarantee forward progress if SSE events are missed. Resolves cleanly on signal abort or ZapierAbortDrainSignal from a handler
|
|
10969
|
+
description: "Continuously consume a trigger inbox: drain currently-available messages via onMessage, then subscribe to SSE notifications for new arrivals until aborted. A periodic safety drain runs every maxDrainIntervalSeconds (default: 300) to guarantee forward progress if SSE events are missed. Resolves cleanly on signal abort or ZapierAbortDrainSignal from a handler. Transient drain failures (5xx, 429, network blips) retry indefinitely with bounded backoff until they succeed or the watch is aborted; it rejects on a fail-fast handler error, an initialization_failure, or a permanent HTTP error. Real-time wake-up health is reported on stderr: a warning when wake-ups pause and the watch falls back to the safety drain, plus (with debug) transient reconnect notices. Persistent drain failures likewise warn once on stderr while bounded-backoff retries continue.",
|
|
10887
10970
|
itemType: "void",
|
|
10888
10971
|
// See drainTriggerInbox: override the doc generator's default
|
|
10889
10972
|
// suffix so the rendered return type is Promise<void>, not
|