@zapier/zapier-sdk 0.50.0 → 0.52.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 +16 -0
- package/README.md +2 -1
- package/dist/api/auth.d.ts +1 -6
- package/dist/api/auth.d.ts.map +1 -1
- package/dist/api/auth.js +34 -27
- package/dist/api/client.d.ts.map +1 -1
- package/dist/api/client.js +87 -9
- package/dist/api/concurrency.d.ts +28 -0
- package/dist/api/concurrency.d.ts.map +1 -0
- package/dist/api/concurrency.js +90 -0
- package/dist/api/index.d.ts +1 -1
- package/dist/api/index.d.ts.map +1 -1
- package/dist/api/index.js +1 -1
- package/dist/api/schemas.d.ts +3 -3
- package/dist/api/types.d.ts +6 -0
- package/dist/api/types.d.ts.map +1 -1
- package/dist/auth.d.ts +13 -2
- package/dist/auth.d.ts.map +1 -1
- package/dist/auth.js +95 -11
- package/dist/constants.d.ts +16 -0
- package/dist/constants.d.ts.map +1 -1
- package/dist/constants.js +29 -0
- package/dist/experimental.cjs +357 -34
- package/dist/experimental.d.mts +28 -28
- package/dist/experimental.d.ts +26 -26
- package/dist/experimental.mjs +353 -35
- package/dist/{index-BQ2ii0Bs.d.mts → index-DcdtPei-.d.mts} +132 -2
- package/dist/{index-BQ2ii0Bs.d.ts → index-DcdtPei-.d.ts} +132 -2
- package/dist/index.cjs +357 -34
- package/dist/index.d.mts +1 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/index.mjs +353 -35
- package/dist/plugins/api/index.d.ts.map +1 -1
- package/dist/plugins/api/index.js +3 -2
- package/dist/plugins/apps/index.d.ts +2 -2
- package/dist/plugins/deprecated/inputFields.d.ts +18 -18
- package/dist/plugins/getAction/index.d.ts +6 -6
- package/dist/plugins/getAction/schemas.d.ts +4 -4
- package/dist/plugins/getActionInputFieldsSchema/index.d.ts +5 -5
- package/dist/plugins/getActionInputFieldsSchema/schemas.d.ts +4 -4
- package/dist/plugins/listActionInputFieldChoices/index.d.ts +5 -5
- package/dist/plugins/listActionInputFieldChoices/schemas.d.ts +4 -4
- package/dist/plugins/listActionInputFields/index.d.ts +5 -5
- package/dist/plugins/listActionInputFields/schemas.d.ts +4 -4
- package/dist/plugins/listActions/index.d.ts +3 -3
- package/dist/plugins/listActions/schemas.d.ts +4 -4
- package/dist/plugins/runAction/index.d.ts +5 -5
- package/dist/plugins/runAction/schemas.d.ts +4 -4
- package/dist/plugins/triggers/getTriggerInputFieldsSchema/index.d.ts +2 -2
- package/dist/plugins/triggers/listTriggerInputFieldChoices/index.d.ts +2 -2
- package/dist/plugins/triggers/listTriggerInputFields/index.d.ts +2 -2
- package/dist/schemas/Action.d.ts +1 -1
- package/dist/sdk.d.ts +52 -52
- package/dist/types/properties.d.ts +1 -1
- package/dist/types/sdk.d.ts +1 -0
- package/dist/types/sdk.d.ts.map +1 -1
- package/dist/types/sdk.js +25 -0
- package/dist/utils/telemetry.d.ts +11 -0
- package/dist/utils/telemetry.d.ts.map +1 -0
- package/dist/utils/telemetry.js +19 -0
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -63,6 +63,21 @@ function parseIntEnvVar(name) {
|
|
|
63
63
|
}
|
|
64
64
|
var ZAPIER_MAX_NETWORK_RETRIES = parseIntEnvVar("ZAPIER_MAX_NETWORK_RETRIES") ?? 3;
|
|
65
65
|
var ZAPIER_MAX_NETWORK_RETRY_DELAY_MS = parseIntEnvVar("ZAPIER_MAX_NETWORK_RETRY_DELAY_MS") ?? 6e4;
|
|
66
|
+
var MAX_CONCURRENCY_LIMIT = 1e4;
|
|
67
|
+
function parseConcurrencyEnvVar(name) {
|
|
68
|
+
const value = globalThis.process?.env?.[name];
|
|
69
|
+
if (!value) return void 0;
|
|
70
|
+
if (value === "Infinity") return Infinity;
|
|
71
|
+
if (/^[1-9]\d*$/.test(value)) {
|
|
72
|
+
const parsed = parseInt(value, 10);
|
|
73
|
+
if (parsed <= MAX_CONCURRENCY_LIMIT) return parsed;
|
|
74
|
+
}
|
|
75
|
+
console.warn(
|
|
76
|
+
`[zapier-sdk] Invalid value for ${name}: "${value}" (expected positive integer 1-${MAX_CONCURRENCY_LIMIT} or "Infinity")`
|
|
77
|
+
);
|
|
78
|
+
return void 0;
|
|
79
|
+
}
|
|
80
|
+
var ZAPIER_MAX_CONCURRENT_REQUESTS = parseConcurrencyEnvVar("ZAPIER_MAX_CONCURRENT_REQUESTS") ?? 200;
|
|
66
81
|
function getZapierApprovalMode() {
|
|
67
82
|
const value = globalThis.process?.env?.ZAPIER_APPROVAL_MODE;
|
|
68
83
|
if (value === "disabled" || value === "poll" || value === "throw")
|
|
@@ -5235,33 +5250,40 @@ function getAuthorizationHeader(token) {
|
|
|
5235
5250
|
}
|
|
5236
5251
|
return `Bearer ${token}`;
|
|
5237
5252
|
}
|
|
5238
|
-
function
|
|
5253
|
+
function readJwtPayload(token) {
|
|
5239
5254
|
const parts = parseJwt(token);
|
|
5240
|
-
if (!parts)
|
|
5241
|
-
|
|
5242
|
-
}
|
|
5255
|
+
if (!parts) return null;
|
|
5256
|
+
let payload;
|
|
5243
5257
|
try {
|
|
5244
|
-
|
|
5245
|
-
|
|
5246
|
-
|
|
5247
|
-
|
|
5248
|
-
|
|
5249
|
-
|
|
5250
|
-
|
|
5251
|
-
|
|
5258
|
+
payload = JSON.parse(Buffer.from(parts[1], "base64url").toString("utf-8"));
|
|
5259
|
+
} catch {
|
|
5260
|
+
return null;
|
|
5261
|
+
}
|
|
5262
|
+
if (payload["sub_type"] === "service" && typeof payload["njwt"] === "string") {
|
|
5263
|
+
const nestedParts = parseJwt(payload["njwt"]);
|
|
5264
|
+
if (nestedParts) {
|
|
5265
|
+
try {
|
|
5266
|
+
return JSON.parse(
|
|
5252
5267
|
Buffer.from(nestedParts[1], "base64url").toString("utf-8")
|
|
5253
5268
|
);
|
|
5269
|
+
} catch {
|
|
5254
5270
|
}
|
|
5255
5271
|
}
|
|
5256
|
-
|
|
5257
|
-
|
|
5258
|
-
|
|
5259
|
-
|
|
5260
|
-
|
|
5261
|
-
|
|
5262
|
-
} catch {
|
|
5272
|
+
}
|
|
5273
|
+
return payload;
|
|
5274
|
+
}
|
|
5275
|
+
function extractUserIdsFromJwt(token) {
|
|
5276
|
+
const payload = readJwtPayload(token);
|
|
5277
|
+
if (!payload) {
|
|
5263
5278
|
return { customuser_id: null, account_id: null };
|
|
5264
5279
|
}
|
|
5280
|
+
const accRaw = payload["zap:acc"];
|
|
5281
|
+
const accountId = accRaw != null ? parseInt(String(accRaw), 10) : null;
|
|
5282
|
+
const customUserId = payload["sub_type"] === "customuser" && payload["sub"] != null ? parseInt(String(payload["sub"]), 10) : null;
|
|
5283
|
+
return {
|
|
5284
|
+
customuser_id: customUserId !== null && !isNaN(customUserId) ? customUserId : null,
|
|
5285
|
+
account_id: accountId !== null && !isNaN(accountId) ? accountId : null
|
|
5286
|
+
};
|
|
5265
5287
|
}
|
|
5266
5288
|
|
|
5267
5289
|
// src/api/debug.ts
|
|
@@ -5569,6 +5591,83 @@ async function pollUntilComplete(options) {
|
|
|
5569
5591
|
}
|
|
5570
5592
|
}
|
|
5571
5593
|
}
|
|
5594
|
+
|
|
5595
|
+
// src/api/concurrency.ts
|
|
5596
|
+
var NO_OP_RELEASE = () => {
|
|
5597
|
+
};
|
|
5598
|
+
var NO_OP_SEMAPHORE = {
|
|
5599
|
+
acquire: async () => NO_OP_RELEASE,
|
|
5600
|
+
tryAcquire: () => NO_OP_RELEASE
|
|
5601
|
+
};
|
|
5602
|
+
function createSemaphore(maxPermits) {
|
|
5603
|
+
if (maxPermits === Infinity) {
|
|
5604
|
+
return NO_OP_SEMAPHORE;
|
|
5605
|
+
}
|
|
5606
|
+
if (!Number.isInteger(maxPermits) || maxPermits <= 0) {
|
|
5607
|
+
throw new Error(
|
|
5608
|
+
`maxPermits must be a positive integer or Infinity, got: ${maxPermits}`
|
|
5609
|
+
);
|
|
5610
|
+
}
|
|
5611
|
+
let permits = maxPermits;
|
|
5612
|
+
const waiters = [];
|
|
5613
|
+
const release = () => {
|
|
5614
|
+
const next = waiters.shift();
|
|
5615
|
+
if (next) {
|
|
5616
|
+
next.grant();
|
|
5617
|
+
} else {
|
|
5618
|
+
permits++;
|
|
5619
|
+
}
|
|
5620
|
+
};
|
|
5621
|
+
const makeReleaseOnce = () => {
|
|
5622
|
+
let released = false;
|
|
5623
|
+
return () => {
|
|
5624
|
+
if (released) return;
|
|
5625
|
+
released = true;
|
|
5626
|
+
release();
|
|
5627
|
+
};
|
|
5628
|
+
};
|
|
5629
|
+
return {
|
|
5630
|
+
tryAcquire() {
|
|
5631
|
+
if (permits > 0) {
|
|
5632
|
+
permits--;
|
|
5633
|
+
return makeReleaseOnce();
|
|
5634
|
+
}
|
|
5635
|
+
return null;
|
|
5636
|
+
},
|
|
5637
|
+
async acquire(signal) {
|
|
5638
|
+
if (signal?.aborted) {
|
|
5639
|
+
throw signal.reason ?? new DOMException("Aborted", "AbortError");
|
|
5640
|
+
}
|
|
5641
|
+
if (permits > 0) {
|
|
5642
|
+
permits--;
|
|
5643
|
+
return makeReleaseOnce();
|
|
5644
|
+
}
|
|
5645
|
+
return new Promise((resolve2, reject) => {
|
|
5646
|
+
const onAbort = () => {
|
|
5647
|
+
const idx = waiters.indexOf(waiter);
|
|
5648
|
+
if (idx !== -1) {
|
|
5649
|
+
waiters.splice(idx, 1);
|
|
5650
|
+
waiter.cancel(
|
|
5651
|
+
signal?.reason ?? new DOMException("Aborted", "AbortError")
|
|
5652
|
+
);
|
|
5653
|
+
}
|
|
5654
|
+
};
|
|
5655
|
+
const waiter = {
|
|
5656
|
+
grant: () => {
|
|
5657
|
+
signal?.removeEventListener("abort", onAbort);
|
|
5658
|
+
resolve2(makeReleaseOnce());
|
|
5659
|
+
},
|
|
5660
|
+
cancel: (reason) => {
|
|
5661
|
+
signal?.removeEventListener("abort", onAbort);
|
|
5662
|
+
reject(reason);
|
|
5663
|
+
}
|
|
5664
|
+
};
|
|
5665
|
+
signal?.addEventListener("abort", onAbort);
|
|
5666
|
+
waiters.push(waiter);
|
|
5667
|
+
});
|
|
5668
|
+
}
|
|
5669
|
+
};
|
|
5670
|
+
}
|
|
5572
5671
|
var ClientCredentialsObjectSchema = zod.z.object({
|
|
5573
5672
|
type: zod.z.enum(["client_credentials"]).optional().meta({ internal: true }),
|
|
5574
5673
|
clientId: zod.z.string().describe("OAuth client ID for authentication.").meta({ valueHint: "id" }),
|
|
@@ -5610,6 +5709,19 @@ function isCredentialsFunction(credentials) {
|
|
|
5610
5709
|
return typeof credentials === "function";
|
|
5611
5710
|
}
|
|
5612
5711
|
|
|
5712
|
+
// src/utils/telemetry.ts
|
|
5713
|
+
var emittedOnce = /* @__PURE__ */ new WeakMap();
|
|
5714
|
+
function emitOnce(onEvent, event) {
|
|
5715
|
+
if (!emittedOnce.has(onEvent)) {
|
|
5716
|
+
emittedOnce.set(onEvent, /* @__PURE__ */ new Set());
|
|
5717
|
+
}
|
|
5718
|
+
const fired = emittedOnce.get(onEvent);
|
|
5719
|
+
if (!fired.has(event.type)) {
|
|
5720
|
+
fired.add(event.type);
|
|
5721
|
+
onEvent(event);
|
|
5722
|
+
}
|
|
5723
|
+
}
|
|
5724
|
+
|
|
5613
5725
|
// src/utils/url-utils.ts
|
|
5614
5726
|
function getZapierBaseUrl(baseUrl) {
|
|
5615
5727
|
if (!baseUrl) {
|
|
@@ -5832,8 +5944,10 @@ async function resolveCache(options) {
|
|
|
5832
5944
|
if (cliLogin?.createCache) {
|
|
5833
5945
|
try {
|
|
5834
5946
|
const cache = cliLogin.createCache();
|
|
5835
|
-
|
|
5836
|
-
|
|
5947
|
+
if (cache) {
|
|
5948
|
+
cachedDefaultCache = cache;
|
|
5949
|
+
return cache;
|
|
5950
|
+
}
|
|
5837
5951
|
} catch {
|
|
5838
5952
|
}
|
|
5839
5953
|
}
|
|
@@ -5845,6 +5959,11 @@ function entryIsValid(entry) {
|
|
|
5845
5959
|
if (entry.expiresAt === void 0) return true;
|
|
5846
5960
|
return entry.expiresAt > Date.now() + TOKEN_EXPIRATION_BUFFER_MS;
|
|
5847
5961
|
}
|
|
5962
|
+
async function readCachedToken(cacheKey, cache) {
|
|
5963
|
+
const cached = await cache.get(cacheKey);
|
|
5964
|
+
if (cached && entryIsValid(cached)) return cached.value;
|
|
5965
|
+
return void 0;
|
|
5966
|
+
}
|
|
5848
5967
|
async function invalidateCachedToken(options) {
|
|
5849
5968
|
const cacheKey = buildCacheKey(options);
|
|
5850
5969
|
pendingExchanges.delete(cacheKey);
|
|
@@ -5958,11 +6077,76 @@ function isCliLoginAvailable() {
|
|
|
5958
6077
|
if (cachedCliLogin === void 0) return void 0;
|
|
5959
6078
|
return cachedCliLogin !== false;
|
|
5960
6079
|
}
|
|
6080
|
+
function emitAuthResolved(onEvent, mechanism) {
|
|
6081
|
+
if (onEvent) {
|
|
6082
|
+
emitOnce(onEvent, {
|
|
6083
|
+
type: "auth_resolved",
|
|
6084
|
+
payload: { mechanism },
|
|
6085
|
+
timestamp: Date.now()
|
|
6086
|
+
});
|
|
6087
|
+
}
|
|
6088
|
+
}
|
|
6089
|
+
async function getActiveCredentialsFromCli(baseUrl) {
|
|
6090
|
+
const cliLogin = await getCliLogin();
|
|
6091
|
+
return cliLogin?.getActiveCredentials?.({ baseUrl });
|
|
6092
|
+
}
|
|
6093
|
+
async function getStoredClientCredentialsFromCli(baseUrl) {
|
|
6094
|
+
const cliLogin = await getCliLogin();
|
|
6095
|
+
return cliLogin?.getStoredClientCredentials?.({ baseUrl });
|
|
6096
|
+
}
|
|
5961
6097
|
async function getTokenFromCliLogin(options) {
|
|
5962
6098
|
const cliLogin = await getCliLogin();
|
|
5963
6099
|
if (!cliLogin) return void 0;
|
|
5964
6100
|
return await cliLogin.getToken(options);
|
|
5965
6101
|
}
|
|
6102
|
+
async function tryStoredClientCredentialToken(options) {
|
|
6103
|
+
const activeCredential = await getActiveCredentialsFromCli(options.baseUrl);
|
|
6104
|
+
if (!activeCredential) return void 0;
|
|
6105
|
+
const resolvedBaseUrl = activeCredential.baseUrl || options.baseUrl || DEFAULT_AUTH_BASE_URL;
|
|
6106
|
+
const mergedScopes = mergeScopes(
|
|
6107
|
+
activeCredential.scopes.join(" "),
|
|
6108
|
+
options.requiredScopes
|
|
6109
|
+
);
|
|
6110
|
+
const cacheKey = buildCacheKey({
|
|
6111
|
+
clientId: activeCredential.clientId,
|
|
6112
|
+
scopes: mergedScopes,
|
|
6113
|
+
baseUrl: resolvedBaseUrl
|
|
6114
|
+
});
|
|
6115
|
+
const cache = await resolveCache(options);
|
|
6116
|
+
const pending = pendingExchanges.get(cacheKey);
|
|
6117
|
+
if (pending) return pending;
|
|
6118
|
+
const cached = await readCachedToken(cacheKey, cache);
|
|
6119
|
+
if (cached !== void 0) {
|
|
6120
|
+
if (options.debug)
|
|
6121
|
+
console.log(
|
|
6122
|
+
`[auth] Using cached token (clientId: ${activeCredential.clientId})`
|
|
6123
|
+
);
|
|
6124
|
+
emitAuthResolved(options.onEvent, "client_credentials");
|
|
6125
|
+
return cached;
|
|
6126
|
+
}
|
|
6127
|
+
const storedCredential = await getStoredClientCredentialsFromCli(resolvedBaseUrl);
|
|
6128
|
+
if (!storedCredential) {
|
|
6129
|
+
await invalidateCachedToken({
|
|
6130
|
+
clientId: activeCredential.clientId,
|
|
6131
|
+
scopes: activeCredential.scopes,
|
|
6132
|
+
baseUrl: resolvedBaseUrl,
|
|
6133
|
+
cache: options.cache
|
|
6134
|
+
});
|
|
6135
|
+
throw new ZapierAuthenticationError(
|
|
6136
|
+
`Stored client credential is missing its secret (clientId: ${activeCredential.clientId}). Run \`zapier-sdk login\` to recreate it.`
|
|
6137
|
+
);
|
|
6138
|
+
}
|
|
6139
|
+
if (options.debug)
|
|
6140
|
+
console.log(
|
|
6141
|
+
`[auth] Using stored client credential (clientId: ${storedCredential.clientId})`
|
|
6142
|
+
);
|
|
6143
|
+
const token = await resolveAuthTokenFromCredentials(
|
|
6144
|
+
storedCredential,
|
|
6145
|
+
options
|
|
6146
|
+
);
|
|
6147
|
+
emitAuthResolved(options.onEvent, "client_credentials");
|
|
6148
|
+
return token;
|
|
6149
|
+
}
|
|
5966
6150
|
async function resolveAuthToken(options = {}) {
|
|
5967
6151
|
const credentials = await resolveCredentials({
|
|
5968
6152
|
credentials: options.credentials,
|
|
@@ -5972,14 +6156,24 @@ async function resolveAuthToken(options = {}) {
|
|
|
5972
6156
|
if (credentials !== void 0) {
|
|
5973
6157
|
return resolveAuthTokenFromCredentials(credentials, options);
|
|
5974
6158
|
}
|
|
5975
|
-
|
|
6159
|
+
const storedToken = await tryStoredClientCredentialToken(options);
|
|
6160
|
+
if (storedToken !== void 0) return storedToken;
|
|
6161
|
+
if (options.debug) {
|
|
6162
|
+
console.log("[auth] Using JWT (no stored client credential found)");
|
|
6163
|
+
}
|
|
6164
|
+
const jwtToken = await getTokenFromCliLogin({
|
|
5976
6165
|
onEvent: options.onEvent,
|
|
5977
6166
|
fetch: options.fetch,
|
|
5978
6167
|
debug: options.debug
|
|
5979
6168
|
});
|
|
6169
|
+
if (jwtToken !== void 0) {
|
|
6170
|
+
emitAuthResolved(options.onEvent, "jwt");
|
|
6171
|
+
}
|
|
6172
|
+
return jwtToken;
|
|
5980
6173
|
}
|
|
5981
6174
|
async function resolveAuthTokenFromCredentials(credentials, options) {
|
|
5982
6175
|
if (typeof credentials === "string") {
|
|
6176
|
+
emitAuthResolved(options.onEvent, "token");
|
|
5983
6177
|
return credentials;
|
|
5984
6178
|
}
|
|
5985
6179
|
if (isClientCredentials(credentials)) {
|
|
@@ -5992,15 +6186,25 @@ async function resolveAuthTokenFromCredentials(credentials, options) {
|
|
|
5992
6186
|
baseUrl: resolvedBaseUrl
|
|
5993
6187
|
});
|
|
5994
6188
|
const cache = await resolveCache(options);
|
|
5995
|
-
const cached = await
|
|
5996
|
-
if (cached
|
|
5997
|
-
|
|
6189
|
+
const cached = await readCachedToken(cacheKey, cache);
|
|
6190
|
+
if (cached !== void 0) {
|
|
6191
|
+
if (options.debug) {
|
|
6192
|
+
console.log(`[auth] Using cached token (clientId: ${clientId})`);
|
|
6193
|
+
}
|
|
6194
|
+
return cached;
|
|
5998
6195
|
}
|
|
5999
6196
|
const pending = pendingExchanges.get(cacheKey);
|
|
6000
6197
|
if (pending) return pending;
|
|
6001
6198
|
const runLocked = async () => {
|
|
6002
|
-
const recheck = await
|
|
6003
|
-
if (recheck
|
|
6199
|
+
const recheck = await readCachedToken(cacheKey, cache);
|
|
6200
|
+
if (recheck !== void 0) {
|
|
6201
|
+
if (options.debug) {
|
|
6202
|
+
console.log(
|
|
6203
|
+
`[auth] Using cached token (clientId: ${clientId}, locked recheck)`
|
|
6204
|
+
);
|
|
6205
|
+
}
|
|
6206
|
+
return recheck;
|
|
6207
|
+
}
|
|
6004
6208
|
const { accessToken, expiresIn } = await exchangeClientCredentials({
|
|
6005
6209
|
clientId: credentials.clientId,
|
|
6006
6210
|
clientSecret: credentials.clientSecret,
|
|
@@ -6058,7 +6262,7 @@ async function invalidateCredentialsToken(options) {
|
|
|
6058
6262
|
}
|
|
6059
6263
|
|
|
6060
6264
|
// src/sdk-version.ts
|
|
6061
|
-
var SDK_VERSION = (typeof process !== "undefined" && process.env ? "0.
|
|
6265
|
+
var SDK_VERSION = (typeof process !== "undefined" && process.env ? "0.52.0" : void 0) || "unknown";
|
|
6062
6266
|
|
|
6063
6267
|
// src/utils/open-url.ts
|
|
6064
6268
|
var nodePrefix = "node:";
|
|
@@ -6268,9 +6472,61 @@ var ZapierApiClient = class {
|
|
|
6268
6472
|
await sleep(delayMs, init?.signal ?? void 0);
|
|
6269
6473
|
}
|
|
6270
6474
|
};
|
|
6475
|
+
/**
|
|
6476
|
+
* Wrap an outbound HTTP call with the concurrency semaphore. Used by both
|
|
6477
|
+
* `rawFetch` (path-based) and the approval-poll path (absolute URL); each
|
|
6478
|
+
* caller acquires per-attempt, so 429 retry sleep is held but the gap
|
|
6479
|
+
* between approval polls and the human-approval wait are not.
|
|
6480
|
+
*
|
|
6481
|
+
* The release is registered in a finally that wraps the entire post-
|
|
6482
|
+
* acquire flow — including the `wait_end` event emission — so a throwing
|
|
6483
|
+
* `onEvent` handler can never leak a permit.
|
|
6484
|
+
*
|
|
6485
|
+
* Slot lifetime is intentionally tied to "fetch resolves" (headers
|
|
6486
|
+
* received), NOT to "response body fully consumed". WHATWG `fetch()`
|
|
6487
|
+
* resolves once headers are in; the body is still streaming. We rely on
|
|
6488
|
+
* that boundary so streaming responses (SSE, long-running chunked reads)
|
|
6489
|
+
* don't pin a permit for the lifetime of the stream — a single SSE
|
|
6490
|
+
* consumer would otherwise hold one of N slots for as long as the
|
|
6491
|
+
* connection stays open. Do not move the release into a path that awaits
|
|
6492
|
+
* body consumption (e.g. `parseResult` / `response.text()`); doing so
|
|
6493
|
+
* would silently break streaming consumers without failing any of the
|
|
6494
|
+
* short-request tests.
|
|
6495
|
+
*/
|
|
6496
|
+
this.withSemaphore = async (context, fn) => {
|
|
6497
|
+
const fastRelease = this.semaphore.tryAcquire();
|
|
6498
|
+
let waitStart = null;
|
|
6499
|
+
let release = fastRelease;
|
|
6500
|
+
if (release === null) {
|
|
6501
|
+
waitStart = Date.now();
|
|
6502
|
+
this.emitEvent("api:concurrency_wait_start", {
|
|
6503
|
+
url: context.url,
|
|
6504
|
+
method: context.method
|
|
6505
|
+
});
|
|
6506
|
+
release = await this.semaphore.acquire(context.signal ?? void 0);
|
|
6507
|
+
}
|
|
6508
|
+
const acquiredRelease = release;
|
|
6509
|
+
try {
|
|
6510
|
+
if (waitStart !== null) {
|
|
6511
|
+
this.emitEvent("api:concurrency_wait_end", {
|
|
6512
|
+
url: context.url,
|
|
6513
|
+
method: context.method,
|
|
6514
|
+
waitedMs: Date.now() - waitStart
|
|
6515
|
+
});
|
|
6516
|
+
}
|
|
6517
|
+
return await fn();
|
|
6518
|
+
} finally {
|
|
6519
|
+
acquiredRelease();
|
|
6520
|
+
}
|
|
6521
|
+
};
|
|
6271
6522
|
/**
|
|
6272
6523
|
* Perform a request with auth, header merging, and rate-limit (429) retries.
|
|
6273
6524
|
* Does NOT handle 403 approval_required — that's routed by `fetch`.
|
|
6525
|
+
*
|
|
6526
|
+
* Concurrency: a semaphore slot is held across the entire call, including
|
|
6527
|
+
* the 429 retry sleep inside `rawFetchUrl`. That keeps backpressure
|
|
6528
|
+
* coherent — when the server is rate-limiting us, we don't dump more
|
|
6529
|
+
* parallelism into the queue.
|
|
6274
6530
|
*/
|
|
6275
6531
|
this.rawFetch = async (path, init) => {
|
|
6276
6532
|
if (!path.startsWith("/")) {
|
|
@@ -6279,7 +6535,10 @@ var ZapierApiClient = class {
|
|
|
6279
6535
|
);
|
|
6280
6536
|
}
|
|
6281
6537
|
const { url, pathConfig: pathConfig2 } = this.buildUrl(path, init?.searchParams);
|
|
6282
|
-
return this.
|
|
6538
|
+
return this.withSemaphore(
|
|
6539
|
+
{ url, method: init?.method ?? "GET", signal: init?.signal },
|
|
6540
|
+
() => this.rawFetchUrl(url, init, pathConfig2)
|
|
6541
|
+
);
|
|
6283
6542
|
};
|
|
6284
6543
|
/**
|
|
6285
6544
|
* Approval-aware HTTP fetch.
|
|
@@ -6387,6 +6646,15 @@ var ZapierApiClient = class {
|
|
|
6387
6646
|
};
|
|
6388
6647
|
this.maxNetworkRetries = options.maxNetworkRetries ?? ZAPIER_MAX_NETWORK_RETRIES;
|
|
6389
6648
|
this.maxNetworkRetryDelayMs = options.maxNetworkRetryDelayMs ?? ZAPIER_MAX_NETWORK_RETRY_DELAY_MS;
|
|
6649
|
+
const requested = options.maxConcurrentRequests;
|
|
6650
|
+
const limit = requested === void 0 || Number.isNaN(requested) ? ZAPIER_MAX_CONCURRENT_REQUESTS : requested;
|
|
6651
|
+
if (limit !== Infinity && (!Number.isInteger(limit) || limit < 1 || limit > MAX_CONCURRENCY_LIMIT)) {
|
|
6652
|
+
throw new ZapierConfigurationError(
|
|
6653
|
+
`Invalid maxConcurrentRequests: ${limit} (expected positive integer 1-${MAX_CONCURRENCY_LIMIT} or Infinity)`,
|
|
6654
|
+
{ configType: "maxConcurrentRequests" }
|
|
6655
|
+
);
|
|
6656
|
+
}
|
|
6657
|
+
this.semaphore = createSemaphore(limit);
|
|
6390
6658
|
}
|
|
6391
6659
|
// Emit an event if onEvent handler is configured
|
|
6392
6660
|
emitEvent(type, payload) {
|
|
@@ -6639,7 +6907,9 @@ var ZapierApiClient = class {
|
|
|
6639
6907
|
if (data && typeof data === "object") {
|
|
6640
6908
|
headers["Content-Type"] = "application/json";
|
|
6641
6909
|
}
|
|
6642
|
-
const wasMissingAuthToken = options.authRequired && await this.getAuthToken({
|
|
6910
|
+
const wasMissingAuthToken = options.authRequired && await this.getAuthToken({
|
|
6911
|
+
requiredScopes: options.requiredScopes
|
|
6912
|
+
}) == null;
|
|
6643
6913
|
const response = await this.fetch(path, {
|
|
6644
6914
|
...options,
|
|
6645
6915
|
method,
|
|
@@ -6762,10 +7032,16 @@ var ZapierApiClient = class {
|
|
|
6762
7032
|
// poll_url is an absolute URL supplied by the server, so we use
|
|
6763
7033
|
// rawFetchUrl directly (skipping path resolution) but still share
|
|
6764
7034
|
// auth + interactive-header + 429-retry with the rest of the SDK.
|
|
6765
|
-
|
|
6766
|
-
|
|
6767
|
-
|
|
6768
|
-
|
|
7035
|
+
// Each individual poll request goes through the concurrency
|
|
7036
|
+
// semaphore — but we deliberately do not hold a slot across the
|
|
7037
|
+
// sleep between polls or across the human-approval wait.
|
|
7038
|
+
fetchPoll: () => this.withSemaphore(
|
|
7039
|
+
{ url: approval.poll_url, method: "GET" },
|
|
7040
|
+
() => this.rawFetchUrl(approval.poll_url, {
|
|
7041
|
+
method: "GET",
|
|
7042
|
+
headers: { Accept: "application/json" }
|
|
7043
|
+
})
|
|
7044
|
+
),
|
|
6769
7045
|
timeoutMs,
|
|
6770
7046
|
isPending: (body2) => {
|
|
6771
7047
|
const parsed = PollApprovalResponseSchema.safeParse(body2);
|
|
@@ -6833,6 +7109,28 @@ var createZapierApi = (options) => {
|
|
|
6833
7109
|
});
|
|
6834
7110
|
};
|
|
6835
7111
|
|
|
7112
|
+
// src/api/index.ts
|
|
7113
|
+
function getOrCreateApiClient(config) {
|
|
7114
|
+
const {
|
|
7115
|
+
baseUrl = ZAPIER_BASE_URL,
|
|
7116
|
+
credentials,
|
|
7117
|
+
token,
|
|
7118
|
+
api: providedApi,
|
|
7119
|
+
debug = false,
|
|
7120
|
+
fetch: customFetch
|
|
7121
|
+
} = config;
|
|
7122
|
+
if (providedApi) {
|
|
7123
|
+
return providedApi;
|
|
7124
|
+
}
|
|
7125
|
+
return createZapierApi({
|
|
7126
|
+
baseUrl,
|
|
7127
|
+
credentials,
|
|
7128
|
+
token,
|
|
7129
|
+
debug,
|
|
7130
|
+
fetch: customFetch
|
|
7131
|
+
});
|
|
7132
|
+
}
|
|
7133
|
+
|
|
6836
7134
|
// src/plugins/api/index.ts
|
|
6837
7135
|
var apiPlugin = definePlugin(
|
|
6838
7136
|
(sdk) => {
|
|
@@ -6845,6 +7143,7 @@ var apiPlugin = definePlugin(
|
|
|
6845
7143
|
debug = false,
|
|
6846
7144
|
maxNetworkRetries = ZAPIER_MAX_NETWORK_RETRIES,
|
|
6847
7145
|
maxNetworkRetryDelayMs = ZAPIER_MAX_NETWORK_RETRY_DELAY_MS,
|
|
7146
|
+
maxConcurrentRequests = ZAPIER_MAX_CONCURRENT_REQUESTS,
|
|
6848
7147
|
approvalTimeoutMs,
|
|
6849
7148
|
maxApprovalRetries,
|
|
6850
7149
|
approvalMode,
|
|
@@ -6859,6 +7158,7 @@ var apiPlugin = definePlugin(
|
|
|
6859
7158
|
onEvent,
|
|
6860
7159
|
maxNetworkRetries,
|
|
6861
7160
|
maxNetworkRetryDelayMs,
|
|
7161
|
+
maxConcurrentRequests,
|
|
6862
7162
|
approvalTimeoutMs,
|
|
6863
7163
|
maxApprovalRetries,
|
|
6864
7164
|
approvalMode,
|
|
@@ -8744,6 +9044,24 @@ var BaseSdkOptionsSchema = zod.z.object({
|
|
|
8744
9044
|
* Default is 60000 (60 seconds).
|
|
8745
9045
|
*/
|
|
8746
9046
|
maxNetworkRetryDelayMs: zod.z.number().optional().describe("Max delay in ms to wait for retry (default: 60000).").meta({ valueHint: "ms" }),
|
|
9047
|
+
/**
|
|
9048
|
+
* Maximum number of concurrent in-flight HTTP requests per client.
|
|
9049
|
+
* Requests beyond this limit queue in FIFO order until a slot frees.
|
|
9050
|
+
* Pass `Infinity` to disable. Default: 200.
|
|
9051
|
+
*
|
|
9052
|
+
* The description and meta are duplicated across the outer wrapper and
|
|
9053
|
+
* the inner numeric branch because the SDK and CLI doc generators walk
|
|
9054
|
+
* the schema differently — the SDK reader looks at wrappers only, while
|
|
9055
|
+
* the CLI reader recurses into union branches.
|
|
9056
|
+
*/
|
|
9057
|
+
maxConcurrentRequests: zod.z.union([
|
|
9058
|
+
zod.z.number().int().min(1).max(MAX_CONCURRENCY_LIMIT).describe(
|
|
9059
|
+
`Max concurrent in-flight HTTP requests (default: 200, max: ${MAX_CONCURRENCY_LIMIT}).`
|
|
9060
|
+
).meta({ valueHint: "count" }),
|
|
9061
|
+
zod.z.literal(Infinity)
|
|
9062
|
+
]).optional().describe(
|
|
9063
|
+
`Max concurrent in-flight HTTP requests (default: 200, max: ${MAX_CONCURRENCY_LIMIT}).`
|
|
9064
|
+
).meta({ valueHint: "count" }),
|
|
8747
9065
|
approvalTimeoutMs: zod.z.number().optional().describe("Timeout in ms for approval polling. Default: 600000 (10 min).").meta({ valueHint: "ms" }),
|
|
8748
9066
|
maxApprovalRetries: zod.z.number().optional().describe(
|
|
8749
9067
|
"Maximum number of sequential approval rounds per request (one per gating policy) before giving up. Default: 2."
|
|
@@ -8808,6 +9126,7 @@ exports.LeaseLimitPropertySchema = LeaseLimitPropertySchema;
|
|
|
8808
9126
|
exports.LeasePropertySchema = LeasePropertySchema;
|
|
8809
9127
|
exports.LeaseSecondsPropertySchema = LeaseSecondsPropertySchema;
|
|
8810
9128
|
exports.LimitPropertySchema = LimitPropertySchema;
|
|
9129
|
+
exports.MAX_CONCURRENCY_LIMIT = MAX_CONCURRENCY_LIMIT;
|
|
8811
9130
|
exports.MAX_PAGE_LIMIT = MAX_PAGE_LIMIT;
|
|
8812
9131
|
exports.OffsetPropertySchema = OffsetPropertySchema;
|
|
8813
9132
|
exports.OutputPropertySchema = OutputPropertySchema;
|
|
@@ -8823,6 +9142,7 @@ exports.TablesPropertySchema = TablesPropertySchema;
|
|
|
8823
9142
|
exports.TriggerInboxNamePropertySchema = TriggerInboxNamePropertySchema;
|
|
8824
9143
|
exports.TriggerInboxPropertySchema = TriggerInboxPropertySchema;
|
|
8825
9144
|
exports.ZAPIER_BASE_URL = ZAPIER_BASE_URL;
|
|
9145
|
+
exports.ZAPIER_MAX_CONCURRENT_REQUESTS = ZAPIER_MAX_CONCURRENT_REQUESTS;
|
|
8826
9146
|
exports.ZAPIER_MAX_NETWORK_RETRIES = ZAPIER_MAX_NETWORK_RETRIES;
|
|
8827
9147
|
exports.ZAPIER_MAX_NETWORK_RETRY_DELAY_MS = ZAPIER_MAX_NETWORK_RETRY_DELAY_MS;
|
|
8828
9148
|
exports.ZapierAbortDrainSignal = ZapierAbortDrainSignal;
|
|
@@ -8875,6 +9195,7 @@ exports.createSdk = createSdk;
|
|
|
8875
9195
|
exports.createTableFieldsPlugin = createTableFieldsPlugin;
|
|
8876
9196
|
exports.createTablePlugin = createTablePlugin;
|
|
8877
9197
|
exports.createTableRecordsPlugin = createTableRecordsPlugin;
|
|
9198
|
+
exports.createZapierApi = createZapierApi;
|
|
8878
9199
|
exports.createZapierSdk = createZapierSdk;
|
|
8879
9200
|
exports.createZapierSdkWithoutRegistry = createZapierSdkWithoutRegistry;
|
|
8880
9201
|
exports.definePlugin = definePlugin;
|
|
@@ -8898,6 +9219,7 @@ exports.getConnectionPlugin = getConnectionPlugin;
|
|
|
8898
9219
|
exports.getCpuTime = getCpuTime;
|
|
8899
9220
|
exports.getCurrentTimestamp = getCurrentTimestamp;
|
|
8900
9221
|
exports.getMemoryUsage = getMemoryUsage;
|
|
9222
|
+
exports.getOrCreateApiClient = getOrCreateApiClient;
|
|
8901
9223
|
exports.getOsInfo = getOsInfo;
|
|
8902
9224
|
exports.getPlatformVersions = getPlatformVersions;
|
|
8903
9225
|
exports.getPreferredManifestEntryKey = getPreferredManifestEntryKey;
|
|
@@ -8932,6 +9254,7 @@ exports.listTableRecordsPlugin = listTableRecordsPlugin;
|
|
|
8932
9254
|
exports.listTablesPlugin = listTablesPlugin;
|
|
8933
9255
|
exports.logDeprecation = logDeprecation;
|
|
8934
9256
|
exports.manifestPlugin = manifestPlugin;
|
|
9257
|
+
exports.parseConcurrencyEnvVar = parseConcurrencyEnvVar;
|
|
8935
9258
|
exports.readManifestFromFile = readManifestFromFile;
|
|
8936
9259
|
exports.registryPlugin = registryPlugin;
|
|
8937
9260
|
exports.requestPlugin = requestPlugin;
|
package/dist/index.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { u as Action, d as ActionEntry,
|
|
1
|
+
export { u as Action, d as ActionEntry, cg as ActionExecutionOptions, y as ActionExecutionResult, z as ActionField, H as ActionFieldChoice, aU as ActionItem, bv as ActionKeyProperty, b3 as ActionKeyPropertySchema, bw as ActionProperty, b4 as ActionPropertySchema, aq as ActionResolverItem, bH as ActionTimeoutMsProperty, bf as ActionTimeoutMsPropertySchema, ar as ActionTypeItem, bu as ActionTypeProperty, b2 as ActionTypePropertySchema, b as AddActionEntryOptions, c as AddActionEntryResult, A as ApiClient, bU as ApiError, dB as ApiEvent, c_ as ApiPluginOptions, d0 as ApiPluginProvides, v as App, ch as AppFactoryInput, aS as AppItem, bs as AppKeyProperty, b0 as AppKeyPropertySchema, bt as AppProperty, b1 as AppPropertySchema, aB as ApplicationLifecycleEventData, c9 as ApprovalStatus, cf as AppsPluginProvides, bM as AppsProperty, bk as AppsPropertySchema, a0 as ArrayResolver, dA as AuthEvent, bA as AuthenticationIdProperty, b7 as AuthenticationIdPropertySchema, ax as BaseEvent, aj as BaseSdkOptionsSchema, a8 as BatchOptions, cN as CONTEXT_CACHE_MAX_SIZE, cM as CONTEXT_CACHE_TTL_MS, x as Choice, dH as ClientCredentialsObject, dS as ClientCredentialsObjectSchema, K as Connection, d_ as ConnectionEntry, dZ as ConnectionEntrySchema, by as ConnectionIdProperty, b6 as ConnectionIdPropertySchema, aT as ConnectionItem, bz as ConnectionProperty, b8 as ConnectionPropertySchema, e0 as ConnectionsMap, d$ as ConnectionsMapSchema, e2 as ConnectionsPluginProvides, bO as ConnectionsProperty, bm as ConnectionsPropertySchema, O as ConnectionsResponse, cz as CreateClientCredentialsPluginProvides, er as CreateTableFieldsPluginProvides, el as CreateTablePluginProvides, ez as CreateTableRecordsPluginProvides, dE as Credentials, dX as CredentialsFunction, dW as CredentialsFunctionSchema, dG as CredentialsObject, dU as CredentialsObjectSchema, dY as CredentialsSchema, e7 as DEFAULT_ACTION_TIMEOUT_MS, ee as DEFAULT_APPROVAL_TIMEOUT_MS, cW as DEFAULT_CONFIG_PATH, ef as DEFAULT_MAX_APPROVAL_RETRIES, e6 as DEFAULT_PAGE_SIZE, bF as DebugProperty, bd as DebugPropertySchema, cB as DeleteClientCredentialsPluginProvides, et as DeleteTableFieldsPluginProvides, en as DeleteTablePluginProvides, eB as DeleteTableRecordsPluginProvides, o as DrainTriggerInboxCallback, p as DrainTriggerInboxErrorObserver, D as DrainTriggerInboxOptions, i as DynamicResolver, aC as EnhancedErrorEventData, bV as ErrorOptions, dD as EventCallback, aA as EventContext, E as EventEmissionContext, az as EventEmissionProvides, cj as FetchPluginProvides, w as Field, bL as FieldsProperty, bj as FieldsPropertySchema, a3 as FieldsResolver, F as FieldsetItem, s as FindFirstAuthenticationPluginProvides, cJ as FindFirstConnectionPluginProvides, t as FindUniqueAuthenticationPluginProvides, cL as FindUniqueConnectionPluginProvides, Y as FormatMetadata, X as FormattedItem, ai as FunctionDeprecation, aZ as FunctionOptions, ah as FunctionRegistryEntry, ct as GetActionInputFieldsSchemaPluginProvides, cF as GetActionPluginProvides, cD as GetAppPluginProvides, G as GetAuthenticationPluginProvides, cH as GetConnectionPluginProvides, cZ as GetProfilePluginProvides, ej as GetTablePluginProvides, ev as GetTableRecordPluginProvides, aW as InfoFieldItem, aV as InputFieldItem, bx as InputFieldProperty, b5 as InputFieldPropertySchema, bB as InputsProperty, b9 as InputsPropertySchema, bT as LeaseLimitProperty, br as LeaseLimitPropertySchema, bR as LeaseProperty, bp as LeasePropertySchema, bS as LeaseSecondsProperty, bq as LeaseSecondsPropertySchema, L as LeasedTriggerMessageItem, bC as LimitProperty, ba as LimitPropertySchema, cr as ListActionInputFieldChoicesPluginProvides, cp as ListActionInputFieldsPluginProvides, cn as ListActionsPluginProvides, cl as ListAppsPluginProvides, q as ListAuthenticationsPluginProvides, cx as ListClientCredentialsPluginProvides, cv as ListConnectionsPluginProvides, ep as ListTableFieldsPluginProvides, ex as ListTableRecordsPluginProvides, eh as ListTablesPluginProvides, dC as LoadingEvent, ea as MAX_CONCURRENCY_LIMIT, e5 as MAX_PAGE_LIMIT, M as Manifest, cX as ManifestEntry, cS as ManifestPluginOptions, cV as ManifestPluginProvides, ay as MethodCalledEvent, aD as MethodCalledEventData, N as Need, I as NeedsRequest, J as NeedsResponse, bD as OffsetProperty, bb as OffsetPropertySchema, _ as OutputFormatter, bE as OutputProperty, bc as OutputPropertySchema, a$ as PaginatedSdkFunction, e as PaginatedSdkResult, bG as ParamsProperty, be as ParamsPropertySchema, dI as PkceCredentialsObject, dT as PkceCredentialsObjectSchema, ak as Plugin, P as PluginMeta, al as PluginProvides, au as PollOptions, g as PositionalMetadata, c7 as RateLimitInfo, bJ as RecordProperty, bh as RecordPropertySchema, bK as RecordsProperty, bi as RecordsPropertySchema, ad as RelayFetchSchema, ac as RelayRequestSchema, at as RequestOptions, cR as RequestPluginProvides, dm as ResolveAuthTokenOptions, dN as ResolveCredentialsOptions, R as ResolvedAppLocator, dF as ResolvedCredentials, dV as ResolvedCredentialsSchema, $ as Resolver, a1 as ResolverMetadata, aX as RootFieldItem, cP as RunActionPluginProvides, dz as SdkEvent, a_ as SdkPage, a2 as StaticResolver, bI as TableProperty, bg as TablePropertySchema, bN as TablesProperty, bl as TablesPropertySchema, bQ as TriggerInboxNameProperty, bo as TriggerInboxNamePropertySchema, bP as TriggerInboxProperty, bn as TriggerInboxPropertySchema, T as TriggerMessageStatus, U as UpdateManifestEntryOptions, a as UpdateManifestEntryResult, eD as UpdateTableRecordsPluginProvides, Q as UserProfile, aY as UserProfileItem, j as WatchTriggerInboxOptions, W as WithAddPlugin, e3 as ZAPIER_BASE_URL, ec as ZAPIER_MAX_CONCURRENT_REQUESTS, e8 as ZAPIER_MAX_NETWORK_RETRIES, e9 as ZAPIER_MAX_NETWORK_RETRY_DELAY_MS, m as ZapierAbortDrainSignal, c5 as ZapierActionError, bX as ZapierApiError, bY as ZapierAppNotFoundError, ca as ZapierApprovalError, b$ as ZapierAuthenticationError, c3 as ZapierBundleError, dv as ZapierCache, dw as ZapierCacheEntry, dx as ZapierCacheSetOptions, c2 as ZapierConfigurationError, c6 as ZapierConflictError, bW as ZapierError, h as ZapierFetchInitOptions, c0 as ZapierNotFoundError, c8 as ZapierRateLimitError, cb as ZapierRelayError, n as ZapierReleaseTriggerMessageSignal, c1 as ZapierResourceNotFoundError, eF as ZapierSdk, l as ZapierSdkApps, Z as ZapierSdkOptions, cd as ZapierSignal, c4 as ZapierTimeoutError, b_ as ZapierUnknownError, bZ as ZapierValidationError, d3 as actionKeyResolver, d2 as actionTypeResolver, c$ as apiPlugin, d1 as appKeyResolver, ce as appsPlugin, d5 as authenticationIdGenericResolver, d4 as authenticationIdResolver, a7 as batch, aN as buildApplicationLifecycleEvent, a9 as buildCapabilityMessage, aP as buildErrorEvent, aO as buildErrorEventWithContext, aR as buildMethodCalledEvent, dn as clearTokenCache, d9 as clientCredentialsNameResolver, da as clientIdResolver, ap as composePlugins, d5 as connectionIdGenericResolver, d4 as connectionIdResolver, e1 as connectionsPlugin, aQ as createBaseEvent, cy as createClientCredentialsPlugin, V as createFunction, dy as createMemoryCache, ag as createOptionsPlugin, ao as createPaginatedPluginMethod, an as createPluginMethod, af as createSdk, eq as createTableFieldsPlugin, ek as createTablePlugin, ey as createTableRecordsPlugin, av as createZapierApi, eE as createZapierSdk, ae as createZapierSdkWithoutRegistry, am as definePlugin, cA as deleteClientCredentialsPlugin, es as deleteTableFieldsPlugin, em as deleteTablePlugin, eA as deleteTableRecordsPlugin, ci as fetchPlugin, cI as findFirstConnectionPlugin, f as findManifestEntry, cK as findUniqueConnectionPlugin, cc as formatErrorMessage, aE as generateEventId, cs as getActionInputFieldsSchemaPlugin, cE as getActionPlugin, cC as getAppPlugin, dQ as getBaseUrlFromCredentials, aK as getCiPlatform, dR as getClientIdFromCredentials, cG as getConnectionPlugin, aM as getCpuTime, aF as getCurrentTimestamp, aL as getMemoryUsage, aw as getOrCreateApiClient, aH as getOsInfo, aI as getPlatformVersions, cT as getPreferredManifestEntryKey, cY as getProfilePlugin, aG as getReleaseId, ei as getTablePlugin, eu as getTableRecordPlugin, ds as getTokenFromCliLogin, ed as getZapierApprovalMode, e4 as getZapierSdkService, dq as injectCliLogin, d8 as inputFieldKeyResolver, d7 as inputsAllOptionalResolver, d6 as inputsResolver, dp as invalidateCachedToken, du as invalidateCredentialsToken, aJ as isCi, dr as isCliLoginAvailable, dJ as isClientCredentials, dM as isCredentialsFunction, dL as isCredentialsObject, dK as isPkceCredentials, S as isPositional, cq as listActionInputFieldChoicesPlugin, co as listActionInputFieldsPlugin, cm as listActionsPlugin, ck as listAppsPlugin, cw as listClientCredentialsPlugin, cu as listConnectionsPlugin, eo as listTableFieldsPlugin, ew as listTableRecordsPlugin, eg as listTablesPlugin, aa as logDeprecation, cU as manifestPlugin, eb as parseConcurrencyEnvVar, r as readManifestFromFile, as as registryPlugin, cQ as requestPlugin, ab as resetDeprecationWarnings, dt as resolveAuthToken, dP as resolveCredentials, dO as resolveCredentialsFromEnv, cO as runActionPlugin, a4 as runWithTelemetryContext, df as tableFieldIdsResolver, dh as tableFieldsResolver, dk as tableFiltersResolver, db as tableIdResolver, dg as tableNameResolver, dd as tableRecordIdResolver, de as tableRecordIdsResolver, di as tableRecordsResolver, dl as tableSortResolver, dj as tableUpdateRecordsResolver, a5 as toSnakeCase, a6 as toTitleCase, dc as triggerInboxResolver, eC as updateTableRecordsPlugin } from './index-DcdtPei-.mjs';
|
|
2
2
|
import 'zod';
|
|
3
3
|
import '@zapier/zapier-sdk-core/v0/schemas/connections';
|
|
4
4
|
import '@zapier/policy-context';
|
package/dist/index.d.ts
CHANGED
|
@@ -66,8 +66,9 @@ export { definePlugin, createPluginMethod, createPaginatedPluginMethod, composeP
|
|
|
66
66
|
export type { ActionItem as ActionResolverItem } from "./resolvers/actionKey";
|
|
67
67
|
export type { ActionTypeItem } from "./resolvers/actionType";
|
|
68
68
|
export type { ResolvedAppLocator } from "./utils/domain-utils";
|
|
69
|
-
export type { ApiClient, RequestOptions, PollOptions } from "./api/types";
|
|
70
69
|
export { registryPlugin } from "./plugins/registry";
|
|
70
|
+
export type { ApiClient, RequestOptions, PollOptions } from "./api/types";
|
|
71
|
+
export { createZapierApi, getOrCreateApiClient } from "./api";
|
|
71
72
|
export type { ZapierSdk } from "./sdk";
|
|
72
73
|
export type { BaseEvent, MethodCalledEvent } from "./types/telemetry-events";
|
|
73
74
|
export type { EventEmissionContext, EventEmissionProvides, EventContext, ApplicationLifecycleEventData, EnhancedErrorEventData, MethodCalledEventData, } from "./plugins/eventEmission";
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,cAAc,gBAAgB,CAAC;AAC/B,cAAc,mBAAmB,CAAC;AAClC,cAAc,oBAAoB,CAAC;AACnC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,iBAAiB,CAAC;AAChC,OAAO,EACL,sBAAsB,EACtB,iCAAiC,GAClC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