@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
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Streams the trigger inbox events endpoint and yields the notification frames
|
|
3
|
-
* for this inbox. The transport (SSE connection, parsing, reconnect-able
|
|
4
|
-
* mapping, abort/cleanup) lives in `api.
|
|
5
|
-
* URL and the `inbox_id` filter
|
|
3
|
+
* for this inbox. The transport (SSE connection, JSON parsing, reconnect-able
|
|
4
|
+
* error mapping, abort/cleanup) lives in `api.fetchJsonStream`; this only adds
|
|
5
|
+
* the inbox URL and the `inbox_id` filter, skipping any frame whose data was
|
|
6
|
+
* not valid JSON.
|
|
6
7
|
*
|
|
7
8
|
* `onOpen` fires once the connection is live (response ok, body present) and
|
|
8
9
|
* before the first frame. The endpoint is edge-triggered with no replay, so a
|
|
@@ -11,19 +12,16 @@
|
|
|
11
12
|
*
|
|
12
13
|
* The generator returns (without throwing) when the signal is aborted, when
|
|
13
14
|
* the server closes the connection (JWT expiry, clean shutdown), or when the
|
|
14
|
-
* body is empty. For a non-ok response `api.
|
|
15
|
-
* carrying the HTTP `statusCode`; `isPermanentHttpError`
|
|
16
|
-
* caller can tell permanent (4xx) failures from transient
|
|
15
|
+
* body is empty. For a non-ok response `api.fetchJsonStream` throws a
|
|
16
|
+
* `ZapierError` carrying the HTTP `statusCode`; `isPermanentHttpError`
|
|
17
|
+
* classifies it so the caller can tell permanent (4xx) failures from transient
|
|
18
|
+
* ones.
|
|
17
19
|
*/
|
|
18
20
|
export async function* readInboxEvents({ api, inboxId, signal, onOpen, }) {
|
|
19
|
-
for await (const message of api.
|
|
20
|
-
|
|
21
|
-
try {
|
|
22
|
-
parsed = JSON.parse(message.data);
|
|
23
|
-
}
|
|
24
|
-
catch {
|
|
21
|
+
for await (const message of api.fetchJsonStream(`/trigger-inbox/api/v1/inboxes/${encodeURIComponent(inboxId)}/events`, { method: "GET", signal, authRequired: true, onOpen })) {
|
|
22
|
+
if (!message.parsed)
|
|
25
23
|
continue;
|
|
26
|
-
|
|
24
|
+
const parsed = message.data;
|
|
27
25
|
if (typeof parsed === "object" &&
|
|
28
26
|
parsed !== null &&
|
|
29
27
|
typeof parsed.inbox_id === "string" &&
|