@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.
Files changed (36) hide show
  1. package/CHANGELOG.md +21 -0
  2. package/README.md +1 -1
  3. package/dist/api/client.d.ts.map +1 -1
  4. package/dist/api/client.js +10 -1
  5. package/dist/api/error-classification.d.ts +7 -0
  6. package/dist/api/error-classification.d.ts.map +1 -1
  7. package/dist/api/error-classification.js +15 -2
  8. package/dist/api/index.d.ts +1 -1
  9. package/dist/api/index.d.ts.map +1 -1
  10. package/dist/api/sse-parser.d.ts +34 -0
  11. package/dist/api/sse-parser.d.ts.map +1 -1
  12. package/dist/api/sse-parser.js +28 -0
  13. package/dist/api/types.d.ts +9 -1
  14. package/dist/api/types.d.ts.map +1 -1
  15. package/dist/auth.d.ts.map +1 -1
  16. package/dist/auth.js +2 -2
  17. package/dist/experimental.cjs +117 -34
  18. package/dist/experimental.d.mts +2 -2
  19. package/dist/experimental.mjs +117 -34
  20. package/dist/{index-DuFFW71E.d.mts → index-C0bQ5snd.d.mts} +33 -1
  21. package/dist/{index-DuFFW71E.d.ts → index-C0bQ5snd.d.ts} +33 -1
  22. package/dist/index.cjs +32 -5
  23. package/dist/index.d.mts +1 -1
  24. package/dist/index.d.ts +1 -1
  25. package/dist/index.d.ts.map +1 -1
  26. package/dist/index.mjs +32 -5
  27. package/dist/plugins/triggers/drainTriggerInbox/index.d.ts +4 -2
  28. package/dist/plugins/triggers/drainTriggerInbox/index.d.ts.map +1 -1
  29. package/dist/plugins/triggers/drainTriggerInbox/index.js +39 -6
  30. package/dist/plugins/triggers/watchTriggerInbox/index.d.ts +4 -2
  31. package/dist/plugins/triggers/watchTriggerInbox/index.d.ts.map +1 -1
  32. package/dist/plugins/triggers/watchTriggerInbox/index.js +100 -16
  33. package/dist/plugins/triggers/watchTriggerInbox/sse.d.ts +8 -6
  34. package/dist/plugins/triggers/watchTriggerInbox/sse.d.ts.map +1 -1
  35. package/dist/plugins/triggers/watchTriggerInbox/sse.js +11 -13
  36. 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 error
4
- * mapping, abort/cleanup) lives in `api.fetchStream`; this only adds the inbox
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.fetchStream` throws a `ZapierError`
15
- * carrying the HTTP `statusCode`; `isPermanentHttpError` classifies it so the
16
- * caller can tell permanent (4xx) failures from transient ones.
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.fetchStream(`/trigger-inbox/api/v1/inboxes/${encodeURIComponent(inboxId)}/events`, { method: "GET", signal, authRequired: true, onOpen })) {
20
- let parsed;
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" &&
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zapier/zapier-sdk",
3
- "version": "0.69.3",
3
+ "version": "0.70.0",
4
4
  "description": "Complete Zapier SDK - combines all Zapier SDK packages",
5
5
  "main": "dist/index.cjs",
6
6
  "module": "dist/index.mjs",