@zapier/zapier-sdk 0.70.4 → 0.71.1
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 +149 -31
- package/dist/api/approval-review-stream.d.ts +25 -0
- package/dist/api/approval-review-stream.d.ts.map +1 -0
- package/dist/api/approval-review-stream.js +104 -0
- package/dist/api/client.d.ts.map +1 -1
- package/dist/api/client.js +215 -27
- package/dist/api/types.d.ts +13 -3
- package/dist/api/types.d.ts.map +1 -1
- package/dist/constants.d.ts +1 -0
- package/dist/constants.d.ts.map +1 -1
- package/dist/constants.js +6 -0
- package/dist/experimental.cjs +602 -37
- package/dist/experimental.d.mts +88 -2
- package/dist/experimental.d.ts +90 -4
- package/dist/experimental.d.ts.map +1 -1
- package/dist/experimental.js +10 -0
- package/dist/experimental.mjs +602 -38
- package/dist/{index-BNaiNmM-.d.mts → index-B43uST61.d.mts} +181 -12
- package/dist/{index-BNaiNmM-.d.ts → index-B43uST61.d.ts} +181 -12
- package/dist/index.cjs +592 -32
- package/dist/index.d.mts +1 -1
- package/dist/index.mjs +592 -33
- package/dist/plugins/api/index.d.ts.map +1 -1
- package/dist/plugins/api/index.js +2 -1
- package/dist/plugins/codeSubstrate/createWorkflow/index.d.ts +1 -0
- package/dist/plugins/codeSubstrate/createWorkflow/index.d.ts.map +1 -1
- package/dist/plugins/codeSubstrate/createWorkflow/index.js +3 -2
- package/dist/plugins/codeSubstrate/createWorkflow/schemas.d.ts +1 -0
- package/dist/plugins/codeSubstrate/createWorkflow/schemas.d.ts.map +1 -1
- package/dist/plugins/codeSubstrate/createWorkflow/schemas.js +7 -1
- package/dist/plugins/codeSubstrate/deleteWorkflow/index.d.ts +1 -1
- package/dist/plugins/codeSubstrate/disableWorkflow/index.d.ts +1 -1
- package/dist/plugins/codeSubstrate/enableWorkflow/index.d.ts +1 -1
- package/dist/plugins/codeSubstrate/getDurableRun/schemas.d.ts +4 -4
- package/dist/plugins/codeSubstrate/getWorkflow/index.d.ts +2 -2
- package/dist/plugins/codeSubstrate/getWorkflow/schemas.d.ts +1 -1
- package/dist/plugins/codeSubstrate/getWorkflowRun/index.d.ts +1 -1
- package/dist/plugins/codeSubstrate/getWorkflowVersion/index.d.ts +1 -1
- package/dist/plugins/codeSubstrate/listWorkflowRuns/index.d.ts +1 -1
- package/dist/plugins/codeSubstrate/listWorkflowVersions/index.d.ts +1 -1
- package/dist/plugins/codeSubstrate/listWorkflows/index.d.ts +1 -1
- package/dist/plugins/codeSubstrate/listWorkflows/schemas.d.ts +2 -2
- package/dist/plugins/codeSubstrate/publishWorkflowVersion/index.d.ts +1 -1
- package/dist/plugins/codeSubstrate/runDurable/schemas.js +1 -1
- package/dist/plugins/codeSubstrate/shared-schemas.d.ts +2 -2
- package/dist/plugins/codeSubstrate/triggerWorkflow/index.d.ts +1 -1
- package/dist/plugins/codeSubstrate/updateWorkflow/index.d.ts +1 -1
- package/dist/plugins/createConnection/index.d.ts +189 -0
- package/dist/plugins/createConnection/index.d.ts.map +1 -0
- package/dist/plugins/createConnection/index.js +71 -0
- package/dist/plugins/createConnection/schemas.d.ts +21 -0
- package/dist/plugins/createConnection/schemas.d.ts.map +1 -0
- package/dist/plugins/createConnection/schemas.js +38 -0
- package/dist/plugins/getConnectionStartUrl/index.d.ts +206 -0
- package/dist/plugins/getConnectionStartUrl/index.d.ts.map +1 -0
- package/dist/plugins/getConnectionStartUrl/index.js +39 -0
- package/dist/plugins/getConnectionStartUrl/schemas.d.ts +15 -0
- package/dist/plugins/getConnectionStartUrl/schemas.d.ts.map +1 -0
- package/dist/plugins/getConnectionStartUrl/schemas.js +23 -0
- package/dist/plugins/waitForNewConnection/index.d.ts +209 -0
- package/dist/plugins/waitForNewConnection/index.d.ts.map +1 -0
- package/dist/plugins/waitForNewConnection/index.js +75 -0
- package/dist/plugins/waitForNewConnection/schemas.d.ts +17 -0
- package/dist/plugins/waitForNewConnection/schemas.d.ts.map +1 -0
- package/dist/plugins/waitForNewConnection/schemas.js +39 -0
- package/dist/sdk.d.ts +126 -0
- package/dist/sdk.d.ts.map +1 -1
- package/dist/sdk.js +8 -0
- package/dist/types/errors.d.ts +13 -4
- package/dist/types/errors.d.ts.map +1 -1
- package/dist/types/errors.js +2 -0
- package/dist/types/sdk.d.ts +1 -0
- package/dist/types/sdk.d.ts.map +1 -1
- package/dist/types/sdk.js +5 -1
- package/dist/utils/open-url.d.ts.map +1 -1
- package/dist/utils/open-url.js +7 -0
- package/dist/utils/should-open-browser.d.ts +24 -0
- package/dist/utils/should-open-browser.d.ts.map +1 -0
- package/dist/utils/should-open-browser.js +55 -0
- package/package.json +1 -1
package/dist/api/client.js
CHANGED
|
@@ -14,21 +14,47 @@ 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
16
|
import { createSseParserStream, jsonFrames, } from "./sse-parser";
|
|
17
|
+
import { consumeApprovalReviewStream } from "./approval-review-stream";
|
|
17
18
|
import { ZapierApiError, ZapierApprovalError, ZapierAuthenticationError, ZapierConfigurationError, ZapierTimeoutError, ZapierValidationError, ZapierResourceNotFoundError, ZapierRateLimitError, } from "../types/errors";
|
|
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
|
+
import { MAX_CONCURRENCY_LIMIT, ZAPIER_MAX_CONCURRENT_REQUESTS, ZAPIER_MAX_NETWORK_RETRIES, ZAPIER_MAX_NETWORK_RETRY_DELAY_MS, getZapierApprovalMode, getZapierDefaultApprovalMode, getZapierOpenAutoModeApprovalsInBrowser, getZapierSdkService, DEFAULT_APPROVAL_TIMEOUT_MS, DEFAULT_MAX_APPROVAL_RETRIES, } from "../constants";
|
|
19
20
|
import { SDK_VERSION } from "../sdk-version";
|
|
20
21
|
import { openApproval } from "../utils/open-approval";
|
|
21
22
|
import { z } from "zod";
|
|
22
|
-
const ApprovalStatusSchema = z.enum([
|
|
23
|
-
|
|
23
|
+
const ApprovalStatusSchema = z.enum([
|
|
24
|
+
"pending_approval",
|
|
25
|
+
"approved",
|
|
26
|
+
"denied",
|
|
27
|
+
"failed",
|
|
28
|
+
]);
|
|
29
|
+
const ApprovalModeSchema = z.enum(["manual", "auto"]);
|
|
30
|
+
const CreateApprovalResponseSchema = z
|
|
31
|
+
.object({
|
|
32
|
+
id: z.string().optional(),
|
|
24
33
|
status: ApprovalStatusSchema,
|
|
25
|
-
approval_id: z.string(),
|
|
34
|
+
approval_id: z.string().optional(),
|
|
35
|
+
mode: ApprovalModeSchema,
|
|
26
36
|
approval_url: z.string().url(),
|
|
27
37
|
poll_url: z.string().url(),
|
|
38
|
+
stream_url: z.string().url().optional(),
|
|
39
|
+
reason: z.string().optional(),
|
|
40
|
+
})
|
|
41
|
+
.transform((approval, ctx) => {
|
|
42
|
+
const id = approval.id ?? approval.approval_id;
|
|
43
|
+
if (!id) {
|
|
44
|
+
ctx.addIssue({
|
|
45
|
+
code: "custom",
|
|
46
|
+
message: "Approval response must include id",
|
|
47
|
+
});
|
|
48
|
+
return z.NEVER;
|
|
49
|
+
}
|
|
50
|
+
return { ...approval, id };
|
|
28
51
|
});
|
|
29
52
|
const PollApprovalResponseSchema = z.object({
|
|
53
|
+
id: z.string().optional(),
|
|
30
54
|
status: ApprovalStatusSchema,
|
|
31
|
-
approval_id: z.string(),
|
|
55
|
+
approval_id: z.string().optional(),
|
|
56
|
+
mode: ApprovalModeSchema.optional(),
|
|
57
|
+
reason: z.string().optional(),
|
|
32
58
|
});
|
|
33
59
|
const APPROVAL_MAX_POLLING_INTERVAL_MS = 5000;
|
|
34
60
|
/**
|
|
@@ -341,7 +367,7 @@ class ZapierApiClient {
|
|
|
341
367
|
// attached (throw mode), and wait for terminal resolution. Returns only
|
|
342
368
|
// on "approved" — every other outcome throws from inside the helper.
|
|
343
369
|
// On return, loop back to retry the original request.
|
|
344
|
-
await this.runOneApprovalRound(init.approvalContext, mode);
|
|
370
|
+
await this.runOneApprovalRound(init.approvalContext, mode, init.signal ?? undefined);
|
|
345
371
|
}
|
|
346
372
|
// Only reachable when the final attempt returned `approval_required`
|
|
347
373
|
// (see the `break` above). Every other terminal outcome throws inline.
|
|
@@ -368,6 +394,7 @@ class ZapierApiClient {
|
|
|
368
394
|
* any frame), so transport / auth failures surface as usual.
|
|
369
395
|
*/
|
|
370
396
|
this.fetchJsonStream = (path, init) => jsonFrames(this.fetchStream(path, init));
|
|
397
|
+
this.streamTrustedJsonUrl = (url, init) => jsonFrames(this.streamTrustedSseUrl(url, init));
|
|
371
398
|
this.get = async (path, options = {}) => {
|
|
372
399
|
return this.fetchJson("GET", path, undefined, options);
|
|
373
400
|
};
|
|
@@ -776,7 +803,7 @@ class ZapierApiClient {
|
|
|
776
803
|
// bound `fetchStream` arrow above for parity with the other client methods.
|
|
777
804
|
async *streamSse(path, init) {
|
|
778
805
|
const { onOpen, headers: initHeaders, ...fetchInit } = init ?? {};
|
|
779
|
-
const signal = fetchInit.signal;
|
|
806
|
+
const signal = fetchInit.signal ?? undefined;
|
|
780
807
|
if (signal?.aborted)
|
|
781
808
|
return;
|
|
782
809
|
// Mirror fetchJson: when auth was required but no token resolved, a 401/403
|
|
@@ -804,6 +831,51 @@ class ZapierApiClient {
|
|
|
804
831
|
return;
|
|
805
832
|
throw err;
|
|
806
833
|
}
|
|
834
|
+
yield* this.readSseResponse({
|
|
835
|
+
response,
|
|
836
|
+
signal,
|
|
837
|
+
onOpen,
|
|
838
|
+
wasMissingAuthToken,
|
|
839
|
+
requiredScopes: fetchInit.requiredScopes,
|
|
840
|
+
});
|
|
841
|
+
}
|
|
842
|
+
// Approval `stream_url` is server-supplied and origin-pinned before use, like
|
|
843
|
+
// `poll_url`; keep absolute-URL streaming private rather than widening the
|
|
844
|
+
// public path-based `fetchStream` API.
|
|
845
|
+
async *streamTrustedSseUrl(url, init) {
|
|
846
|
+
const { onOpen, headers: initHeaders, ...fetchInit } = init ?? {};
|
|
847
|
+
const signal = fetchInit.signal ?? undefined;
|
|
848
|
+
if (signal?.aborted)
|
|
849
|
+
return;
|
|
850
|
+
const wasMissingAuthToken = fetchInit.authRequired === true &&
|
|
851
|
+
(await this.getAuthToken({
|
|
852
|
+
requiredScopes: fetchInit.requiredScopes,
|
|
853
|
+
})) == null;
|
|
854
|
+
const headers = new Headers(initHeaders);
|
|
855
|
+
if (!headers.has("Accept"))
|
|
856
|
+
headers.set("Accept", "text/event-stream");
|
|
857
|
+
let response;
|
|
858
|
+
try {
|
|
859
|
+
response = await this.withSemaphore({ url, method: fetchInit.method ?? "GET", signal }, () => this.rawFetchUrl(url, {
|
|
860
|
+
...fetchInit,
|
|
861
|
+
method: fetchInit.method ?? "GET",
|
|
862
|
+
headers,
|
|
863
|
+
}));
|
|
864
|
+
}
|
|
865
|
+
catch (err) {
|
|
866
|
+
if (signal?.aborted || isAbortError(err))
|
|
867
|
+
return;
|
|
868
|
+
throw err;
|
|
869
|
+
}
|
|
870
|
+
yield* this.readSseResponse({
|
|
871
|
+
response,
|
|
872
|
+
signal,
|
|
873
|
+
onOpen,
|
|
874
|
+
wasMissingAuthToken,
|
|
875
|
+
requiredScopes: fetchInit.requiredScopes,
|
|
876
|
+
});
|
|
877
|
+
}
|
|
878
|
+
async *readSseResponse({ response, signal, onOpen, wasMissingAuthToken, requiredScopes, }) {
|
|
807
879
|
if (!response.ok) {
|
|
808
880
|
// Parse the error body only on this non-ok branch — reading it on the ok
|
|
809
881
|
// path would consume the stream. Map it exactly like the JSON path does.
|
|
@@ -812,7 +884,7 @@ class ZapierApiClient {
|
|
|
812
884
|
response,
|
|
813
885
|
responseData: data,
|
|
814
886
|
wasMissingAuthToken,
|
|
815
|
-
requiredScopes
|
|
887
|
+
requiredScopes,
|
|
816
888
|
});
|
|
817
889
|
}
|
|
818
890
|
if (!response.body)
|
|
@@ -853,12 +925,12 @@ class ZapierApiClient {
|
|
|
853
925
|
/**
|
|
854
926
|
* Run a single approval round: create the approval, open the URL (poll mode)
|
|
855
927
|
* or throw (throw mode), poll until resolved, and emit events. Throws on
|
|
856
|
-
* denied/timeout/unexpected status. Returns on approved.
|
|
928
|
+
* denied/failed/timeout/unexpected status. Returns on approved.
|
|
857
929
|
*
|
|
858
930
|
* Caller is responsible for passing a non-"disabled" mode; this method
|
|
859
931
|
* unconditionally creates an approval.
|
|
860
932
|
*/
|
|
861
|
-
async runOneApprovalRound(buildContext, mode) {
|
|
933
|
+
async runOneApprovalRound(buildContext, mode, signal) {
|
|
862
934
|
const context = buildContext();
|
|
863
935
|
// Route through rawFetch so the approval POST shares auth + 429 retry.
|
|
864
936
|
let approvalResponse;
|
|
@@ -870,9 +942,12 @@ class ZapierApiClient {
|
|
|
870
942
|
Accept: "application/json",
|
|
871
943
|
},
|
|
872
944
|
body: JSON.stringify({ context }),
|
|
945
|
+
signal,
|
|
873
946
|
});
|
|
874
947
|
}
|
|
875
948
|
catch (err) {
|
|
949
|
+
if (isAbortError(err))
|
|
950
|
+
throw err;
|
|
876
951
|
throw new ZapierApiError("Failed to create approval request", {
|
|
877
952
|
statusCode: 0,
|
|
878
953
|
cause: err,
|
|
@@ -931,23 +1006,89 @@ class ZapierApiClient {
|
|
|
931
1006
|
// the dev owns every service on the machine.
|
|
932
1007
|
if (!isLocalhostBaseUrl(this.options.baseUrl)) {
|
|
933
1008
|
assertApprovalOrigin(approval.poll_url, sdkapiOrigin, "poll_url");
|
|
1009
|
+
if (approval.stream_url) {
|
|
1010
|
+
assertApprovalOrigin(approval.stream_url, sdkapiOrigin, "stream_url");
|
|
1011
|
+
}
|
|
934
1012
|
assertApprovalOrigin(approval.approval_url, browserOrigin, "approval_url");
|
|
935
1013
|
}
|
|
936
1014
|
this.emitEvent("approval:required", {
|
|
937
|
-
approvalId: approval.
|
|
1015
|
+
approvalId: approval.id,
|
|
938
1016
|
approvalUrl: approval.approval_url,
|
|
1017
|
+
mode: approval.mode,
|
|
1018
|
+
...(approval.stream_url ? { streamUrl: approval.stream_url } : {}),
|
|
939
1019
|
});
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
}
|
|
1020
|
+
const shouldOpenAutoModeApproval = this.options.openAutoModeApprovalsInBrowser ??
|
|
1021
|
+
getZapierOpenAutoModeApprovalsInBrowser() ??
|
|
1022
|
+
false;
|
|
1023
|
+
if (approval.mode === "auto") {
|
|
1024
|
+
if (shouldOpenAutoModeApproval) {
|
|
1025
|
+
await openApproval(approval.approval_url);
|
|
1026
|
+
}
|
|
1027
|
+
if (approval.status === "approved") {
|
|
1028
|
+
this.emitEvent("approval:approved", {
|
|
1029
|
+
approvalId: approval.id,
|
|
1030
|
+
});
|
|
1031
|
+
return;
|
|
1032
|
+
}
|
|
1033
|
+
if (approval.status === "denied") {
|
|
1034
|
+
this.emitEvent("approval:denied", {
|
|
1035
|
+
approvalId: approval.id,
|
|
1036
|
+
...(approval.reason ? { reason: approval.reason } : {}),
|
|
1037
|
+
});
|
|
1038
|
+
throw new ZapierApprovalError(approval.reason
|
|
1039
|
+
? `Request denied: ${approval.reason}`
|
|
1040
|
+
: "Request denied by user", {
|
|
1041
|
+
approvalId: approval.id,
|
|
1042
|
+
status: "denied",
|
|
1043
|
+
reason: approval.reason,
|
|
1044
|
+
});
|
|
1045
|
+
}
|
|
1046
|
+
if (approval.status === "failed") {
|
|
1047
|
+
this.throwApprovalFailed({
|
|
1048
|
+
approvalId: approval.id,
|
|
1049
|
+
approvalUrl: approval.approval_url,
|
|
1050
|
+
pollUrl: approval.poll_url,
|
|
1051
|
+
streamUrl: approval.stream_url,
|
|
1052
|
+
reason: approval.reason,
|
|
1053
|
+
});
|
|
1054
|
+
}
|
|
1055
|
+
}
|
|
1056
|
+
else {
|
|
1057
|
+
if (mode === "throw") {
|
|
1058
|
+
throw new ZapierApprovalError("This request requires approval.", {
|
|
1059
|
+
approvalId: approval.id,
|
|
1060
|
+
approvalUrl: approval.approval_url,
|
|
1061
|
+
pollUrl: approval.poll_url,
|
|
1062
|
+
streamUrl: approval.stream_url,
|
|
1063
|
+
status: "pending",
|
|
1064
|
+
});
|
|
1065
|
+
}
|
|
1066
|
+
// mode === "poll", manual approval — open browser and poll
|
|
1067
|
+
await openApproval(approval.approval_url);
|
|
947
1068
|
}
|
|
948
|
-
// mode === "poll" — open browser and poll
|
|
949
|
-
await openApproval(approval.approval_url);
|
|
950
1069
|
const timeoutMs = this.options.approvalTimeoutMs ?? DEFAULT_APPROVAL_TIMEOUT_MS;
|
|
1070
|
+
let streamAbortController;
|
|
1071
|
+
let streamPromise;
|
|
1072
|
+
let removeStreamAbortListener;
|
|
1073
|
+
if (approval.mode === "auto" && approval.stream_url) {
|
|
1074
|
+
const streamUrl = approval.stream_url;
|
|
1075
|
+
streamAbortController = new AbortController();
|
|
1076
|
+
const abortStream = () => streamAbortController?.abort();
|
|
1077
|
+
if (signal?.aborted) {
|
|
1078
|
+
abortStream();
|
|
1079
|
+
}
|
|
1080
|
+
else if (signal) {
|
|
1081
|
+
signal.addEventListener("abort", abortStream, { once: true });
|
|
1082
|
+
removeStreamAbortListener = () => signal.removeEventListener("abort", abortStream);
|
|
1083
|
+
}
|
|
1084
|
+
streamPromise = consumeApprovalReviewStream({
|
|
1085
|
+
approvalId: approval.id,
|
|
1086
|
+
streamUrl,
|
|
1087
|
+
signal: streamAbortController.signal,
|
|
1088
|
+
stream: (url, streamInit) => this.streamTrustedJsonUrl(url, streamInit),
|
|
1089
|
+
emitEvent: (type, payload) => this.emitEvent(type, payload),
|
|
1090
|
+
});
|
|
1091
|
+
}
|
|
951
1092
|
let rawPollResult;
|
|
952
1093
|
try {
|
|
953
1094
|
rawPollResult = await pollUntilComplete({
|
|
@@ -957,12 +1098,14 @@ class ZapierApiClient {
|
|
|
957
1098
|
// Each individual poll request goes through the concurrency
|
|
958
1099
|
// semaphore — but we deliberately do not hold a slot across the
|
|
959
1100
|
// sleep between polls or across the human-approval wait.
|
|
960
|
-
fetchPoll: () => this.withSemaphore({ url: approval.poll_url, method: "GET" }, () => this.rawFetchUrl(approval.poll_url, {
|
|
1101
|
+
fetchPoll: () => this.withSemaphore({ url: approval.poll_url, method: "GET", signal }, () => this.rawFetchUrl(approval.poll_url, {
|
|
961
1102
|
method: "GET",
|
|
962
1103
|
headers: { Accept: "application/json" },
|
|
1104
|
+
signal,
|
|
963
1105
|
})),
|
|
964
1106
|
timeoutMs,
|
|
965
1107
|
maxPollingIntervalMs: APPROVAL_MAX_POLLING_INTERVAL_MS,
|
|
1108
|
+
signal,
|
|
966
1109
|
isPending: (body) => {
|
|
967
1110
|
const parsed = PollApprovalResponseSchema.safeParse(body);
|
|
968
1111
|
return parsed.success && parsed.data.status === "pending_approval";
|
|
@@ -971,24 +1114,38 @@ class ZapierApiClient {
|
|
|
971
1114
|
}
|
|
972
1115
|
catch (err) {
|
|
973
1116
|
if (!(err instanceof ZapierTimeoutError)) {
|
|
1117
|
+
this.emitEvent("approval:error", {
|
|
1118
|
+
approvalId: approval.id,
|
|
1119
|
+
message: err instanceof Error ? err.message : String(err),
|
|
1120
|
+
});
|
|
974
1121
|
throw err;
|
|
975
1122
|
}
|
|
976
1123
|
this.emitEvent("approval:timeout", {
|
|
977
|
-
approvalId: approval.
|
|
1124
|
+
approvalId: approval.id,
|
|
978
1125
|
});
|
|
979
1126
|
throw new ZapierApprovalError(`Approval timed out after ${timeoutMs / 1000} seconds`, {
|
|
980
|
-
approvalId: approval.
|
|
1127
|
+
approvalId: approval.id,
|
|
981
1128
|
approvalUrl: approval.approval_url,
|
|
982
1129
|
pollUrl: approval.poll_url,
|
|
1130
|
+
streamUrl: approval.stream_url,
|
|
983
1131
|
status: "timeout",
|
|
984
1132
|
cause: err,
|
|
985
1133
|
});
|
|
986
1134
|
}
|
|
1135
|
+
finally {
|
|
1136
|
+
removeStreamAbortListener?.();
|
|
1137
|
+
streamAbortController?.abort();
|
|
1138
|
+
await streamPromise;
|
|
1139
|
+
}
|
|
987
1140
|
const pollParse = PollApprovalResponseSchema.safeParse(rawPollResult);
|
|
988
1141
|
if (!pollParse.success) {
|
|
989
1142
|
const bodyPreview = typeof rawPollResult === "string"
|
|
990
1143
|
? rawPollResult
|
|
991
1144
|
: JSON.stringify(rawPollResult);
|
|
1145
|
+
this.emitEvent("approval:error", {
|
|
1146
|
+
approvalId: approval.id,
|
|
1147
|
+
message: `Failed to parse approval poll response: ${bodyPreview}`,
|
|
1148
|
+
});
|
|
992
1149
|
throw new ZapierApiError(`Failed to parse approval poll response: ${bodyPreview}`, {
|
|
993
1150
|
statusCode: 0,
|
|
994
1151
|
cause: pollParse.error,
|
|
@@ -998,18 +1155,49 @@ class ZapierApiClient {
|
|
|
998
1155
|
const pollResult = pollParse.data;
|
|
999
1156
|
if (pollResult.status === "denied") {
|
|
1000
1157
|
this.emitEvent("approval:denied", {
|
|
1001
|
-
approvalId: approval.
|
|
1158
|
+
approvalId: approval.id,
|
|
1159
|
+
...(pollResult.reason ? { reason: pollResult.reason } : {}),
|
|
1002
1160
|
});
|
|
1003
|
-
throw new ZapierApprovalError(
|
|
1004
|
-
|
|
1161
|
+
throw new ZapierApprovalError(pollResult.reason
|
|
1162
|
+
? `Request denied: ${pollResult.reason}`
|
|
1163
|
+
: "Request denied by user", {
|
|
1164
|
+
approvalId: approval.id,
|
|
1005
1165
|
status: "denied",
|
|
1166
|
+
reason: pollResult.reason,
|
|
1167
|
+
});
|
|
1168
|
+
}
|
|
1169
|
+
if (pollResult.status === "failed") {
|
|
1170
|
+
this.throwApprovalFailed({
|
|
1171
|
+
approvalId: approval.id,
|
|
1172
|
+
approvalUrl: approval.approval_url,
|
|
1173
|
+
pollUrl: approval.poll_url,
|
|
1174
|
+
streamUrl: approval.stream_url,
|
|
1175
|
+
reason: pollResult.reason,
|
|
1006
1176
|
});
|
|
1007
1177
|
}
|
|
1008
1178
|
if (pollResult.status !== "approved") {
|
|
1179
|
+
this.emitEvent("approval:error", {
|
|
1180
|
+
approvalId: approval.id,
|
|
1181
|
+
message: `Unexpected approval status received: ${pollResult.status}`,
|
|
1182
|
+
});
|
|
1009
1183
|
throw new ZapierApiError(`Unexpected approval status received: ${pollResult.status}`);
|
|
1010
1184
|
}
|
|
1011
1185
|
this.emitEvent("approval:approved", {
|
|
1012
|
-
approvalId: approval.
|
|
1186
|
+
approvalId: approval.id,
|
|
1187
|
+
});
|
|
1188
|
+
}
|
|
1189
|
+
throwApprovalFailed({ approvalId, approvalUrl, pollUrl, streamUrl, reason, }) {
|
|
1190
|
+
this.emitEvent("approval:failed", {
|
|
1191
|
+
approvalId,
|
|
1192
|
+
...(reason ? { reason } : {}),
|
|
1193
|
+
});
|
|
1194
|
+
throw new ZapierApprovalError(reason ? `Approval failed: ${reason}` : "Approval failed", {
|
|
1195
|
+
approvalId,
|
|
1196
|
+
approvalUrl,
|
|
1197
|
+
pollUrl,
|
|
1198
|
+
streamUrl,
|
|
1199
|
+
status: "failed",
|
|
1200
|
+
reason,
|
|
1013
1201
|
});
|
|
1014
1202
|
}
|
|
1015
1203
|
}
|
package/dist/api/types.d.ts
CHANGED
|
@@ -48,17 +48,27 @@ export interface ApiClientOptions {
|
|
|
48
48
|
*/
|
|
49
49
|
maxConcurrentRequests?: number;
|
|
50
50
|
/**
|
|
51
|
-
* Controls how
|
|
51
|
+
* Controls how manual approvals are handled.
|
|
52
52
|
* - "poll": Create the approval, open the URL in a browser, poll until
|
|
53
53
|
* resolved, and retry the original request on success.
|
|
54
|
-
* - "throw": Create the approval and throw a ZapierApprovalError
|
|
55
|
-
* with the approval URL so the caller can surface it.
|
|
54
|
+
* - "throw": Create the manual approval and throw a ZapierApprovalError
|
|
55
|
+
* immediately with the approval URL so the caller can surface it.
|
|
56
56
|
* - "disabled": Throw a ZapierApprovalError on approval-required responses
|
|
57
57
|
* without creating an approval.
|
|
58
|
+
* Server-created auto-mode approvals always poll until terminal resolution
|
|
59
|
+
* and retry the original request on success, even when this option is
|
|
60
|
+
* "throw".
|
|
58
61
|
* Resolution order is: explicit option, then ZAPIER_APPROVAL_MODE, then a
|
|
59
62
|
* TTY-based default ("poll" if interactive, "throw" otherwise).
|
|
60
63
|
*/
|
|
61
64
|
approvalMode?: "disabled" | "poll" | "throw";
|
|
65
|
+
/**
|
|
66
|
+
* By default, auto-mode approvals do not open in a browser. Enable this
|
|
67
|
+
* option to open the approval URL and watch the approval process.
|
|
68
|
+
* Resolution order is: explicit option, then
|
|
69
|
+
* ZAPIER_OPEN_AUTO_MODE_APPROVALS_IN_BROWSER, then false.
|
|
70
|
+
*/
|
|
71
|
+
openAutoModeApprovalsInBrowser?: boolean;
|
|
62
72
|
/**
|
|
63
73
|
* Timeout in ms for approval polling. Default: 600000 (10 minutes).
|
|
64
74
|
*/
|
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,KAAK,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AAC7D,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AAC5C,OAAO,KAAK,EAAE,UAAU,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAC/D,OAAO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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"}
|
package/dist/constants.d.ts
CHANGED
|
@@ -61,6 +61,7 @@ export declare const ZAPIER_MAX_CONCURRENT_REQUESTS: number;
|
|
|
61
61
|
* Read lazily so tests can set env vars after module import.
|
|
62
62
|
*/
|
|
63
63
|
export declare function getZapierApprovalMode(): "disabled" | "poll" | "throw" | undefined;
|
|
64
|
+
export declare function getZapierOpenAutoModeApprovalsInBrowser(): boolean | undefined;
|
|
64
65
|
/**
|
|
65
66
|
* Returns the default approval mode based on whether the process is running in
|
|
66
67
|
* an interactive terminal. If both stdin and stdout are TTYs the user can act
|
package/dist/constants.d.ts.map
CHANGED
|
@@ -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;;;;;GAKG;AACH,eAAO,MAAM,qBAAqB,QAAS,CAAC;AAE5C,wBAAgB,sBAAsB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OAAO,CAI/D;AAED;;GAEG;AACH,eAAO,MAAM,2BAA2B,QAAiB,CAAC;AAE1D;;;;;GAKG;AACH,eAAO,MAAM,4BAA4B,IAAI,CAAC"}
|
package/dist/constants.js
CHANGED
|
@@ -92,6 +92,12 @@ export function getZapierApprovalMode() {
|
|
|
92
92
|
return value;
|
|
93
93
|
return undefined;
|
|
94
94
|
}
|
|
95
|
+
export function getZapierOpenAutoModeApprovalsInBrowser() {
|
|
96
|
+
const value = globalThis.process?.env?.ZAPIER_OPEN_AUTO_MODE_APPROVALS_IN_BROWSER;
|
|
97
|
+
if (value === undefined)
|
|
98
|
+
return undefined;
|
|
99
|
+
return value === "true";
|
|
100
|
+
}
|
|
95
101
|
/**
|
|
96
102
|
* Returns the default approval mode based on whether the process is running in
|
|
97
103
|
* an interactive terminal. If both stdin and stdout are TTYs the user can act
|