@zapier/zapier-sdk 0.23.2 → 0.25.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 +15 -0
- package/README.md +29 -56
- package/dist/api/polling.d.ts +7 -0
- package/dist/api/polling.d.ts.map +1 -1
- package/dist/api/polling.js +21 -19
- package/dist/api/polling.test.js +43 -1
- package/dist/constants.d.ts +4 -0
- package/dist/constants.d.ts.map +1 -1
- package/dist/constants.js +4 -0
- package/dist/index.cjs +162 -128
- package/dist/index.d.mts +59 -31
- package/dist/index.mjs +161 -129
- package/dist/plugins/apps/index.d.ts.map +1 -1
- package/dist/plugins/apps/index.js +2 -1
- package/dist/plugins/apps/schemas.d.ts +1 -0
- package/dist/plugins/apps/schemas.d.ts.map +1 -1
- package/dist/plugins/apps/schemas.js +2 -1
- package/dist/plugins/fetch/index.d.ts +13 -5
- package/dist/plugins/fetch/index.d.ts.map +1 -1
- package/dist/plugins/fetch/index.js +85 -33
- package/dist/plugins/fetch/index.test.d.ts +2 -0
- package/dist/plugins/fetch/index.test.d.ts.map +1 -0
- package/dist/plugins/fetch/index.test.js +296 -0
- package/dist/plugins/fetch/schemas.d.ts.map +1 -1
- package/dist/plugins/fetch/schemas.js +10 -5
- package/dist/plugins/registry/index.d.ts.map +1 -1
- package/dist/plugins/registry/index.js +1 -0
- package/dist/plugins/request/index.d.ts +8 -7
- package/dist/plugins/request/index.d.ts.map +1 -1
- package/dist/plugins/request/index.js +15 -55
- package/dist/plugins/request/index.test.js +106 -2
- package/dist/plugins/request/schemas.d.ts +0 -2
- package/dist/plugins/request/schemas.d.ts.map +1 -1
- package/dist/plugins/request/schemas.js +0 -3
- package/dist/plugins/runAction/index.d.ts.map +1 -1
- package/dist/plugins/runAction/index.js +5 -3
- package/dist/plugins/runAction/index.test.js +16 -0
- package/dist/plugins/runAction/schemas.d.ts +1 -0
- package/dist/plugins/runAction/schemas.d.ts.map +1 -1
- package/dist/plugins/runAction/schemas.js +2 -1
- package/dist/schemas/Action.d.ts +1 -1
- package/dist/sdk.d.ts +8 -7
- package/dist/sdk.d.ts.map +1 -1
- package/dist/sdk.js +2 -2
- package/dist/types/plugin.d.ts +6 -0
- package/dist/types/plugin.d.ts.map +1 -1
- package/dist/types/properties.d.ts +2 -0
- package/dist/types/properties.d.ts.map +1 -1
- package/dist/types/properties.js +6 -1
- package/dist/types/sdk.d.ts +6 -0
- package/dist/types/sdk.d.ts.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -59,6 +59,7 @@ function isPositional(schema) {
|
|
|
59
59
|
// src/constants.ts
|
|
60
60
|
var ZAPIER_BASE_URL = process.env.ZAPIER_BASE_URL || "https://zapier.com";
|
|
61
61
|
var MAX_PAGE_LIMIT = 1e4;
|
|
62
|
+
var DEFAULT_ACTION_TIMEOUT_MS = 18e4;
|
|
62
63
|
var ZAPIER_CREDENTIALS = process.env.ZAPIER_CREDENTIALS;
|
|
63
64
|
var ZAPIER_CREDENTIALS_CLIENT_ID = process.env.ZAPIER_CREDENTIALS_CLIENT_ID;
|
|
64
65
|
var ZAPIER_CREDENTIALS_CLIENT_SECRET = process.env.ZAPIER_CREDENTIALS_CLIENT_SECRET;
|
|
@@ -90,6 +91,9 @@ var OffsetPropertySchema = zod.z.number().int().min(0).default(0).describe("Numb
|
|
|
90
91
|
var OutputPropertySchema = zod.z.string().describe("Output file path");
|
|
91
92
|
var DebugPropertySchema = zod.z.boolean().default(false).describe("Enable debug logging");
|
|
92
93
|
var ParamsPropertySchema = zod.z.record(zod.z.string(), zod.z.unknown()).describe("Additional parameters");
|
|
94
|
+
var ActionTimeoutMsPropertySchema = zod.z.number().min(1e3).optional().describe(
|
|
95
|
+
`Maximum time to wait for action completion in milliseconds (default: ${DEFAULT_ACTION_TIMEOUT_MS})`
|
|
96
|
+
);
|
|
93
97
|
|
|
94
98
|
// src/types/errors.ts
|
|
95
99
|
var ZapierError = class extends Error {
|
|
@@ -227,7 +231,8 @@ HTTP Status: ${error.statusCode}`;
|
|
|
227
231
|
}
|
|
228
232
|
var ActionExecutionInputSchema = zod.z.object({
|
|
229
233
|
inputs: zod.z.record(zod.z.string(), zod.z.unknown()).optional(),
|
|
230
|
-
authenticationId: AuthenticationIdPropertySchema.optional()
|
|
234
|
+
authenticationId: AuthenticationIdPropertySchema.optional(),
|
|
235
|
+
timeoutMs: ActionTimeoutMsPropertySchema
|
|
231
236
|
}).describe(
|
|
232
237
|
"Execute an action with the given inputs for the bound app, as an alternative to runAction"
|
|
233
238
|
);
|
|
@@ -264,7 +269,11 @@ var ActionResultItemSchema = withFormatter(
|
|
|
264
269
|
function createActionFunction(appKey, actionType, actionKey, options, pinnedAuthId) {
|
|
265
270
|
return (actionOptions = {}) => {
|
|
266
271
|
const { sdk } = options;
|
|
267
|
-
const {
|
|
272
|
+
const {
|
|
273
|
+
inputs,
|
|
274
|
+
authenticationId: providedAuthenticationId,
|
|
275
|
+
timeoutMs
|
|
276
|
+
} = actionOptions;
|
|
268
277
|
const authenticationId = pinnedAuthId ?? providedAuthenticationId;
|
|
269
278
|
if (!authenticationId) {
|
|
270
279
|
throw new ZapierValidationError(
|
|
@@ -276,7 +285,8 @@ function createActionFunction(appKey, actionType, actionKey, options, pinnedAuth
|
|
|
276
285
|
actionType,
|
|
277
286
|
actionKey,
|
|
278
287
|
inputs,
|
|
279
|
-
authenticationId
|
|
288
|
+
authenticationId,
|
|
289
|
+
timeoutMs
|
|
280
290
|
});
|
|
281
291
|
};
|
|
282
292
|
}
|
|
@@ -384,71 +394,136 @@ var appsPlugin = ({ sdk }) => {
|
|
|
384
394
|
}
|
|
385
395
|
};
|
|
386
396
|
};
|
|
387
|
-
var FetchUrlSchema = zod.z.union([zod.z.string(), zod.z.instanceof(URL)]).describe(
|
|
397
|
+
var FetchUrlSchema = zod.z.union([zod.z.string(), zod.z.instanceof(URL)]).describe(
|
|
398
|
+
"The full URL of the API endpoint to call (proxied through Zapier's Relay service)"
|
|
399
|
+
);
|
|
388
400
|
var FetchInitSchema = zod.z.object({
|
|
389
|
-
method: zod.z.enum(["GET", "POST", "PUT", "DELETE", "PATCH", "HEAD", "OPTIONS"]).optional(),
|
|
390
|
-
headers: zod.z.record(zod.z.string(), zod.z.string()).optional(),
|
|
401
|
+
method: zod.z.enum(["GET", "POST", "PUT", "DELETE", "PATCH", "HEAD", "OPTIONS"]).optional().describe("HTTP method for the request (defaults to GET)"),
|
|
402
|
+
headers: zod.z.record(zod.z.string(), zod.z.string()).optional().describe("HTTP headers to include in the request"),
|
|
391
403
|
body: zod.z.union([
|
|
392
404
|
zod.z.string(),
|
|
393
405
|
zod.z.instanceof(FormData),
|
|
394
406
|
zod.z.instanceof(URLSearchParams)
|
|
395
|
-
]).optional()
|
|
407
|
+
]).optional().describe(
|
|
408
|
+
"Request body \u2014 JSON strings are auto-detected and Content-Type is set accordingly"
|
|
409
|
+
),
|
|
396
410
|
authenticationId: AuthenticationIdPropertySchema.optional(),
|
|
397
411
|
callbackUrl: zod.z.string().optional().describe("URL to send async response to (makes request async)"),
|
|
398
412
|
authenticationTemplate: zod.z.string().optional().describe(
|
|
399
413
|
"Optional JSON string authentication template to bypass Notary lookup"
|
|
400
414
|
)
|
|
401
|
-
}).optional().describe(
|
|
415
|
+
}).optional().describe(
|
|
416
|
+
"Request options including method, headers, body, and authentication"
|
|
417
|
+
);
|
|
418
|
+
|
|
419
|
+
// src/utils/id-utils.ts
|
|
420
|
+
function coerceToNumericId(fieldName, value) {
|
|
421
|
+
if (value === "") {
|
|
422
|
+
throw new ZapierValidationError(`The ${fieldName} cannot be empty`);
|
|
423
|
+
}
|
|
424
|
+
const numericValue = typeof value === "number" ? value : Number(value);
|
|
425
|
+
if (!Number.isFinite(numericValue)) {
|
|
426
|
+
throw new ZapierValidationError(
|
|
427
|
+
`The ${fieldName} "${value}" could not be converted to a number`
|
|
428
|
+
);
|
|
429
|
+
}
|
|
430
|
+
return numericValue;
|
|
431
|
+
}
|
|
402
432
|
|
|
403
433
|
// src/plugins/fetch/index.ts
|
|
404
|
-
|
|
434
|
+
function transformUrlToRelayPath(url) {
|
|
435
|
+
const targetUrl = new URL(url);
|
|
436
|
+
return `/relay/${targetUrl.host}${targetUrl.pathname}${targetUrl.search}${targetUrl.hash}`;
|
|
437
|
+
}
|
|
438
|
+
function normalizeHeaders(optionsHeaders) {
|
|
439
|
+
const headers = {};
|
|
440
|
+
if (!optionsHeaders) {
|
|
441
|
+
return headers;
|
|
442
|
+
}
|
|
443
|
+
const headerEntries = optionsHeaders instanceof Headers ? Array.from(optionsHeaders.entries()) : Array.isArray(optionsHeaders) ? optionsHeaders : Object.entries(optionsHeaders);
|
|
444
|
+
for (const [key, value] of headerEntries) {
|
|
445
|
+
headers[key] = value;
|
|
446
|
+
}
|
|
447
|
+
return headers;
|
|
448
|
+
}
|
|
449
|
+
var fetchPlugin = ({ context }) => {
|
|
405
450
|
return {
|
|
406
451
|
fetch: async function fetch2(url, init) {
|
|
452
|
+
const { api } = context;
|
|
407
453
|
const startTime = Date.now();
|
|
454
|
+
const isNested = init?._telemetry?.isNested === true;
|
|
408
455
|
try {
|
|
409
456
|
const {
|
|
410
457
|
authenticationId,
|
|
411
458
|
callbackUrl,
|
|
412
459
|
authenticationTemplate,
|
|
460
|
+
_telemetry,
|
|
413
461
|
...fetchInit
|
|
414
462
|
} = init || {};
|
|
415
|
-
const
|
|
416
|
-
|
|
417
|
-
|
|
463
|
+
const relayPath = transformUrlToRelayPath(url);
|
|
464
|
+
const headers = normalizeHeaders(
|
|
465
|
+
fetchInit.headers
|
|
466
|
+
);
|
|
467
|
+
const hasContentType = Object.keys(headers).some(
|
|
468
|
+
(k) => k.toLowerCase() === "content-type"
|
|
469
|
+
);
|
|
470
|
+
if (fetchInit.body && !hasContentType) {
|
|
471
|
+
const bodyStr = typeof fetchInit.body === "string" ? fetchInit.body : JSON.stringify(fetchInit.body);
|
|
472
|
+
const trimmed = bodyStr.trimStart();
|
|
473
|
+
if (trimmed.startsWith("{") || trimmed.startsWith("[")) {
|
|
474
|
+
headers["Content-Type"] = "application/json; charset=utf-8";
|
|
475
|
+
}
|
|
476
|
+
}
|
|
477
|
+
if (authenticationId) {
|
|
478
|
+
headers["X-Relay-Authentication-Id"] = coerceToNumericId(
|
|
479
|
+
"authenticationId",
|
|
480
|
+
authenticationId
|
|
481
|
+
).toString();
|
|
482
|
+
}
|
|
483
|
+
if (callbackUrl) {
|
|
484
|
+
headers["X-Relay-Callback-Url"] = callbackUrl;
|
|
485
|
+
}
|
|
486
|
+
if (authenticationTemplate) {
|
|
487
|
+
headers["X-Authentication-Template"] = authenticationTemplate;
|
|
488
|
+
}
|
|
489
|
+
const result = await api.fetch(relayPath, {
|
|
490
|
+
method: fetchInit.method ?? "GET",
|
|
418
491
|
body: fetchInit.body,
|
|
419
|
-
headers
|
|
420
|
-
|
|
421
|
-
callbackUrl,
|
|
422
|
-
authenticationTemplate,
|
|
423
|
-
_telemetry: { isNested: true }
|
|
424
|
-
});
|
|
425
|
-
context.eventEmission.emitMethodCalled({
|
|
426
|
-
method_name: "fetch",
|
|
427
|
-
execution_duration_ms: Date.now() - startTime,
|
|
428
|
-
success_flag: true,
|
|
429
|
-
error_message: null,
|
|
430
|
-
error_type: null,
|
|
431
|
-
argument_count: init ? 2 : 1,
|
|
432
|
-
is_paginated: false
|
|
492
|
+
headers,
|
|
493
|
+
authRequired: true
|
|
433
494
|
});
|
|
495
|
+
if (!isNested) {
|
|
496
|
+
context.eventEmission.emitMethodCalled({
|
|
497
|
+
method_name: "fetch",
|
|
498
|
+
execution_duration_ms: Date.now() - startTime,
|
|
499
|
+
success_flag: true,
|
|
500
|
+
error_message: null,
|
|
501
|
+
error_type: null,
|
|
502
|
+
argument_count: init ? 2 : 1,
|
|
503
|
+
is_paginated: false
|
|
504
|
+
});
|
|
505
|
+
}
|
|
434
506
|
return result;
|
|
435
507
|
} catch (error) {
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
508
|
+
if (!isNested) {
|
|
509
|
+
context.eventEmission.emitMethodCalled({
|
|
510
|
+
method_name: "fetch",
|
|
511
|
+
execution_duration_ms: Date.now() - startTime,
|
|
512
|
+
success_flag: false,
|
|
513
|
+
error_message: error instanceof Error ? error.message : String(error),
|
|
514
|
+
error_type: error instanceof Error ? error.constructor.name : "Unknown",
|
|
515
|
+
argument_count: init ? 2 : 1,
|
|
516
|
+
is_paginated: false
|
|
517
|
+
});
|
|
518
|
+
}
|
|
445
519
|
throw error;
|
|
446
520
|
}
|
|
447
521
|
},
|
|
448
522
|
context: {
|
|
449
523
|
meta: {
|
|
450
524
|
fetch: {
|
|
451
|
-
|
|
525
|
+
description: "Make authenticated HTTP requests to any API through Zapier's Relay service. Pass an authenticationId to automatically inject the user's stored credentials (OAuth tokens, API keys, etc.) into the outgoing request. Mirrors the native fetch(url, init?) signature with additional Zapier-specific options.",
|
|
526
|
+
packages: ["sdk", "cli", "mcp"],
|
|
452
527
|
categories: ["http"],
|
|
453
528
|
returnType: "Response",
|
|
454
529
|
inputParameters: [
|
|
@@ -1827,20 +1902,6 @@ var RootFieldItemSchema = zod.z.union([
|
|
|
1827
1902
|
FieldsetItemSchema
|
|
1828
1903
|
]);
|
|
1829
1904
|
|
|
1830
|
-
// src/utils/id-utils.ts
|
|
1831
|
-
function coerceToNumericId(fieldName, value) {
|
|
1832
|
-
if (value === "") {
|
|
1833
|
-
throw new ZapierValidationError(`The ${fieldName} cannot be empty`);
|
|
1834
|
-
}
|
|
1835
|
-
const numericValue = typeof value === "number" ? value : Number(value);
|
|
1836
|
-
if (!Number.isFinite(numericValue)) {
|
|
1837
|
-
throw new ZapierValidationError(
|
|
1838
|
-
`The ${fieldName} "${value}" could not be converted to a number`
|
|
1839
|
-
);
|
|
1840
|
-
}
|
|
1841
|
-
return numericValue;
|
|
1842
|
-
}
|
|
1843
|
-
|
|
1844
1905
|
// src/services/implementations.ts
|
|
1845
1906
|
async function fetchImplementationNeeds({
|
|
1846
1907
|
api,
|
|
@@ -2680,6 +2741,7 @@ var RunActionSchema = zod.z.object({
|
|
|
2680
2741
|
inputs: InputsPropertySchema.optional().describe(
|
|
2681
2742
|
"Input parameters for the action"
|
|
2682
2743
|
),
|
|
2744
|
+
timeoutMs: ActionTimeoutMsPropertySchema,
|
|
2683
2745
|
pageSize: zod.z.number().min(1).optional().describe("Number of results per page"),
|
|
2684
2746
|
maxItems: zod.z.number().min(1).optional().describe("Maximum total items to return across all pages"),
|
|
2685
2747
|
cursor: zod.z.string().optional().describe("Cursor to start from")
|
|
@@ -2695,7 +2757,8 @@ async function executeAction(actionOptions) {
|
|
|
2695
2757
|
actionKey,
|
|
2696
2758
|
actionType,
|
|
2697
2759
|
executionOptions,
|
|
2698
|
-
authenticationId
|
|
2760
|
+
authenticationId,
|
|
2761
|
+
timeoutMs
|
|
2699
2762
|
} = actionOptions;
|
|
2700
2763
|
const selectedApi = await context.getVersionedImplementationId(appKey);
|
|
2701
2764
|
if (!selectedApi) {
|
|
@@ -2725,6 +2788,7 @@ async function executeAction(actionOptions) {
|
|
|
2725
2788
|
return await api.poll(`/zapier/api/actions/v1/runs/${runId}`, {
|
|
2726
2789
|
successStatus: 200,
|
|
2727
2790
|
pendingStatus: 202,
|
|
2791
|
+
timeoutMs: timeoutMs ?? DEFAULT_ACTION_TIMEOUT_MS,
|
|
2728
2792
|
isPending: (result) => {
|
|
2729
2793
|
const data = result?.data;
|
|
2730
2794
|
return data?.status === "waiting";
|
|
@@ -2740,7 +2804,8 @@ var runActionPlugin = ({ sdk, context }) => {
|
|
|
2740
2804
|
actionKey,
|
|
2741
2805
|
actionType,
|
|
2742
2806
|
authenticationId,
|
|
2743
|
-
inputs = {}
|
|
2807
|
+
inputs = {},
|
|
2808
|
+
timeoutMs
|
|
2744
2809
|
} = options;
|
|
2745
2810
|
const actionData = await sdk.getAction({
|
|
2746
2811
|
appKey,
|
|
@@ -2764,7 +2829,9 @@ var runActionPlugin = ({ sdk, context }) => {
|
|
|
2764
2829
|
actionKey,
|
|
2765
2830
|
actionType,
|
|
2766
2831
|
executionOptions: { inputs },
|
|
2767
|
-
authenticationId
|
|
2832
|
+
authenticationId,
|
|
2833
|
+
timeoutMs
|
|
2834
|
+
});
|
|
2768
2835
|
if (result.errors && result.errors.length > 0) {
|
|
2769
2836
|
const errorMessage = result.errors.map(
|
|
2770
2837
|
(error) => error.detail || error.title || "Unknown error"
|
|
@@ -2823,64 +2890,41 @@ var RelayRequestSchema = zod.z.object({
|
|
|
2823
2890
|
zod.z.instanceof(Headers),
|
|
2824
2891
|
zod.z.array(zod.z.tuple([zod.z.string(), zod.z.string()]))
|
|
2825
2892
|
]).optional().describe("Request headers")
|
|
2826
|
-
}).extend({
|
|
2827
|
-
relayBaseUrl: zod.z.string().optional().describe("Base URL for Relay service")
|
|
2828
2893
|
}).merge(TelemetryMarkerSchema).describe("Make authenticated HTTP requests through Zapier's Relay service");
|
|
2829
2894
|
var RelayFetchSchema = RelayRequestSchema;
|
|
2830
2895
|
|
|
2831
|
-
// src/
|
|
2832
|
-
|
|
2833
|
-
|
|
2834
|
-
|
|
2835
|
-
|
|
2896
|
+
// src/utils/logging.ts
|
|
2897
|
+
var loggedDeprecations = /* @__PURE__ */ new Set();
|
|
2898
|
+
function logDeprecation(message) {
|
|
2899
|
+
if (loggedDeprecations.has(message)) return;
|
|
2900
|
+
loggedDeprecations.add(message);
|
|
2901
|
+
console.warn(`[zapier-sdk] Deprecation: ${message}`);
|
|
2902
|
+
}
|
|
2903
|
+
function resetDeprecationWarnings() {
|
|
2904
|
+
loggedDeprecations.clear();
|
|
2836
2905
|
}
|
|
2837
|
-
|
|
2906
|
+
|
|
2907
|
+
// src/plugins/request/index.ts
|
|
2908
|
+
var requestPlugin = ({ sdk, context }) => {
|
|
2838
2909
|
async function request(options) {
|
|
2839
|
-
|
|
2910
|
+
logDeprecation("request() is deprecated. Use fetch() instead.");
|
|
2840
2911
|
const {
|
|
2841
2912
|
url,
|
|
2842
|
-
method
|
|
2913
|
+
method,
|
|
2843
2914
|
body,
|
|
2844
|
-
headers
|
|
2915
|
+
headers,
|
|
2845
2916
|
authenticationId,
|
|
2846
2917
|
callbackUrl,
|
|
2847
2918
|
authenticationTemplate
|
|
2848
2919
|
} = options;
|
|
2849
|
-
|
|
2850
|
-
const headers = {};
|
|
2851
|
-
if (optionsHeaders) {
|
|
2852
|
-
const headerEntries = optionsHeaders instanceof Headers ? Array.from(optionsHeaders.entries()) : Array.isArray(optionsHeaders) ? optionsHeaders : Object.entries(optionsHeaders);
|
|
2853
|
-
for (const [key, value] of headerEntries) {
|
|
2854
|
-
headers[key] = value;
|
|
2855
|
-
}
|
|
2856
|
-
}
|
|
2857
|
-
const hasContentType = Object.keys(headers).some(
|
|
2858
|
-
(k) => k.toLowerCase() === "content-type"
|
|
2859
|
-
);
|
|
2860
|
-
if (body && !hasContentType) {
|
|
2861
|
-
const bodyStr = typeof body === "string" ? body : JSON.stringify(body);
|
|
2862
|
-
const trimmed = bodyStr.trimStart();
|
|
2863
|
-
if (trimmed.startsWith("{") || trimmed.startsWith("[")) {
|
|
2864
|
-
headers["Content-Type"] = "application/json; charset=utf-8";
|
|
2865
|
-
}
|
|
2866
|
-
}
|
|
2867
|
-
if (authenticationId) {
|
|
2868
|
-
headers["X-Relay-Authentication-Id"] = coerceToNumericId(
|
|
2869
|
-
"authenticationId",
|
|
2870
|
-
authenticationId
|
|
2871
|
-
).toString();
|
|
2872
|
-
}
|
|
2873
|
-
if (callbackUrl) {
|
|
2874
|
-
headers["X-Relay-Callback-Url"] = callbackUrl;
|
|
2875
|
-
}
|
|
2876
|
-
if (authenticationTemplate) {
|
|
2877
|
-
headers["X-Authentication-Template"] = authenticationTemplate;
|
|
2878
|
-
}
|
|
2879
|
-
return await api.fetch(relayPath, {
|
|
2920
|
+
return sdk.fetch(url, {
|
|
2880
2921
|
method,
|
|
2881
2922
|
body,
|
|
2882
2923
|
headers,
|
|
2883
|
-
|
|
2924
|
+
authenticationId,
|
|
2925
|
+
callbackUrl,
|
|
2926
|
+
authenticationTemplate,
|
|
2927
|
+
_telemetry: { isNested: true }
|
|
2884
2928
|
});
|
|
2885
2929
|
}
|
|
2886
2930
|
const requestDefinition = createFunction(
|
|
@@ -2896,7 +2940,8 @@ var requestPlugin = ({ context }) => {
|
|
|
2896
2940
|
context: {
|
|
2897
2941
|
meta: {
|
|
2898
2942
|
request: {
|
|
2899
|
-
|
|
2943
|
+
packages: ["cli", "mcp"],
|
|
2944
|
+
categories: ["http", "deprecated"],
|
|
2900
2945
|
returnType: "Response",
|
|
2901
2946
|
inputSchema: RelayRequestSchema
|
|
2902
2947
|
}
|
|
@@ -3605,9 +3650,8 @@ var DEFAULT_TIMEOUT_MS = 18e4;
|
|
|
3605
3650
|
var DEFAULT_SUCCESS_STATUS = 200;
|
|
3606
3651
|
var DEFAULT_PENDING_STATUS = 202;
|
|
3607
3652
|
var DEFAULT_INITIAL_DELAY_MS = 50;
|
|
3608
|
-
var DEFAULT_MAX_POLLING_INTERVAL_MS =
|
|
3609
|
-
var
|
|
3610
|
-
var DEFAULT_POLLING_STAGES = [
|
|
3653
|
+
var DEFAULT_MAX_POLLING_INTERVAL_MS = 6e4;
|
|
3654
|
+
var POLLING_STAGES = [
|
|
3611
3655
|
[125, 125],
|
|
3612
3656
|
// Up to 125ms: poll every 125ms
|
|
3613
3657
|
[375, 250],
|
|
@@ -3618,9 +3662,16 @@ var DEFAULT_POLLING_STAGES = [
|
|
|
3618
3662
|
// Up to 10s: poll every 1s
|
|
3619
3663
|
[3e4, 2500],
|
|
3620
3664
|
// Up to 30s: poll every 2.5s
|
|
3621
|
-
[6e4, 5e3]
|
|
3665
|
+
[6e4, 5e3],
|
|
3622
3666
|
// Up to 60s: poll every 5s
|
|
3667
|
+
[18e4, 1e4]
|
|
3668
|
+
// Up to 3min: poll every 10s
|
|
3669
|
+
// Beyond 3min: use DEFAULT_MAX_POLLING_INTERVAL_MS (60s)
|
|
3623
3670
|
];
|
|
3671
|
+
function getPollingInterval(elapsedMs) {
|
|
3672
|
+
const stage = POLLING_STAGES.find(([threshold]) => elapsedMs < threshold);
|
|
3673
|
+
return stage ? stage[1] : DEFAULT_MAX_POLLING_INTERVAL_MS;
|
|
3674
|
+
}
|
|
3624
3675
|
var processResponse = async (response, successStatus, pendingStatus, isPending, resultExtractor, errorCount) => {
|
|
3625
3676
|
if (!response.ok) {
|
|
3626
3677
|
return {
|
|
@@ -3689,23 +3740,12 @@ async function pollUntilComplete(options) {
|
|
|
3689
3740
|
const startTime = Date.now();
|
|
3690
3741
|
let attempts = 0;
|
|
3691
3742
|
let errorCount = 0;
|
|
3692
|
-
const pollingStages = [
|
|
3693
|
-
...DEFAULT_POLLING_STAGES,
|
|
3694
|
-
[timeoutMs + MAX_TIMEOUT_BUFFER_MS, DEFAULT_MAX_POLLING_INTERVAL_MS]
|
|
3695
|
-
// Up to timeout + 10s: poll every 10s
|
|
3696
|
-
];
|
|
3697
3743
|
if (initialDelay > 0) {
|
|
3698
3744
|
await promises.setTimeout(initialDelay);
|
|
3699
3745
|
}
|
|
3700
3746
|
while (true) {
|
|
3701
|
-
attempts++;
|
|
3702
3747
|
const elapsedTime = Date.now() - startTime;
|
|
3703
|
-
|
|
3704
|
-
([maxTimeForStage, _interval]) => {
|
|
3705
|
-
return elapsedTime < maxTimeForStage;
|
|
3706
|
-
}
|
|
3707
|
-
);
|
|
3708
|
-
if (!pollingInterval) {
|
|
3748
|
+
if (elapsedTime >= timeoutMs) {
|
|
3709
3749
|
throw new ZapierTimeoutError(
|
|
3710
3750
|
`Operation timed out after ${Math.floor(elapsedTime / 1e3)}s (${attempts} attempts)`,
|
|
3711
3751
|
{
|
|
@@ -3713,10 +3753,12 @@ async function pollUntilComplete(options) {
|
|
|
3713
3753
|
}
|
|
3714
3754
|
);
|
|
3715
3755
|
}
|
|
3716
|
-
if (attempts >
|
|
3717
|
-
const
|
|
3756
|
+
if (attempts > 0) {
|
|
3757
|
+
const interval = getPollingInterval(elapsedTime);
|
|
3758
|
+
const waitTime = calculateWaitTime(interval, errorCount);
|
|
3718
3759
|
await promises.setTimeout(waitTime);
|
|
3719
3760
|
}
|
|
3761
|
+
attempts++;
|
|
3720
3762
|
try {
|
|
3721
3763
|
const response = await fetchPoll();
|
|
3722
3764
|
const {
|
|
@@ -3769,17 +3811,6 @@ function isCredentialsFunction(credentials) {
|
|
|
3769
3811
|
return typeof credentials === "function";
|
|
3770
3812
|
}
|
|
3771
3813
|
|
|
3772
|
-
// src/utils/logging.ts
|
|
3773
|
-
var loggedDeprecations = /* @__PURE__ */ new Set();
|
|
3774
|
-
function logDeprecation(message) {
|
|
3775
|
-
if (loggedDeprecations.has(message)) return;
|
|
3776
|
-
loggedDeprecations.add(message);
|
|
3777
|
-
console.warn(`[zapier-sdk] Deprecation: ${message}`);
|
|
3778
|
-
}
|
|
3779
|
-
function resetDeprecationWarnings() {
|
|
3780
|
-
loggedDeprecations.clear();
|
|
3781
|
-
}
|
|
3782
|
-
|
|
3783
3814
|
// src/utils/url-utils.ts
|
|
3784
3815
|
function getZapierBaseUrl(baseUrl) {
|
|
3785
3816
|
if (!baseUrl) {
|
|
@@ -4637,6 +4668,7 @@ var registryPlugin = ({ sdk, context }) => {
|
|
|
4637
4668
|
const meta = context.meta[key];
|
|
4638
4669
|
return {
|
|
4639
4670
|
name: key,
|
|
4671
|
+
description: meta.description,
|
|
4640
4672
|
type: meta.type,
|
|
4641
4673
|
itemType: meta.itemType,
|
|
4642
4674
|
returnType: meta.returnType,
|
|
@@ -5097,7 +5129,7 @@ function getCpuTime() {
|
|
|
5097
5129
|
|
|
5098
5130
|
// package.json
|
|
5099
5131
|
var package_default = {
|
|
5100
|
-
version: "0.
|
|
5132
|
+
version: "0.25.0"};
|
|
5101
5133
|
|
|
5102
5134
|
// src/plugins/eventEmission/builders.ts
|
|
5103
5135
|
function createBaseEvent(context = {}) {
|
|
@@ -5551,16 +5583,18 @@ function createSdk(options = {}, initialSdk = {}, initialContext = { meta: {} })
|
|
|
5551
5583
|
};
|
|
5552
5584
|
}
|
|
5553
5585
|
function createZapierSdkWithoutRegistry(options = {}) {
|
|
5554
|
-
return createSdk(options).addPlugin(eventEmissionPlugin).addPlugin(apiPlugin).addPlugin(manifestPlugin).addPlugin(listAppsPlugin).addPlugin(getAppPlugin).addPlugin(listActionsPlugin).addPlugin(getActionPlugin).addPlugin(listInputFieldsPlugin).addPlugin(getInputFieldsSchemaPlugin).addPlugin(listInputFieldChoicesPlugin).addPlugin(runActionPlugin).addPlugin(listAuthenticationsPlugin).addPlugin(getAuthenticationPlugin).addPlugin(findFirstAuthenticationPlugin).addPlugin(findUniqueAuthenticationPlugin).addPlugin(listClientCredentialsPlugin).addPlugin(createClientCredentialsPlugin).addPlugin(deleteClientCredentialsPlugin).addPlugin(
|
|
5586
|
+
return createSdk(options).addPlugin(eventEmissionPlugin).addPlugin(apiPlugin).addPlugin(manifestPlugin).addPlugin(listAppsPlugin).addPlugin(getAppPlugin).addPlugin(listActionsPlugin).addPlugin(getActionPlugin).addPlugin(listInputFieldsPlugin).addPlugin(getInputFieldsSchemaPlugin).addPlugin(listInputFieldChoicesPlugin).addPlugin(runActionPlugin).addPlugin(listAuthenticationsPlugin).addPlugin(getAuthenticationPlugin).addPlugin(findFirstAuthenticationPlugin).addPlugin(findUniqueAuthenticationPlugin).addPlugin(listClientCredentialsPlugin).addPlugin(createClientCredentialsPlugin).addPlugin(deleteClientCredentialsPlugin).addPlugin(fetchPlugin).addPlugin(requestPlugin).addPlugin(appsPlugin).addPlugin(getProfilePlugin);
|
|
5555
5587
|
}
|
|
5556
5588
|
function createZapierSdk(options = {}) {
|
|
5557
5589
|
return createZapierSdkWithoutRegistry(options).addPlugin(registryPlugin);
|
|
5558
5590
|
}
|
|
5559
5591
|
|
|
5560
5592
|
exports.ActionKeyPropertySchema = ActionKeyPropertySchema;
|
|
5593
|
+
exports.ActionTimeoutMsPropertySchema = ActionTimeoutMsPropertySchema;
|
|
5561
5594
|
exports.ActionTypePropertySchema = ActionTypePropertySchema;
|
|
5562
5595
|
exports.AppKeyPropertySchema = AppKeyPropertySchema;
|
|
5563
5596
|
exports.AuthenticationIdPropertySchema = AuthenticationIdPropertySchema;
|
|
5597
|
+
exports.DEFAULT_ACTION_TIMEOUT_MS = DEFAULT_ACTION_TIMEOUT_MS;
|
|
5564
5598
|
exports.DEFAULT_CONFIG_PATH = DEFAULT_CONFIG_PATH;
|
|
5565
5599
|
exports.DebugPropertySchema = DebugPropertySchema;
|
|
5566
5600
|
exports.InputsPropertySchema = InputsPropertySchema;
|