@zapier/zapier-sdk 0.23.2 → 0.24.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 +9 -0
- package/README.md +11 -40
- package/dist/index.cjs +123 -104
- package/dist/index.d.mts +50 -30
- package/dist/index.mjs +123 -104
- 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/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/sdk.d.ts +6 -0
- package/dist/types/sdk.d.ts.map +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,14 @@
|
|
|
1
1
|
# @zapier/zapier-sdk
|
|
2
2
|
|
|
3
|
+
## 0.24.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- d72cda1: Deprecates request() in favor of self-contained fetch(). The fetch plugin now handles URL-to-relay transformation, header normalization,
|
|
8
|
+
and body content-type inference directly instead of delegating to request. The request plugin is preserved as a backward-compatible
|
|
9
|
+
shim that forwards to fetch. CLI and MCP now expose a fetch command via a new inputParameters registry concept for
|
|
10
|
+
multi-positional-argument functions.
|
|
11
|
+
|
|
3
12
|
## 0.23.2
|
|
4
13
|
|
|
5
14
|
### Patch Changes
|
package/README.md
CHANGED
|
@@ -30,7 +30,6 @@
|
|
|
30
30
|
- [`listClientCredentials`](#listclientcredentials)
|
|
31
31
|
- [HTTP Requests](#http-requests)
|
|
32
32
|
- [`fetch`](#fetch)
|
|
33
|
-
- [`request`](#request)
|
|
34
33
|
|
|
35
34
|
## Installation
|
|
36
35
|
|
|
@@ -803,20 +802,20 @@ for await (const clientCredentials of sdk.listClientCredentials().items()) {
|
|
|
803
802
|
|
|
804
803
|
#### `fetch`
|
|
805
804
|
|
|
806
|
-
|
|
805
|
+
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.
|
|
807
806
|
|
|
808
807
|
**Parameters:**
|
|
809
808
|
|
|
810
|
-
| Name | Type | Required | Default | Possible Values | Description
|
|
811
|
-
| -------------------------- | ------------------------ | -------- | ------- | ---------------------------------------------------------- |
|
|
812
|
-
| `url` | `string, custom` | ✅ | — | — | The URL to
|
|
813
|
-
| `init` | `object` | ❌ | — | — |
|
|
814
|
-
| ↳ `method` | `string` | ❌ | — | `GET`, `POST`, `PUT`, `DELETE`, `PATCH`, `HEAD`, `OPTIONS` |
|
|
815
|
-
| ↳ `headers` | `object` | ❌ | — | — |
|
|
816
|
-
| ↳ `body` | `string, custom, custom` | ❌ | — | — |
|
|
817
|
-
| ↳ `authenticationId` | `string, number` | ❌ | — | — | Authentication ID to use for this action
|
|
818
|
-
| ↳ `callbackUrl` | `string` | ❌ | — | — | URL to send async response to (makes request async)
|
|
819
|
-
| ↳ `authenticationTemplate` | `string` | ❌ | — | — | Optional JSON string authentication template to bypass Notary lookup
|
|
809
|
+
| Name | Type | Required | Default | Possible Values | Description |
|
|
810
|
+
| -------------------------- | ------------------------ | -------- | ------- | ---------------------------------------------------------- | --------------------------------------------------------------------------------- |
|
|
811
|
+
| `url` | `string, custom` | ✅ | — | — | The full URL of the API endpoint to call (proxied through Zapier's Relay service) |
|
|
812
|
+
| `init` | `object` | ❌ | — | — | Request options including method, headers, body, and authentication |
|
|
813
|
+
| ↳ `method` | `string` | ❌ | — | `GET`, `POST`, `PUT`, `DELETE`, `PATCH`, `HEAD`, `OPTIONS` | HTTP method for the request (defaults to GET) |
|
|
814
|
+
| ↳ `headers` | `object` | ❌ | — | — | HTTP headers to include in the request |
|
|
815
|
+
| ↳ `body` | `string, custom, custom` | ❌ | — | — | Request body — JSON strings are auto-detected and Content-Type is set accordingly |
|
|
816
|
+
| ↳ `authenticationId` | `string, number` | ❌ | — | — | Authentication ID to use for this action |
|
|
817
|
+
| ↳ `callbackUrl` | `string` | ❌ | — | — | URL to send async response to (makes request async) |
|
|
818
|
+
| ↳ `authenticationTemplate` | `string` | ❌ | — | — | Optional JSON string authentication template to bypass Notary lookup |
|
|
820
819
|
|
|
821
820
|
**Returns:** `Promise<Response>`
|
|
822
821
|
|
|
@@ -825,31 +824,3 @@ Execute fetch
|
|
|
825
824
|
```typescript
|
|
826
825
|
const result = await sdk.fetch("example-value", { key: "value" });
|
|
827
826
|
```
|
|
828
|
-
|
|
829
|
-
#### `request`
|
|
830
|
-
|
|
831
|
-
Make authenticated HTTP requests through Zapier's Relay service
|
|
832
|
-
|
|
833
|
-
**Parameters:**
|
|
834
|
-
|
|
835
|
-
| Name | Type | Required | Default | Possible Values | Description |
|
|
836
|
-
| -------------------------- | ----------------------- | -------- | ------- | ---------------------------------------------------------- | -------------------------------------------------------------------- |
|
|
837
|
-
| `options` | `object` | ✅ | — | — | |
|
|
838
|
-
| ↳ `url` | `string` | ✅ | — | — | The URL to request (will be proxied through Relay) |
|
|
839
|
-
| ↳ `method` | `string` | ❌ | — | `GET`, `POST`, `PUT`, `DELETE`, `PATCH`, `HEAD`, `OPTIONS` | HTTP method |
|
|
840
|
-
| ↳ `body` | `string` | ❌ | — | — | Request body as a string |
|
|
841
|
-
| ↳ `authenticationId` | `string, number` | ❌ | — | — | Authentication ID to use for this action |
|
|
842
|
-
| ↳ `callbackUrl` | `string` | ❌ | — | — | URL to send async response to (makes request async) |
|
|
843
|
-
| ↳ `authenticationTemplate` | `string` | ❌ | — | — | Optional JSON string authentication template to bypass Notary lookup |
|
|
844
|
-
| ↳ `headers` | `record, custom, array` | ❌ | — | — | Request headers |
|
|
845
|
-
| ↳ `relayBaseUrl` | `string` | ❌ | — | — | Base URL for Relay service |
|
|
846
|
-
|
|
847
|
-
**Returns:** `Promise<Response>`
|
|
848
|
-
|
|
849
|
-
**Example:**
|
|
850
|
-
|
|
851
|
-
```typescript
|
|
852
|
-
const result = await sdk.request({
|
|
853
|
-
url: "https://example.com",
|
|
854
|
-
});
|
|
855
|
-
```
|
package/dist/index.cjs
CHANGED
|
@@ -384,71 +384,136 @@ var appsPlugin = ({ sdk }) => {
|
|
|
384
384
|
}
|
|
385
385
|
};
|
|
386
386
|
};
|
|
387
|
-
var FetchUrlSchema = zod.z.union([zod.z.string(), zod.z.instanceof(URL)]).describe(
|
|
387
|
+
var FetchUrlSchema = zod.z.union([zod.z.string(), zod.z.instanceof(URL)]).describe(
|
|
388
|
+
"The full URL of the API endpoint to call (proxied through Zapier's Relay service)"
|
|
389
|
+
);
|
|
388
390
|
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(),
|
|
391
|
+
method: zod.z.enum(["GET", "POST", "PUT", "DELETE", "PATCH", "HEAD", "OPTIONS"]).optional().describe("HTTP method for the request (defaults to GET)"),
|
|
392
|
+
headers: zod.z.record(zod.z.string(), zod.z.string()).optional().describe("HTTP headers to include in the request"),
|
|
391
393
|
body: zod.z.union([
|
|
392
394
|
zod.z.string(),
|
|
393
395
|
zod.z.instanceof(FormData),
|
|
394
396
|
zod.z.instanceof(URLSearchParams)
|
|
395
|
-
]).optional()
|
|
397
|
+
]).optional().describe(
|
|
398
|
+
"Request body \u2014 JSON strings are auto-detected and Content-Type is set accordingly"
|
|
399
|
+
),
|
|
396
400
|
authenticationId: AuthenticationIdPropertySchema.optional(),
|
|
397
401
|
callbackUrl: zod.z.string().optional().describe("URL to send async response to (makes request async)"),
|
|
398
402
|
authenticationTemplate: zod.z.string().optional().describe(
|
|
399
403
|
"Optional JSON string authentication template to bypass Notary lookup"
|
|
400
404
|
)
|
|
401
|
-
}).optional().describe(
|
|
405
|
+
}).optional().describe(
|
|
406
|
+
"Request options including method, headers, body, and authentication"
|
|
407
|
+
);
|
|
408
|
+
|
|
409
|
+
// src/utils/id-utils.ts
|
|
410
|
+
function coerceToNumericId(fieldName, value) {
|
|
411
|
+
if (value === "") {
|
|
412
|
+
throw new ZapierValidationError(`The ${fieldName} cannot be empty`);
|
|
413
|
+
}
|
|
414
|
+
const numericValue = typeof value === "number" ? value : Number(value);
|
|
415
|
+
if (!Number.isFinite(numericValue)) {
|
|
416
|
+
throw new ZapierValidationError(
|
|
417
|
+
`The ${fieldName} "${value}" could not be converted to a number`
|
|
418
|
+
);
|
|
419
|
+
}
|
|
420
|
+
return numericValue;
|
|
421
|
+
}
|
|
402
422
|
|
|
403
423
|
// src/plugins/fetch/index.ts
|
|
404
|
-
|
|
424
|
+
function transformUrlToRelayPath(url) {
|
|
425
|
+
const targetUrl = new URL(url);
|
|
426
|
+
return `/relay/${targetUrl.host}${targetUrl.pathname}${targetUrl.search}${targetUrl.hash}`;
|
|
427
|
+
}
|
|
428
|
+
function normalizeHeaders(optionsHeaders) {
|
|
429
|
+
const headers = {};
|
|
430
|
+
if (!optionsHeaders) {
|
|
431
|
+
return headers;
|
|
432
|
+
}
|
|
433
|
+
const headerEntries = optionsHeaders instanceof Headers ? Array.from(optionsHeaders.entries()) : Array.isArray(optionsHeaders) ? optionsHeaders : Object.entries(optionsHeaders);
|
|
434
|
+
for (const [key, value] of headerEntries) {
|
|
435
|
+
headers[key] = value;
|
|
436
|
+
}
|
|
437
|
+
return headers;
|
|
438
|
+
}
|
|
439
|
+
var fetchPlugin = ({ context }) => {
|
|
405
440
|
return {
|
|
406
441
|
fetch: async function fetch2(url, init) {
|
|
442
|
+
const { api } = context;
|
|
407
443
|
const startTime = Date.now();
|
|
444
|
+
const isNested = init?._telemetry?.isNested === true;
|
|
408
445
|
try {
|
|
409
446
|
const {
|
|
410
447
|
authenticationId,
|
|
411
448
|
callbackUrl,
|
|
412
449
|
authenticationTemplate,
|
|
450
|
+
_telemetry,
|
|
413
451
|
...fetchInit
|
|
414
452
|
} = init || {};
|
|
415
|
-
const
|
|
416
|
-
|
|
417
|
-
|
|
453
|
+
const relayPath = transformUrlToRelayPath(url);
|
|
454
|
+
const headers = normalizeHeaders(
|
|
455
|
+
fetchInit.headers
|
|
456
|
+
);
|
|
457
|
+
const hasContentType = Object.keys(headers).some(
|
|
458
|
+
(k) => k.toLowerCase() === "content-type"
|
|
459
|
+
);
|
|
460
|
+
if (fetchInit.body && !hasContentType) {
|
|
461
|
+
const bodyStr = typeof fetchInit.body === "string" ? fetchInit.body : JSON.stringify(fetchInit.body);
|
|
462
|
+
const trimmed = bodyStr.trimStart();
|
|
463
|
+
if (trimmed.startsWith("{") || trimmed.startsWith("[")) {
|
|
464
|
+
headers["Content-Type"] = "application/json; charset=utf-8";
|
|
465
|
+
}
|
|
466
|
+
}
|
|
467
|
+
if (authenticationId) {
|
|
468
|
+
headers["X-Relay-Authentication-Id"] = coerceToNumericId(
|
|
469
|
+
"authenticationId",
|
|
470
|
+
authenticationId
|
|
471
|
+
).toString();
|
|
472
|
+
}
|
|
473
|
+
if (callbackUrl) {
|
|
474
|
+
headers["X-Relay-Callback-Url"] = callbackUrl;
|
|
475
|
+
}
|
|
476
|
+
if (authenticationTemplate) {
|
|
477
|
+
headers["X-Authentication-Template"] = authenticationTemplate;
|
|
478
|
+
}
|
|
479
|
+
const result = await api.fetch(relayPath, {
|
|
480
|
+
method: fetchInit.method ?? "GET",
|
|
418
481
|
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
|
|
482
|
+
headers,
|
|
483
|
+
authRequired: true
|
|
433
484
|
});
|
|
485
|
+
if (!isNested) {
|
|
486
|
+
context.eventEmission.emitMethodCalled({
|
|
487
|
+
method_name: "fetch",
|
|
488
|
+
execution_duration_ms: Date.now() - startTime,
|
|
489
|
+
success_flag: true,
|
|
490
|
+
error_message: null,
|
|
491
|
+
error_type: null,
|
|
492
|
+
argument_count: init ? 2 : 1,
|
|
493
|
+
is_paginated: false
|
|
494
|
+
});
|
|
495
|
+
}
|
|
434
496
|
return result;
|
|
435
497
|
} catch (error) {
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
498
|
+
if (!isNested) {
|
|
499
|
+
context.eventEmission.emitMethodCalled({
|
|
500
|
+
method_name: "fetch",
|
|
501
|
+
execution_duration_ms: Date.now() - startTime,
|
|
502
|
+
success_flag: false,
|
|
503
|
+
error_message: error instanceof Error ? error.message : String(error),
|
|
504
|
+
error_type: error instanceof Error ? error.constructor.name : "Unknown",
|
|
505
|
+
argument_count: init ? 2 : 1,
|
|
506
|
+
is_paginated: false
|
|
507
|
+
});
|
|
508
|
+
}
|
|
445
509
|
throw error;
|
|
446
510
|
}
|
|
447
511
|
},
|
|
448
512
|
context: {
|
|
449
513
|
meta: {
|
|
450
514
|
fetch: {
|
|
451
|
-
|
|
515
|
+
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.",
|
|
516
|
+
packages: ["sdk", "cli", "mcp"],
|
|
452
517
|
categories: ["http"],
|
|
453
518
|
returnType: "Response",
|
|
454
519
|
inputParameters: [
|
|
@@ -1827,20 +1892,6 @@ var RootFieldItemSchema = zod.z.union([
|
|
|
1827
1892
|
FieldsetItemSchema
|
|
1828
1893
|
]);
|
|
1829
1894
|
|
|
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
1895
|
// src/services/implementations.ts
|
|
1845
1896
|
async function fetchImplementationNeeds({
|
|
1846
1897
|
api,
|
|
@@ -2823,64 +2874,41 @@ var RelayRequestSchema = zod.z.object({
|
|
|
2823
2874
|
zod.z.instanceof(Headers),
|
|
2824
2875
|
zod.z.array(zod.z.tuple([zod.z.string(), zod.z.string()]))
|
|
2825
2876
|
]).optional().describe("Request headers")
|
|
2826
|
-
}).extend({
|
|
2827
|
-
relayBaseUrl: zod.z.string().optional().describe("Base URL for Relay service")
|
|
2828
2877
|
}).merge(TelemetryMarkerSchema).describe("Make authenticated HTTP requests through Zapier's Relay service");
|
|
2829
2878
|
var RelayFetchSchema = RelayRequestSchema;
|
|
2830
2879
|
|
|
2831
|
-
// src/
|
|
2832
|
-
|
|
2833
|
-
|
|
2834
|
-
|
|
2835
|
-
|
|
2880
|
+
// src/utils/logging.ts
|
|
2881
|
+
var loggedDeprecations = /* @__PURE__ */ new Set();
|
|
2882
|
+
function logDeprecation(message) {
|
|
2883
|
+
if (loggedDeprecations.has(message)) return;
|
|
2884
|
+
loggedDeprecations.add(message);
|
|
2885
|
+
console.warn(`[zapier-sdk] Deprecation: ${message}`);
|
|
2886
|
+
}
|
|
2887
|
+
function resetDeprecationWarnings() {
|
|
2888
|
+
loggedDeprecations.clear();
|
|
2836
2889
|
}
|
|
2837
|
-
|
|
2890
|
+
|
|
2891
|
+
// src/plugins/request/index.ts
|
|
2892
|
+
var requestPlugin = ({ sdk, context }) => {
|
|
2838
2893
|
async function request(options) {
|
|
2839
|
-
|
|
2894
|
+
logDeprecation("request() is deprecated. Use fetch() instead.");
|
|
2840
2895
|
const {
|
|
2841
2896
|
url,
|
|
2842
|
-
method
|
|
2897
|
+
method,
|
|
2843
2898
|
body,
|
|
2844
|
-
headers
|
|
2899
|
+
headers,
|
|
2845
2900
|
authenticationId,
|
|
2846
2901
|
callbackUrl,
|
|
2847
2902
|
authenticationTemplate
|
|
2848
2903
|
} = 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, {
|
|
2904
|
+
return sdk.fetch(url, {
|
|
2880
2905
|
method,
|
|
2881
2906
|
body,
|
|
2882
2907
|
headers,
|
|
2883
|
-
|
|
2908
|
+
authenticationId,
|
|
2909
|
+
callbackUrl,
|
|
2910
|
+
authenticationTemplate,
|
|
2911
|
+
_telemetry: { isNested: true }
|
|
2884
2912
|
});
|
|
2885
2913
|
}
|
|
2886
2914
|
const requestDefinition = createFunction(
|
|
@@ -2896,7 +2924,8 @@ var requestPlugin = ({ context }) => {
|
|
|
2896
2924
|
context: {
|
|
2897
2925
|
meta: {
|
|
2898
2926
|
request: {
|
|
2899
|
-
|
|
2927
|
+
packages: ["cli", "mcp"],
|
|
2928
|
+
categories: ["http", "deprecated"],
|
|
2900
2929
|
returnType: "Response",
|
|
2901
2930
|
inputSchema: RelayRequestSchema
|
|
2902
2931
|
}
|
|
@@ -3769,17 +3798,6 @@ function isCredentialsFunction(credentials) {
|
|
|
3769
3798
|
return typeof credentials === "function";
|
|
3770
3799
|
}
|
|
3771
3800
|
|
|
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
3801
|
// src/utils/url-utils.ts
|
|
3784
3802
|
function getZapierBaseUrl(baseUrl) {
|
|
3785
3803
|
if (!baseUrl) {
|
|
@@ -4637,6 +4655,7 @@ var registryPlugin = ({ sdk, context }) => {
|
|
|
4637
4655
|
const meta = context.meta[key];
|
|
4638
4656
|
return {
|
|
4639
4657
|
name: key,
|
|
4658
|
+
description: meta.description,
|
|
4640
4659
|
type: meta.type,
|
|
4641
4660
|
itemType: meta.itemType,
|
|
4642
4661
|
returnType: meta.returnType,
|
|
@@ -5097,7 +5116,7 @@ function getCpuTime() {
|
|
|
5097
5116
|
|
|
5098
5117
|
// package.json
|
|
5099
5118
|
var package_default = {
|
|
5100
|
-
version: "0.
|
|
5119
|
+
version: "0.24.0"};
|
|
5101
5120
|
|
|
5102
5121
|
// src/plugins/eventEmission/builders.ts
|
|
5103
5122
|
function createBaseEvent(context = {}) {
|
|
@@ -5551,7 +5570,7 @@ function createSdk(options = {}, initialSdk = {}, initialContext = { meta: {} })
|
|
|
5551
5570
|
};
|
|
5552
5571
|
}
|
|
5553
5572
|
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(
|
|
5573
|
+
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
5574
|
}
|
|
5556
5575
|
function createZapierSdk(options = {}) {
|
|
5557
5576
|
return createZapierSdkWithoutRegistry(options).addPlugin(registryPlugin);
|
package/dist/index.d.mts
CHANGED
|
@@ -60,6 +60,12 @@ interface PluginProvides extends Record<string, any> {
|
|
|
60
60
|
context?: Record<string, any>;
|
|
61
61
|
}
|
|
62
62
|
interface PluginMeta {
|
|
63
|
+
/**
|
|
64
|
+
* Human-readable description of the plugin function. Used by the CLI (help text),
|
|
65
|
+
* MCP (tool description), and README generators. When omitted, falls back to
|
|
66
|
+
* the inputSchema's `.describe()` value or a generic placeholder.
|
|
67
|
+
*/
|
|
68
|
+
description?: string;
|
|
63
69
|
categories: string[];
|
|
64
70
|
type?: "list" | "item" | "create" | "delete";
|
|
65
71
|
itemType?: string;
|
|
@@ -1128,7 +1134,6 @@ declare const RelayRequestSchema: z.ZodObject<{
|
|
|
1128
1134
|
callbackUrl: z.ZodOptional<z.ZodString>;
|
|
1129
1135
|
authenticationTemplate: z.ZodOptional<z.ZodString>;
|
|
1130
1136
|
headers: z.ZodOptional<z.ZodUnion<readonly [z.ZodRecord<z.ZodString, z.ZodString>, z.ZodCustom<Headers, Headers>, z.ZodArray<z.ZodTuple<[z.ZodString, z.ZodString], null>>]>>;
|
|
1131
|
-
relayBaseUrl: z.ZodOptional<z.ZodString>;
|
|
1132
1137
|
_telemetry: z.ZodOptional<z.ZodObject<{
|
|
1133
1138
|
isNested: z.ZodOptional<z.ZodBoolean>;
|
|
1134
1139
|
}, z.core.$strip>>;
|
|
@@ -1150,7 +1155,6 @@ declare const RelayFetchSchema: z.ZodObject<{
|
|
|
1150
1155
|
callbackUrl: z.ZodOptional<z.ZodString>;
|
|
1151
1156
|
authenticationTemplate: z.ZodOptional<z.ZodString>;
|
|
1152
1157
|
headers: z.ZodOptional<z.ZodUnion<readonly [z.ZodRecord<z.ZodString, z.ZodString>, z.ZodCustom<Headers, Headers>, z.ZodArray<z.ZodTuple<[z.ZodString, z.ZodString], null>>]>>;
|
|
1153
|
-
relayBaseUrl: z.ZodOptional<z.ZodString>;
|
|
1154
1158
|
_telemetry: z.ZodOptional<z.ZodObject<{
|
|
1155
1159
|
isNested: z.ZodOptional<z.ZodBoolean>;
|
|
1156
1160
|
}, z.core.$strip>>;
|
|
@@ -1276,32 +1280,19 @@ interface ActionProxy {
|
|
|
1276
1280
|
[app: string]: AppProxyWithFactory;
|
|
1277
1281
|
}
|
|
1278
1282
|
|
|
1279
|
-
interface RequestPluginProvides {
|
|
1280
|
-
request: (options: RelayRequestOptions) => Promise<Response>;
|
|
1281
|
-
context: {
|
|
1282
|
-
meta: {
|
|
1283
|
-
request: {
|
|
1284
|
-
inputSchema: typeof RelayRequestSchema;
|
|
1285
|
-
};
|
|
1286
|
-
};
|
|
1287
|
-
};
|
|
1288
|
-
}
|
|
1289
|
-
declare const requestPlugin: Plugin<{}, // no SDK dependencies
|
|
1290
|
-
// no SDK dependencies
|
|
1291
|
-
{
|
|
1292
|
-
api: ApiClient;
|
|
1293
|
-
} & EventEmissionContext, // requires api in context
|
|
1294
|
-
RequestPluginProvides>;
|
|
1295
|
-
|
|
1296
1283
|
interface FetchPluginProvides {
|
|
1297
1284
|
fetch: (url: string | URL, init?: RequestInit & {
|
|
1298
1285
|
authenticationId?: string | number;
|
|
1299
1286
|
callbackUrl?: string;
|
|
1300
1287
|
authenticationTemplate?: string;
|
|
1288
|
+
_telemetry?: {
|
|
1289
|
+
isNested?: boolean;
|
|
1290
|
+
};
|
|
1301
1291
|
}) => Promise<Response>;
|
|
1302
1292
|
context: {
|
|
1303
1293
|
meta: {
|
|
1304
1294
|
fetch: {
|
|
1295
|
+
description: string;
|
|
1305
1296
|
packages: string[];
|
|
1306
1297
|
categories: string[];
|
|
1307
1298
|
returnType: string;
|
|
@@ -1314,10 +1305,14 @@ interface FetchPluginProvides {
|
|
|
1314
1305
|
};
|
|
1315
1306
|
}
|
|
1316
1307
|
/**
|
|
1317
|
-
*
|
|
1308
|
+
* Fetch plugin — the primary way to make authenticated HTTP requests through Zapier's Relay service.
|
|
1309
|
+
* Mirrors the native fetch(url, init?) signature with additional Zapier-specific options.
|
|
1318
1310
|
*/
|
|
1319
|
-
declare const fetchPlugin: Plugin<
|
|
1320
|
-
|
|
1311
|
+
declare const fetchPlugin: Plugin<{}, // no SDK dependencies
|
|
1312
|
+
// no SDK dependencies
|
|
1313
|
+
{
|
|
1314
|
+
api: ApiClient;
|
|
1315
|
+
} & EventEmissionContext, // requires api + eventEmission in context
|
|
1321
1316
|
FetchPluginProvides>;
|
|
1322
1317
|
type ZapierFetchInitOptions = RequestInit & {
|
|
1323
1318
|
authenticationId?: string | number;
|
|
@@ -1825,6 +1820,24 @@ interface ListInputFieldChoicesPluginProvides {
|
|
|
1825
1820
|
};
|
|
1826
1821
|
}
|
|
1827
1822
|
|
|
1823
|
+
interface RequestPluginProvides {
|
|
1824
|
+
request: (options: RelayRequestOptions) => Promise<Response>;
|
|
1825
|
+
context: {
|
|
1826
|
+
meta: {
|
|
1827
|
+
request: {
|
|
1828
|
+
inputSchema: typeof RelayRequestSchema;
|
|
1829
|
+
};
|
|
1830
|
+
};
|
|
1831
|
+
};
|
|
1832
|
+
}
|
|
1833
|
+
/**
|
|
1834
|
+
* @deprecated Use `sdk.fetch(url, init?)` instead. This plugin now delegates to the fetch plugin
|
|
1835
|
+
* and is kept only for backward compatibility. It is hidden from the CLI/MCP registries.
|
|
1836
|
+
*/
|
|
1837
|
+
declare const requestPlugin: Plugin<GetSdkType<FetchPluginProvides>, // requires fetch in SDK
|
|
1838
|
+
EventEmissionContext, // requires eventEmission context for telemetry
|
|
1839
|
+
RequestPluginProvides>;
|
|
1840
|
+
|
|
1828
1841
|
/**
|
|
1829
1842
|
* SDK-related types and interfaces
|
|
1830
1843
|
*/
|
|
@@ -1854,6 +1867,12 @@ interface BaseSdkOptions {
|
|
|
1854
1867
|
|
|
1855
1868
|
interface FunctionRegistryEntry {
|
|
1856
1869
|
name: string;
|
|
1870
|
+
/**
|
|
1871
|
+
* Human-readable description of the function. Surfaced as CLI help text,
|
|
1872
|
+
* MCP tool description, and README documentation. Prefer providing this
|
|
1873
|
+
* directly rather than relying solely on inputSchema.describe().
|
|
1874
|
+
*/
|
|
1875
|
+
description?: string;
|
|
1857
1876
|
type?: "list" | "item" | "create" | "delete";
|
|
1858
1877
|
itemType?: string;
|
|
1859
1878
|
returnType?: string;
|
|
@@ -2081,9 +2100,9 @@ declare const AuthItemSchema: z.ZodObject<{
|
|
|
2081
2100
|
type AuthItem = z.infer<typeof AuthItemSchema>;
|
|
2082
2101
|
|
|
2083
2102
|
declare const ActionItemSchema: z.ZodObject<{
|
|
2103
|
+
description: z.ZodString;
|
|
2084
2104
|
key: z.ZodString;
|
|
2085
2105
|
id: z.ZodOptional<z.ZodString>;
|
|
2086
|
-
description: z.ZodString;
|
|
2087
2106
|
is_important: z.ZodOptional<z.ZodBoolean>;
|
|
2088
2107
|
is_hidden: z.ZodOptional<z.ZodBoolean>;
|
|
2089
2108
|
app_key: z.ZodString;
|
|
@@ -2533,7 +2552,7 @@ declare function createSdk<TCurrentSdk = {}, TCurrentContext extends {
|
|
|
2533
2552
|
getContext(): TCurrentContext;
|
|
2534
2553
|
}, TRequiresContext, TProvides>, addPluginOptions?: Record<string, unknown>): Sdk<TCurrentSdk & ExtractSdkProperties<TProvides>, TCurrentContext & NonNullable<ExtractContextProperties<TProvides>>>;
|
|
2535
2554
|
};
|
|
2536
|
-
declare function createZapierSdkWithoutRegistry(options?: ZapierSdkOptions): Sdk<ExtractSdkProperties<EventEmissionProvides> & ExtractSdkProperties<ApiPluginProvides> & ExtractSdkProperties<ManifestPluginProvides> & ExtractSdkProperties<ListAppsPluginProvides> & ExtractSdkProperties<GetAppPluginProvides> & ExtractSdkProperties<ListActionsPluginProvides> & ExtractSdkProperties<GetActionPluginProvides> & ExtractSdkProperties<ListInputFieldsPluginProvides> & ExtractSdkProperties<GetInputFieldsSchemaPluginProvides> & ExtractSdkProperties<ListInputFieldChoicesPluginProvides> & ExtractSdkProperties<RunActionPluginProvides> & ExtractSdkProperties<ListAuthenticationsPluginProvides> & ExtractSdkProperties<GetAuthenticationPluginProvides> & ExtractSdkProperties<FindFirstAuthenticationPluginProvides> & ExtractSdkProperties<FindUniqueAuthenticationPluginProvides> & ExtractSdkProperties<ListClientCredentialsPluginProvides> & ExtractSdkProperties<CreateClientCredentialsPluginProvides> & ExtractSdkProperties<DeleteClientCredentialsPluginProvides> & ExtractSdkProperties<
|
|
2555
|
+
declare function createZapierSdkWithoutRegistry(options?: ZapierSdkOptions): Sdk<ExtractSdkProperties<EventEmissionProvides> & ExtractSdkProperties<ApiPluginProvides> & ExtractSdkProperties<ManifestPluginProvides> & ExtractSdkProperties<ListAppsPluginProvides> & ExtractSdkProperties<GetAppPluginProvides> & ExtractSdkProperties<ListActionsPluginProvides> & ExtractSdkProperties<GetActionPluginProvides> & ExtractSdkProperties<ListInputFieldsPluginProvides> & ExtractSdkProperties<GetInputFieldsSchemaPluginProvides> & ExtractSdkProperties<ListInputFieldChoicesPluginProvides> & ExtractSdkProperties<RunActionPluginProvides> & ExtractSdkProperties<ListAuthenticationsPluginProvides> & ExtractSdkProperties<GetAuthenticationPluginProvides> & ExtractSdkProperties<FindFirstAuthenticationPluginProvides> & ExtractSdkProperties<FindUniqueAuthenticationPluginProvides> & ExtractSdkProperties<ListClientCredentialsPluginProvides> & ExtractSdkProperties<CreateClientCredentialsPluginProvides> & ExtractSdkProperties<DeleteClientCredentialsPluginProvides> & ExtractSdkProperties<FetchPluginProvides> & ExtractSdkProperties<RequestPluginProvides> & ExtractSdkProperties<AppsPluginProvides> & ExtractSdkProperties<GetProfilePluginProvides>, {
|
|
2537
2556
|
meta: Record<string, PluginMeta>;
|
|
2538
2557
|
} & EventEmissionContext & {
|
|
2539
2558
|
api: ApiClient;
|
|
@@ -2656,15 +2675,10 @@ declare function createZapierSdkWithoutRegistry(options?: ZapierSdkOptions): Sdk
|
|
|
2656
2675
|
inputSchema: typeof DeleteClientCredentialsSchema;
|
|
2657
2676
|
};
|
|
2658
2677
|
};
|
|
2659
|
-
} & {
|
|
2660
|
-
meta: {
|
|
2661
|
-
request: {
|
|
2662
|
-
inputSchema: typeof RelayRequestSchema;
|
|
2663
|
-
};
|
|
2664
|
-
};
|
|
2665
2678
|
} & {
|
|
2666
2679
|
meta: {
|
|
2667
2680
|
fetch: {
|
|
2681
|
+
description: string;
|
|
2668
2682
|
packages: string[];
|
|
2669
2683
|
categories: string[];
|
|
2670
2684
|
returnType: string;
|
|
@@ -2674,6 +2688,12 @@ declare function createZapierSdkWithoutRegistry(options?: ZapierSdkOptions): Sdk
|
|
|
2674
2688
|
}>;
|
|
2675
2689
|
};
|
|
2676
2690
|
};
|
|
2691
|
+
} & {
|
|
2692
|
+
meta: {
|
|
2693
|
+
request: {
|
|
2694
|
+
inputSchema: typeof RelayRequestSchema;
|
|
2695
|
+
};
|
|
2696
|
+
};
|
|
2677
2697
|
} & {
|
|
2678
2698
|
meta: {
|
|
2679
2699
|
getProfile: {
|