@zapier/zapier-sdk 0.108.1 → 0.109.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 +10 -0
- package/dist/{chunk-S7XDZGKJ.mjs → chunk-6QN54DRD.mjs} +290 -234
- package/dist/{chunk-OS45HFVJ.cjs → chunk-BU4ANX6G.cjs} +289 -233
- package/dist/experimental.cjs +378 -378
- package/dist/experimental.d.mts +3 -3
- package/dist/experimental.d.ts +3 -3
- package/dist/experimental.mjs +2 -2
- package/dist/{index-BUYztqGh.d.mts → index-Cum18GPG.d.mts} +34 -35
- package/dist/{index-BUYztqGh.d.ts → index-Cum18GPG.d.ts} +34 -35
- package/dist/index.cjs +279 -279
- package/dist/index.d.mts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.mjs +1 -1
- package/package.json +1 -1
|
@@ -606,6 +606,83 @@ function extractUserIdsFromJwt(token) {
|
|
|
606
606
|
};
|
|
607
607
|
}
|
|
608
608
|
|
|
609
|
+
// src/api/concurrency.ts
|
|
610
|
+
var NO_OP_RELEASE = () => {
|
|
611
|
+
};
|
|
612
|
+
var NO_OP_SEMAPHORE = {
|
|
613
|
+
acquire: async () => NO_OP_RELEASE,
|
|
614
|
+
tryAcquire: () => NO_OP_RELEASE
|
|
615
|
+
};
|
|
616
|
+
function createSemaphore(maxPermits) {
|
|
617
|
+
if (maxPermits === Infinity) {
|
|
618
|
+
return NO_OP_SEMAPHORE;
|
|
619
|
+
}
|
|
620
|
+
if (!Number.isInteger(maxPermits) || maxPermits <= 0) {
|
|
621
|
+
throw new Error(
|
|
622
|
+
`maxPermits must be a positive integer or Infinity, got: ${maxPermits}`
|
|
623
|
+
);
|
|
624
|
+
}
|
|
625
|
+
let permits = maxPermits;
|
|
626
|
+
const waiters = [];
|
|
627
|
+
const release = () => {
|
|
628
|
+
const next = waiters.shift();
|
|
629
|
+
if (next) {
|
|
630
|
+
next.grant();
|
|
631
|
+
} else {
|
|
632
|
+
permits++;
|
|
633
|
+
}
|
|
634
|
+
};
|
|
635
|
+
const makeReleaseOnce = () => {
|
|
636
|
+
let released = false;
|
|
637
|
+
return () => {
|
|
638
|
+
if (released) return;
|
|
639
|
+
released = true;
|
|
640
|
+
release();
|
|
641
|
+
};
|
|
642
|
+
};
|
|
643
|
+
return {
|
|
644
|
+
tryAcquire() {
|
|
645
|
+
if (permits > 0) {
|
|
646
|
+
permits--;
|
|
647
|
+
return makeReleaseOnce();
|
|
648
|
+
}
|
|
649
|
+
return null;
|
|
650
|
+
},
|
|
651
|
+
async acquire(signal) {
|
|
652
|
+
if (signal?.aborted) {
|
|
653
|
+
throw signal.reason ?? new DOMException("Aborted", "AbortError");
|
|
654
|
+
}
|
|
655
|
+
if (permits > 0) {
|
|
656
|
+
permits--;
|
|
657
|
+
return makeReleaseOnce();
|
|
658
|
+
}
|
|
659
|
+
return new Promise((resolve2, reject) => {
|
|
660
|
+
const onAbort = () => {
|
|
661
|
+
const idx = waiters.indexOf(waiter);
|
|
662
|
+
if (idx !== -1) {
|
|
663
|
+
waiters.splice(idx, 1);
|
|
664
|
+
waiter.cancel(
|
|
665
|
+
signal?.reason ?? new DOMException("Aborted", "AbortError")
|
|
666
|
+
);
|
|
667
|
+
}
|
|
668
|
+
};
|
|
669
|
+
const waiter = {
|
|
670
|
+
grant: () => {
|
|
671
|
+
signal?.removeEventListener("abort", onAbort);
|
|
672
|
+
resolve2(makeReleaseOnce());
|
|
673
|
+
},
|
|
674
|
+
cancel: (reason) => {
|
|
675
|
+
signal?.removeEventListener("abort", onAbort);
|
|
676
|
+
reject(reason);
|
|
677
|
+
}
|
|
678
|
+
};
|
|
679
|
+
signal?.addEventListener("abort", onAbort);
|
|
680
|
+
waiters.push(waiter);
|
|
681
|
+
});
|
|
682
|
+
}
|
|
683
|
+
};
|
|
684
|
+
}
|
|
685
|
+
|
|
609
686
|
// src/api/debug.ts
|
|
610
687
|
var utilModule = null;
|
|
611
688
|
var utilPromise = null;
|
|
@@ -998,86 +1075,21 @@ async function pollUntilComplete(options) {
|
|
|
998
1075
|
}
|
|
999
1076
|
}
|
|
1000
1077
|
|
|
1001
|
-
// src/api/
|
|
1002
|
-
var
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
|
|
1009
|
-
|
|
1010
|
-
|
|
1011
|
-
|
|
1012
|
-
|
|
1013
|
-
|
|
1014
|
-
|
|
1015
|
-
);
|
|
1016
|
-
}
|
|
1017
|
-
let permits = maxPermits;
|
|
1018
|
-
const waiters = [];
|
|
1019
|
-
const release = () => {
|
|
1020
|
-
const next = waiters.shift();
|
|
1021
|
-
if (next) {
|
|
1022
|
-
next.grant();
|
|
1023
|
-
} else {
|
|
1024
|
-
permits++;
|
|
1025
|
-
}
|
|
1026
|
-
};
|
|
1027
|
-
const makeReleaseOnce = () => {
|
|
1028
|
-
let released = false;
|
|
1029
|
-
return () => {
|
|
1030
|
-
if (released) return;
|
|
1031
|
-
released = true;
|
|
1032
|
-
release();
|
|
1033
|
-
};
|
|
1034
|
-
};
|
|
1035
|
-
return {
|
|
1036
|
-
tryAcquire() {
|
|
1037
|
-
if (permits > 0) {
|
|
1038
|
-
permits--;
|
|
1039
|
-
return makeReleaseOnce();
|
|
1040
|
-
}
|
|
1041
|
-
return null;
|
|
1042
|
-
},
|
|
1043
|
-
async acquire(signal) {
|
|
1044
|
-
if (signal?.aborted) {
|
|
1045
|
-
throw signal.reason ?? new DOMException("Aborted", "AbortError");
|
|
1046
|
-
}
|
|
1047
|
-
if (permits > 0) {
|
|
1048
|
-
permits--;
|
|
1049
|
-
return makeReleaseOnce();
|
|
1050
|
-
}
|
|
1051
|
-
return new Promise((resolve2, reject) => {
|
|
1052
|
-
const onAbort = () => {
|
|
1053
|
-
const idx = waiters.indexOf(waiter);
|
|
1054
|
-
if (idx !== -1) {
|
|
1055
|
-
waiters.splice(idx, 1);
|
|
1056
|
-
waiter.cancel(
|
|
1057
|
-
signal?.reason ?? new DOMException("Aborted", "AbortError")
|
|
1058
|
-
);
|
|
1059
|
-
}
|
|
1060
|
-
};
|
|
1061
|
-
const waiter = {
|
|
1062
|
-
grant: () => {
|
|
1063
|
-
signal?.removeEventListener("abort", onAbort);
|
|
1064
|
-
resolve2(makeReleaseOnce());
|
|
1065
|
-
},
|
|
1066
|
-
cancel: (reason) => {
|
|
1067
|
-
signal?.removeEventListener("abort", onAbort);
|
|
1068
|
-
reject(reason);
|
|
1069
|
-
}
|
|
1070
|
-
};
|
|
1071
|
-
signal?.addEventListener("abort", onAbort);
|
|
1072
|
-
waiters.push(waiter);
|
|
1073
|
-
});
|
|
1074
|
-
}
|
|
1075
|
-
};
|
|
1078
|
+
// src/api/correlation.ts
|
|
1079
|
+
var CORRELATION_CALL_ID = Symbol(
|
|
1080
|
+
"zapier.correlationCallId"
|
|
1081
|
+
);
|
|
1082
|
+
function resolveCorrelationId({
|
|
1083
|
+
options,
|
|
1084
|
+
callId
|
|
1085
|
+
}) {
|
|
1086
|
+
return options?.correlationId || getZapierCorrelationId() || callId || void 0;
|
|
1087
|
+
}
|
|
1088
|
+
function resolveCausationId({
|
|
1089
|
+
options
|
|
1090
|
+
}) {
|
|
1091
|
+
return options?.causationId || getZapierCausationId();
|
|
1076
1092
|
}
|
|
1077
|
-
var SDK_OPTIONS_ID = "zapier/sdkOptions";
|
|
1078
|
-
var sdkOptionsPluginRef = kitcore.declareOptionalProperty({
|
|
1079
|
-
id: SDK_OPTIONS_ID
|
|
1080
|
-
});
|
|
1081
1093
|
|
|
1082
1094
|
// src/api/rate-limit.ts
|
|
1083
1095
|
var EPOCH_THRESHOLD_SECONDS = 1e9;
|
|
@@ -1163,99 +1175,6 @@ function createRetryObserver({
|
|
|
1163
1175
|
}
|
|
1164
1176
|
};
|
|
1165
1177
|
}
|
|
1166
|
-
|
|
1167
|
-
// src/plugins/transport/options.ts
|
|
1168
|
-
var RETRYABLE_STATUSES = [429, 500, 502, 503, 504];
|
|
1169
|
-
var NON_IDEMPOTENT_RETRYABLE_STATUSES = [429];
|
|
1170
|
-
function resolveRetryHttpRequestOptions({
|
|
1171
|
-
maxNetworkRetries,
|
|
1172
|
-
maxNetworkRetryDelayMilliseconds,
|
|
1173
|
-
onEvent
|
|
1174
|
-
}) {
|
|
1175
|
-
const retries = maxNetworkRetries ?? ZAPIER_MAX_NETWORK_RETRIES;
|
|
1176
|
-
return {
|
|
1177
|
-
maxAttempts: retries + 1,
|
|
1178
|
-
maxDelayMilliseconds: maxNetworkRetryDelayMilliseconds ?? ZAPIER_MAX_NETWORK_RETRY_DELAY_MILLISECONDS,
|
|
1179
|
-
retryStatuses: RETRYABLE_STATUSES,
|
|
1180
|
-
nonIdempotentRetryStatuses: NON_IDEMPOTENT_RETRYABLE_STATUSES,
|
|
1181
|
-
onRetry: createRetryObserver({ onEvent, maxNetworkRetries: retries })
|
|
1182
|
-
};
|
|
1183
|
-
}
|
|
1184
|
-
function resolveNetworkRetryDelayMilliseconds({
|
|
1185
|
-
maxNetworkRetryDelaySeconds,
|
|
1186
|
-
maxNetworkRetryDelayMs
|
|
1187
|
-
}) {
|
|
1188
|
-
return maxNetworkRetryDelaySeconds != null ? maxNetworkRetryDelaySeconds * 1e3 : maxNetworkRetryDelayMs;
|
|
1189
|
-
}
|
|
1190
|
-
function resolveTransportFetch({
|
|
1191
|
-
fetch: customFetch,
|
|
1192
|
-
debug = false
|
|
1193
|
-
}) {
|
|
1194
|
-
const originalFetch = customFetch ?? ((input, init) => globalThis.fetch(input, init));
|
|
1195
|
-
if (!debug) return originalFetch;
|
|
1196
|
-
return createDebugFetch({
|
|
1197
|
-
originalFetch,
|
|
1198
|
-
debugLog: createDebugLogger(debug)
|
|
1199
|
-
});
|
|
1200
|
-
}
|
|
1201
|
-
|
|
1202
|
-
// src/plugins/transport/http-fetch.ts
|
|
1203
|
-
var httpFetchPlugin = kitcore.defineProperty({
|
|
1204
|
-
namespace: "kitcore",
|
|
1205
|
-
name: "httpFetch",
|
|
1206
|
-
imports: [sdkOptionsPluginRef],
|
|
1207
|
-
setup: ({ imports }) => resolveTransportFetch({
|
|
1208
|
-
fetch: imports.sdkOptions?.fetch,
|
|
1209
|
-
debug: imports.sdkOptions?.debug
|
|
1210
|
-
}),
|
|
1211
|
-
get: ({ state }) => state
|
|
1212
|
-
});
|
|
1213
|
-
|
|
1214
|
-
// src/plugins/transport/standalone.ts
|
|
1215
|
-
function createZapierSendHttpRequest({
|
|
1216
|
-
fetch: customFetch,
|
|
1217
|
-
debug,
|
|
1218
|
-
maxNetworkRetries,
|
|
1219
|
-
maxNetworkRetryDelayMilliseconds,
|
|
1220
|
-
onEvent
|
|
1221
|
-
}) {
|
|
1222
|
-
const sdk = kitcore.createSdk(
|
|
1223
|
-
kitcore.definePlugin({
|
|
1224
|
-
name: "zapierStandaloneHttpTransport",
|
|
1225
|
-
imports: [kitcore.sendHttpRequestPlugin, kitcore.retryHttpRequestPlugin, httpFetchPlugin],
|
|
1226
|
-
exports: [kitcore.sendHttpRequestPlugin]
|
|
1227
|
-
}),
|
|
1228
|
-
{
|
|
1229
|
-
configuration: {
|
|
1230
|
-
[SDK_OPTIONS_ID]: { fetch: customFetch, debug },
|
|
1231
|
-
// Filled by configuration rather than the graph's property plugin: the
|
|
1232
|
-
// caller here holds client-shaped ms options, not SDK options.
|
|
1233
|
-
[kitcore.RETRY_HTTP_REQUEST_OPTIONS_ID]: resolveRetryHttpRequestOptions({
|
|
1234
|
-
maxNetworkRetries,
|
|
1235
|
-
maxNetworkRetryDelayMilliseconds,
|
|
1236
|
-
onEvent
|
|
1237
|
-
})
|
|
1238
|
-
}
|
|
1239
|
-
}
|
|
1240
|
-
);
|
|
1241
|
-
return sdk.sendHttpRequest;
|
|
1242
|
-
}
|
|
1243
|
-
|
|
1244
|
-
// src/api/correlation.ts
|
|
1245
|
-
var CORRELATION_CALL_ID = Symbol(
|
|
1246
|
-
"zapier.correlationCallId"
|
|
1247
|
-
);
|
|
1248
|
-
function resolveCorrelationId({
|
|
1249
|
-
options,
|
|
1250
|
-
callId
|
|
1251
|
-
}) {
|
|
1252
|
-
return options?.correlationId || getZapierCorrelationId() || callId || void 0;
|
|
1253
|
-
}
|
|
1254
|
-
function resolveCausationId({
|
|
1255
|
-
options
|
|
1256
|
-
}) {
|
|
1257
|
-
return options?.causationId || getZapierCausationId();
|
|
1258
|
-
}
|
|
1259
1178
|
var ClientCredentialsObjectSchema = zod.z.object({
|
|
1260
1179
|
type: zod.z.enum(["client_credentials"]).optional().meta({ internal: true }),
|
|
1261
1180
|
clientId: zod.z.string().describe("OAuth client ID for authentication.").meta({ valueHint: "id" }),
|
|
@@ -2879,7 +2798,7 @@ function logRouteOverride({
|
|
|
2879
2798
|
}
|
|
2880
2799
|
|
|
2881
2800
|
// src/sdk-version.ts
|
|
2882
|
-
var SDK_VERSION = (typeof process !== "undefined" && process.env ? "0.
|
|
2801
|
+
var SDK_VERSION = (typeof process !== "undefined" && process.env ? "0.109.0" : void 0) || "unknown";
|
|
2883
2802
|
|
|
2884
2803
|
// src/utils/open-url.ts
|
|
2885
2804
|
var nodePrefix = "node:";
|
|
@@ -3898,7 +3817,7 @@ var ZapierApiClient = class {
|
|
|
3898
3817
|
}
|
|
3899
3818
|
await openApproval(approval.approval_url);
|
|
3900
3819
|
}
|
|
3901
|
-
const timeoutMs = this.options.approvalTimeoutMilliseconds ??
|
|
3820
|
+
const timeoutMs = this.options.approvalTimeoutMilliseconds ?? DEFAULT_APPROVAL_TIMEOUT_MILLISECONDS;
|
|
3902
3821
|
const approvalDeadline = Date.now() + timeoutMs;
|
|
3903
3822
|
let streamAbortController;
|
|
3904
3823
|
let streamPromise;
|
|
@@ -4066,7 +3985,7 @@ var ZapierApiClient = class {
|
|
|
4066
3985
|
);
|
|
4067
3986
|
}
|
|
4068
3987
|
};
|
|
4069
|
-
var
|
|
3988
|
+
var createApiClient = (options) => {
|
|
4070
3989
|
const { debug = false, fetch: originalFetch = globalThis.fetch } = options;
|
|
4071
3990
|
const routingOptions = parseRoutingOptions({ options });
|
|
4072
3991
|
const debugLog = createDebugLogger(debug);
|
|
@@ -4077,62 +3996,94 @@ var createZapierApi = (options) => {
|
|
|
4077
3996
|
// The credential-exchange transport. Debug-wrapped here rather than in the
|
|
4078
3997
|
// pipeline because `resolveAuthToken` is issued outside it.
|
|
4079
3998
|
fetch: debugFetch,
|
|
4080
|
-
|
|
4081
|
-
// for debug itself, and passing the wrapped one would log twice.
|
|
4082
|
-
sendHttpRequest: options.sendHttpRequest ?? createZapierSendHttpRequest({
|
|
4083
|
-
fetch: options.fetch,
|
|
4084
|
-
debug,
|
|
4085
|
-
onEvent: options.onEvent,
|
|
4086
|
-
maxNetworkRetries: options.maxNetworkRetries,
|
|
4087
|
-
maxNetworkRetryDelayMilliseconds: options.maxNetworkRetryDelayMilliseconds ?? options.maxNetworkRetryDelayMs
|
|
4088
|
-
}),
|
|
3999
|
+
sendHttpRequest: options.sendHttpRequest,
|
|
4089
4000
|
debugLog,
|
|
4090
4001
|
routingOptions
|
|
4091
4002
|
});
|
|
4092
4003
|
};
|
|
4093
|
-
|
|
4094
|
-
|
|
4095
|
-
|
|
4096
|
-
|
|
4097
|
-
|
|
4098
|
-
|
|
4004
|
+
var API_CLIENT_DURATIONS_ID = "zapier/apiClientDurations";
|
|
4005
|
+
var apiClientDurationsPluginRef = kitcore.declareOptionalProperty({
|
|
4006
|
+
id: API_CLIENT_DURATIONS_ID
|
|
4007
|
+
});
|
|
4008
|
+
function resolveNetworkRetryDelayMilliseconds({
|
|
4009
|
+
apiClientDurations,
|
|
4010
|
+
sdkOptions
|
|
4011
|
+
}) {
|
|
4012
|
+
if (apiClientDurations?.maxNetworkRetryDelayMilliseconds != null) {
|
|
4013
|
+
return apiClientDurations.maxNetworkRetryDelayMilliseconds;
|
|
4099
4014
|
}
|
|
4100
|
-
|
|
4101
|
-
|
|
4015
|
+
if (sdkOptions?.maxNetworkRetryDelaySeconds != null) {
|
|
4016
|
+
return sdkOptions.maxNetworkRetryDelaySeconds * 1e3;
|
|
4017
|
+
}
|
|
4018
|
+
return sdkOptions?.maxNetworkRetryDelayMs;
|
|
4102
4019
|
}
|
|
4103
|
-
|
|
4104
|
-
|
|
4105
|
-
|
|
4106
|
-
|
|
4107
|
-
|
|
4108
|
-
|
|
4109
|
-
token,
|
|
4110
|
-
api: providedApi,
|
|
4111
|
-
debug = false,
|
|
4112
|
-
fetch: customFetch,
|
|
4113
|
-
callerPackage
|
|
4114
|
-
} = config;
|
|
4115
|
-
if (providedApi) {
|
|
4116
|
-
return providedApi;
|
|
4020
|
+
function resolveApprovalTimeoutMilliseconds({
|
|
4021
|
+
apiClientDurations,
|
|
4022
|
+
sdkOptions
|
|
4023
|
+
}) {
|
|
4024
|
+
if (apiClientDurations?.approvalTimeoutMilliseconds != null) {
|
|
4025
|
+
return apiClientDurations.approvalTimeoutMilliseconds;
|
|
4117
4026
|
}
|
|
4118
|
-
|
|
4119
|
-
|
|
4120
|
-
|
|
4121
|
-
|
|
4122
|
-
|
|
4123
|
-
|
|
4124
|
-
|
|
4027
|
+
if (sdkOptions?.approvalTimeoutSeconds != null) {
|
|
4028
|
+
return sdkOptions.approvalTimeoutSeconds * 1e3;
|
|
4029
|
+
}
|
|
4030
|
+
return sdkOptions?.approvalTimeoutMs;
|
|
4031
|
+
}
|
|
4032
|
+
var SDK_OPTIONS_ID = "zapier/sdkOptions";
|
|
4033
|
+
var sdkOptionsPluginRef = kitcore.declareOptionalProperty({
|
|
4034
|
+
id: SDK_OPTIONS_ID
|
|
4035
|
+
});
|
|
4036
|
+
|
|
4037
|
+
// src/plugins/transport/options.ts
|
|
4038
|
+
var RETRYABLE_STATUSES = [429, 500, 502, 503, 504];
|
|
4039
|
+
var NON_IDEMPOTENT_RETRYABLE_STATUSES = [429];
|
|
4040
|
+
function resolveRetryHttpRequestOptions({
|
|
4041
|
+
maxNetworkRetries,
|
|
4042
|
+
maxNetworkRetryDelayMilliseconds,
|
|
4043
|
+
onEvent
|
|
4044
|
+
}) {
|
|
4045
|
+
const retries = maxNetworkRetries ?? ZAPIER_MAX_NETWORK_RETRIES;
|
|
4046
|
+
return {
|
|
4047
|
+
maxAttempts: retries + 1,
|
|
4048
|
+
maxDelayMilliseconds: maxNetworkRetryDelayMilliseconds ?? ZAPIER_MAX_NETWORK_RETRY_DELAY_MILLISECONDS,
|
|
4049
|
+
retryStatuses: RETRYABLE_STATUSES,
|
|
4050
|
+
nonIdempotentRetryStatuses: NON_IDEMPOTENT_RETRYABLE_STATUSES,
|
|
4051
|
+
onRetry: createRetryObserver({ onEvent, maxNetworkRetries: retries })
|
|
4052
|
+
};
|
|
4053
|
+
}
|
|
4054
|
+
function resolveTransportFetch({
|
|
4055
|
+
fetch: customFetch,
|
|
4056
|
+
debug = false
|
|
4057
|
+
}) {
|
|
4058
|
+
const originalFetch = customFetch ?? ((input, init) => globalThis.fetch(input, init));
|
|
4059
|
+
if (!debug) return originalFetch;
|
|
4060
|
+
return createDebugFetch({
|
|
4061
|
+
originalFetch,
|
|
4062
|
+
debugLog: createDebugLogger(debug)
|
|
4125
4063
|
});
|
|
4126
4064
|
}
|
|
4065
|
+
|
|
4066
|
+
// src/plugins/transport/http-fetch.ts
|
|
4067
|
+
var httpFetchPlugin = kitcore.defineProperty({
|
|
4068
|
+
namespace: "kitcore",
|
|
4069
|
+
name: "httpFetch",
|
|
4070
|
+
imports: [sdkOptionsPluginRef],
|
|
4071
|
+
setup: ({ imports }) => resolveTransportFetch({
|
|
4072
|
+
fetch: imports.sdkOptions?.fetch,
|
|
4073
|
+
debug: imports.sdkOptions?.debug
|
|
4074
|
+
}),
|
|
4075
|
+
get: ({ state }) => state
|
|
4076
|
+
});
|
|
4127
4077
|
var retryHttpRequestOptionsPlugin = kitcore.defineProperty({
|
|
4128
4078
|
namespace: "kitcore",
|
|
4129
4079
|
name: "retryHttpRequestOptions",
|
|
4130
|
-
imports: [sdkOptionsPluginRef],
|
|
4080
|
+
imports: [sdkOptionsPluginRef, apiClientDurationsPluginRef],
|
|
4131
4081
|
setup: ({ imports }) => resolveRetryHttpRequestOptions({
|
|
4132
4082
|
maxNetworkRetries: imports.sdkOptions?.maxNetworkRetries,
|
|
4133
|
-
maxNetworkRetryDelayMilliseconds: resolveNetworkRetryDelayMilliseconds(
|
|
4134
|
-
imports.
|
|
4135
|
-
|
|
4083
|
+
maxNetworkRetryDelayMilliseconds: resolveNetworkRetryDelayMilliseconds({
|
|
4084
|
+
apiClientDurations: imports.apiClientDurations,
|
|
4085
|
+
sdkOptions: imports.sdkOptions
|
|
4086
|
+
}),
|
|
4136
4087
|
onEvent: imports.sdkOptions?.onEvent
|
|
4137
4088
|
}),
|
|
4138
4089
|
get: ({ state }) => state
|
|
@@ -4176,10 +4127,14 @@ function withCorrelationId({
|
|
|
4176
4127
|
var apiPlugin = kitcore.defineProperty({
|
|
4177
4128
|
namespace: "zapier",
|
|
4178
4129
|
name: "api",
|
|
4179
|
-
// Import the aggregate so
|
|
4180
|
-
|
|
4181
|
-
|
|
4130
|
+
// Import the aggregate so SDK options and host transport wraps are applied.
|
|
4131
|
+
imports: [
|
|
4132
|
+
sdkOptionsPluginRef,
|
|
4133
|
+
apiClientDurationsPluginRef,
|
|
4134
|
+
zapierHttpTransportPlugin
|
|
4135
|
+
],
|
|
4182
4136
|
setup: ({ imports }) => {
|
|
4137
|
+
const sdkOptions = imports.sdkOptions ?? {};
|
|
4183
4138
|
const {
|
|
4184
4139
|
fetch: customFetch = globalThis.fetch,
|
|
4185
4140
|
baseUrl = ZAPIER_BASE_URL,
|
|
@@ -4187,38 +4142,33 @@ var apiPlugin = kitcore.defineProperty({
|
|
|
4187
4142
|
token,
|
|
4188
4143
|
onEvent,
|
|
4189
4144
|
debug = false,
|
|
4190
|
-
maxNetworkRetries = ZAPIER_MAX_NETWORK_RETRIES,
|
|
4191
|
-
maxNetworkRetryDelaySeconds,
|
|
4192
|
-
maxNetworkRetryDelayMs,
|
|
4193
4145
|
maxConcurrentRequests = ZAPIER_MAX_CONCURRENT_REQUESTS,
|
|
4194
|
-
approvalTimeoutSeconds,
|
|
4195
|
-
approvalTimeoutMs,
|
|
4196
4146
|
maxApprovalRetries,
|
|
4197
4147
|
approvalMode,
|
|
4198
4148
|
openAutoModeApprovalsInBrowser,
|
|
4199
4149
|
callerPackage,
|
|
4150
|
+
cache,
|
|
4200
4151
|
routeOverrides,
|
|
4201
4152
|
correlationId,
|
|
4202
4153
|
causationId
|
|
4203
|
-
} =
|
|
4204
|
-
return
|
|
4154
|
+
} = sdkOptions;
|
|
4155
|
+
return createApiClient({
|
|
4205
4156
|
baseUrl,
|
|
4206
4157
|
credentials,
|
|
4207
4158
|
token,
|
|
4208
4159
|
debug,
|
|
4209
4160
|
fetch: customFetch,
|
|
4210
4161
|
onEvent,
|
|
4211
|
-
maxNetworkRetries,
|
|
4212
|
-
maxNetworkRetryDelayMilliseconds: resolveNetworkRetryDelayMilliseconds({
|
|
4213
|
-
maxNetworkRetryDelaySeconds,
|
|
4214
|
-
maxNetworkRetryDelayMs
|
|
4215
|
-
}) ?? ZAPIER_MAX_NETWORK_RETRY_DELAY_MILLISECONDS,
|
|
4216
4162
|
maxConcurrentRequests,
|
|
4217
|
-
approvalTimeoutMilliseconds:
|
|
4163
|
+
approvalTimeoutMilliseconds: resolveApprovalTimeoutMilliseconds({
|
|
4164
|
+
apiClientDurations: imports.apiClientDurations,
|
|
4165
|
+
sdkOptions
|
|
4166
|
+
}),
|
|
4218
4167
|
maxApprovalRetries,
|
|
4219
4168
|
approvalMode,
|
|
4220
4169
|
openAutoModeApprovalsInBrowser,
|
|
4221
4170
|
callerPackage,
|
|
4171
|
+
cache,
|
|
4222
4172
|
routeOverrides,
|
|
4223
4173
|
// Inject the graph-composed transport so host `dispatchHttpRequest` wraps
|
|
4224
4174
|
// apply.
|
|
@@ -10518,6 +10468,112 @@ var drainTriggerInboxPlugin = kitcore.defineMethod({
|
|
|
10518
10468
|
});
|
|
10519
10469
|
}
|
|
10520
10470
|
});
|
|
10471
|
+
var apiClientRootPlugin = kitcore.definePlugin({
|
|
10472
|
+
namespace: "zapier",
|
|
10473
|
+
name: "apiClientRoot",
|
|
10474
|
+
imports: [apiPlugin],
|
|
10475
|
+
exports: []
|
|
10476
|
+
});
|
|
10477
|
+
function hasStringUrl(request) {
|
|
10478
|
+
return typeof request.url === "string";
|
|
10479
|
+
}
|
|
10480
|
+
function createApiClientGraphConfiguration(options) {
|
|
10481
|
+
const {
|
|
10482
|
+
maxNetworkRetryDelayMilliseconds,
|
|
10483
|
+
maxNetworkRetryDelayMs,
|
|
10484
|
+
approvalTimeoutMilliseconds,
|
|
10485
|
+
approvalTimeoutMs,
|
|
10486
|
+
sendHttpRequest: _sendHttpRequest,
|
|
10487
|
+
...sdkOptions
|
|
10488
|
+
} = options;
|
|
10489
|
+
return {
|
|
10490
|
+
[SDK_OPTIONS_ID]: sdkOptions,
|
|
10491
|
+
[API_CLIENT_DURATIONS_ID]: {
|
|
10492
|
+
maxNetworkRetryDelayMilliseconds: maxNetworkRetryDelayMilliseconds ?? maxNetworkRetryDelayMs,
|
|
10493
|
+
approvalTimeoutMilliseconds: approvalTimeoutMilliseconds ?? approvalTimeoutMs
|
|
10494
|
+
}
|
|
10495
|
+
};
|
|
10496
|
+
}
|
|
10497
|
+
function createApiClientFromSdkGraph(options) {
|
|
10498
|
+
parseRoutingOptions({ options });
|
|
10499
|
+
const configuration = createApiClientGraphConfiguration(options);
|
|
10500
|
+
const { sendHttpRequest } = options;
|
|
10501
|
+
if (!sendHttpRequest) {
|
|
10502
|
+
const sdk2 = kitcore.createSdk(apiClientRootPlugin, { configuration });
|
|
10503
|
+
return kitcore.resolvePlugin(sdk2, apiPluginRef);
|
|
10504
|
+
}
|
|
10505
|
+
const replaceSendHttpRequestPlugin = kitcore.defineHook({
|
|
10506
|
+
namespace: "zapier",
|
|
10507
|
+
name: "replaceApiClientSendHttpRequest",
|
|
10508
|
+
imports: [kitcore.sendHttpRequestPlugin],
|
|
10509
|
+
wrap: {
|
|
10510
|
+
// Replaces the pipeline rather than wrapping it: `next` is deliberately
|
|
10511
|
+
// unused. A transport supplied through `sendHttpRequest` owns its retry
|
|
10512
|
+
// policy, so running the SDK's stages underneath would nest the caller's
|
|
10513
|
+
// retry loop inside a second one. Dropping them is only safe because the
|
|
10514
|
+
// SDK's retry hook wraps `attemptHttpRequest`, a stage below this seam,
|
|
10515
|
+
// so replacing `sendHttpRequest` removes that loop instead of nesting
|
|
10516
|
+
// inside it. The cost is that the SDK cannot observe retries the caller
|
|
10517
|
+
// performs, and so reports a terminal 429 as zero.
|
|
10518
|
+
sendHttpRequest: ({ input }) => sendHttpRequest(
|
|
10519
|
+
hasStringUrl(input) ? input : { ...input, url: input.url.toString() }
|
|
10520
|
+
)
|
|
10521
|
+
}
|
|
10522
|
+
});
|
|
10523
|
+
const sdk = kitcore.createSdk(
|
|
10524
|
+
kitcore.definePlugin({
|
|
10525
|
+
namespace: "zapier",
|
|
10526
|
+
name: "standaloneApiClientRoot",
|
|
10527
|
+
imports: [apiPlugin, replaceSendHttpRequestPlugin],
|
|
10528
|
+
exports: []
|
|
10529
|
+
}),
|
|
10530
|
+
{ configuration }
|
|
10531
|
+
);
|
|
10532
|
+
return kitcore.resolvePlugin(sdk, apiPluginRef);
|
|
10533
|
+
}
|
|
10534
|
+
|
|
10535
|
+
// src/api/error-classification.ts
|
|
10536
|
+
function isPermanentHttpError(err) {
|
|
10537
|
+
if (!isZapierError(err)) return false;
|
|
10538
|
+
if (isZapierAuthenticationError(err) && err.statusCode === void 0) {
|
|
10539
|
+
return true;
|
|
10540
|
+
}
|
|
10541
|
+
const { statusCode } = err;
|
|
10542
|
+
return statusCode !== void 0 && statusCode >= 400 && statusCode < 500 && statusCode !== 429;
|
|
10543
|
+
}
|
|
10544
|
+
|
|
10545
|
+
// src/api/index.ts
|
|
10546
|
+
function createZapierApi(options) {
|
|
10547
|
+
logDeprecation(
|
|
10548
|
+
"createZapierApi is deprecated and will be removed in a future release. Build an SDK with createSdk and access apiPluginRef with resolvePlugin instead."
|
|
10549
|
+
);
|
|
10550
|
+
return createApiClientFromSdkGraph(options);
|
|
10551
|
+
}
|
|
10552
|
+
function getOrCreateApiClient(config) {
|
|
10553
|
+
logDeprecation(
|
|
10554
|
+
"getOrCreateApiClient is deprecated and will be removed in a future release. Use a provided API client directly, or build an SDK with createSdk and access apiPluginRef with resolvePlugin."
|
|
10555
|
+
);
|
|
10556
|
+
const {
|
|
10557
|
+
baseUrl = ZAPIER_BASE_URL,
|
|
10558
|
+
credentials,
|
|
10559
|
+
token,
|
|
10560
|
+
api: providedApi,
|
|
10561
|
+
debug = false,
|
|
10562
|
+
fetch: customFetch,
|
|
10563
|
+
callerPackage
|
|
10564
|
+
} = config;
|
|
10565
|
+
if (providedApi) {
|
|
10566
|
+
return providedApi;
|
|
10567
|
+
}
|
|
10568
|
+
return createApiClientFromSdkGraph({
|
|
10569
|
+
baseUrl,
|
|
10570
|
+
credentials,
|
|
10571
|
+
token,
|
|
10572
|
+
debug,
|
|
10573
|
+
fetch: customFetch,
|
|
10574
|
+
callerPackage
|
|
10575
|
+
});
|
|
10576
|
+
}
|
|
10521
10577
|
|
|
10522
10578
|
// src/plugins/triggers/watchTriggerInbox/sse.ts
|
|
10523
10579
|
async function* readInboxEvents({
|