@zapier/zapier-sdk 0.11.1 → 0.11.2
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 +6 -0
- package/README.md +149 -91
- package/dist/index.cjs +69 -25
- package/dist/index.d.mts +35 -2
- package/dist/index.mjs +69 -25
- package/dist/plugins/fetch/index.d.ts +14 -0
- package/dist/plugins/fetch/index.d.ts.map +1 -1
- package/dist/plugins/fetch/index.js +14 -0
- package/dist/plugins/fetch/schemas.d.ts +25 -0
- package/dist/plugins/fetch/schemas.d.ts.map +1 -0
- package/dist/plugins/fetch/schemas.js +33 -0
- package/dist/plugins/registry/index.d.ts +3 -1
- package/dist/plugins/registry/index.d.ts.map +1 -1
- package/dist/plugins/registry/index.js +55 -34
- package/dist/sdk.d.ts +12 -0
- package/dist/sdk.d.ts.map +1 -1
- package/dist/types/sdk.d.ts +6 -1
- package/dist/types/sdk.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/plugins/fetch/index.ts +25 -0
- package/src/plugins/fetch/schemas.ts +37 -0
- package/src/plugins/registry/index.ts +66 -34
- package/src/types/sdk.ts +3 -1
- package/tsconfig.tsbuildinfo +1 -1
package/CHANGELOG.md
CHANGED
package/README.md
CHANGED
|
@@ -22,6 +22,7 @@
|
|
|
22
22
|
- [`getAuthentication`](#getauthentication)
|
|
23
23
|
- [`listAuthentications`](#listauthentications)
|
|
24
24
|
- [HTTP Requests](#http-requests)
|
|
25
|
+
- [`fetch`](#fetch)
|
|
25
26
|
- [`request`](#request)
|
|
26
27
|
|
|
27
28
|
## Installation
|
|
@@ -62,7 +63,11 @@ const result = await sdk.runAction({
|
|
|
62
63
|
|
|
63
64
|
Get current user's profile information
|
|
64
65
|
|
|
65
|
-
**Parameters:**
|
|
66
|
+
**Parameters:**
|
|
67
|
+
|
|
68
|
+
| Name | Type | Required | Default | Possible Values | Description |
|
|
69
|
+
| --------- | -------- | -------- | ------- | --------------- | -------------------------------------- |
|
|
70
|
+
| `options` | `string` | ❌ | — | — | Get current user's profile information |
|
|
66
71
|
|
|
67
72
|
**Returns:** `Promise<ProfileItem>`
|
|
68
73
|
|
|
@@ -80,11 +85,12 @@ Get detailed information about a specific action
|
|
|
80
85
|
|
|
81
86
|
**Parameters:**
|
|
82
87
|
|
|
83
|
-
| Name
|
|
84
|
-
|
|
|
85
|
-
| `
|
|
86
|
-
| `
|
|
87
|
-
| `
|
|
88
|
+
| Name | Type | Required | Default | Possible Values | Description |
|
|
89
|
+
| -------------- | -------- | -------- | ------- | ---------------------------------------------------------------------------------------------- | -------------------------------------------------- |
|
|
90
|
+
| `options` | `string` | ✅ | — | — | Get detailed information about a specific action |
|
|
91
|
+
| ↳ `appKey` | `string` | ✅ | — | — | App key (e.g., 'SlackCLIAPI') |
|
|
92
|
+
| ↳ `actionType` | `string` | ✅ | — | `read`, `read_bulk`, `write`, `run`, `search`, `search_or_write`, `search_and_write`, `filter` | Action type that matches the action's defined type |
|
|
93
|
+
| ↳ `actionKey` | `string` | ✅ | — | — | Action key to execute |
|
|
88
94
|
|
|
89
95
|
**Returns:** `Promise<ActionItem>`
|
|
90
96
|
|
|
@@ -92,6 +98,7 @@ Get detailed information about a specific action
|
|
|
92
98
|
|
|
93
99
|
```typescript
|
|
94
100
|
const result = await sdk.getAction({
|
|
101
|
+
options: "example-value",
|
|
95
102
|
appKey: "example-key",
|
|
96
103
|
actionType: "read",
|
|
97
104
|
actionKey: "example-key",
|
|
@@ -104,12 +111,13 @@ List all actions for a specific app
|
|
|
104
111
|
|
|
105
112
|
**Parameters:**
|
|
106
113
|
|
|
107
|
-
| Name
|
|
108
|
-
|
|
|
109
|
-
| `
|
|
110
|
-
| `
|
|
111
|
-
| `
|
|
112
|
-
| `
|
|
114
|
+
| Name | Type | Required | Default | Possible Values | Description |
|
|
115
|
+
| -------------- | -------- | -------- | ------- | ---------------------------------------------------------------------------------------------- | ------------------------------------------------ |
|
|
116
|
+
| `options` | `string` | ✅ | — | — | List all actions for a specific app |
|
|
117
|
+
| ↳ `appKey` | `string` | ✅ | — | — | App key of actions to list (e.g., 'SlackCLIAPI') |
|
|
118
|
+
| ↳ `actionType` | `string` | ❌ | — | `read`, `read_bulk`, `write`, `run`, `search`, `search_or_write`, `search_and_write`, `filter` | Filter actions by type |
|
|
119
|
+
| ↳ `pageSize` | `number` | ❌ | — | — | Number of actions per page |
|
|
120
|
+
| ↳ `maxItems` | `number` | ❌ | — | — | Maximum total items to return across all pages |
|
|
113
121
|
|
|
114
122
|
**Returns:** `Promise<PaginatedResult<ActionItem>>`
|
|
115
123
|
|
|
@@ -117,6 +125,7 @@ List all actions for a specific app
|
|
|
117
125
|
|
|
118
126
|
```typescript
|
|
119
127
|
const result = await sdk.listActions({
|
|
128
|
+
options: "example-value",
|
|
120
129
|
appKey: "example-key",
|
|
121
130
|
});
|
|
122
131
|
```
|
|
@@ -127,17 +136,18 @@ Get the available choices for a dynamic dropdown input field
|
|
|
127
136
|
|
|
128
137
|
**Parameters:**
|
|
129
138
|
|
|
130
|
-
| Name
|
|
131
|
-
|
|
|
132
|
-
| `
|
|
133
|
-
| `
|
|
134
|
-
| `
|
|
135
|
-
| `
|
|
136
|
-
| `
|
|
137
|
-
| `
|
|
138
|
-
| `
|
|
139
|
-
| `
|
|
140
|
-
| `
|
|
139
|
+
| Name | Type | Required | Default | Possible Values | Description |
|
|
140
|
+
| -------------------- | -------- | -------- | ------- | ---------------------------------------------------------------------------------------------- | ------------------------------------------------------------ |
|
|
141
|
+
| `options` | `string` | ✅ | — | — | Get the available choices for a dynamic dropdown input field |
|
|
142
|
+
| ↳ `appKey` | `string` | ✅ | — | — | App key (e.g., 'SlackCLIAPI') |
|
|
143
|
+
| ↳ `actionType` | `string` | ✅ | — | `read`, `read_bulk`, `write`, `run`, `search`, `search_or_write`, `search_and_write`, `filter` | Action type that matches the action's defined type |
|
|
144
|
+
| ↳ `actionKey` | `string` | ✅ | — | — | Action key to execute |
|
|
145
|
+
| ↳ `inputFieldKey` | `string` | ✅ | — | — | Input field key to get choices for. |
|
|
146
|
+
| ↳ `authenticationId` | `string` | ❌ | — | — | Authentication ID to use for this action |
|
|
147
|
+
| ↳ `inputs` | `object` | ❌ | — | — | Current input values that may affect available choices |
|
|
148
|
+
| ↳ `page` | `number` | ❌ | — | — | Page number for paginated results |
|
|
149
|
+
| ↳ `pageSize` | `number` | ❌ | — | — | Number of choices per page |
|
|
150
|
+
| ↳ `maxItems` | `number` | ❌ | — | — | Maximum total items to return across all pages |
|
|
141
151
|
|
|
142
152
|
**Returns:** `Promise<PaginatedResult<InputFieldChoiceItem>>`
|
|
143
153
|
|
|
@@ -145,6 +155,7 @@ Get the available choices for a dynamic dropdown input field
|
|
|
145
155
|
|
|
146
156
|
```typescript
|
|
147
157
|
const result = await sdk.listInputFieldChoices({
|
|
158
|
+
options: "example-value",
|
|
148
159
|
appKey: "example-key",
|
|
149
160
|
actionType: "read",
|
|
150
161
|
actionKey: "example-key",
|
|
@@ -158,15 +169,16 @@ Get the input fields required for a specific action
|
|
|
158
169
|
|
|
159
170
|
**Parameters:**
|
|
160
171
|
|
|
161
|
-
| Name
|
|
162
|
-
|
|
|
163
|
-
| `
|
|
164
|
-
| `
|
|
165
|
-
| `
|
|
166
|
-
| `
|
|
167
|
-
| `
|
|
168
|
-
| `
|
|
169
|
-
| `
|
|
172
|
+
| Name | Type | Required | Default | Possible Values | Description |
|
|
173
|
+
| -------------------- | -------- | -------- | ------- | ---------------------------------------------------------------------------------------------- | ----------------------------------------------------- |
|
|
174
|
+
| `options` | `string` | ✅ | — | — | Get the input fields required for a specific action |
|
|
175
|
+
| ↳ `appKey` | `string` | ✅ | — | — | App key (e.g., 'SlackCLIAPI') |
|
|
176
|
+
| ↳ `actionType` | `string` | ✅ | — | `read`, `read_bulk`, `write`, `run`, `search`, `search_or_write`, `search_and_write`, `filter` | Action type that matches the action's defined type |
|
|
177
|
+
| ↳ `actionKey` | `string` | ✅ | — | — | Action key to execute |
|
|
178
|
+
| ↳ `authenticationId` | `string` | ❌ | — | — | Authentication ID to use for this action |
|
|
179
|
+
| ↳ `inputs` | `object` | ❌ | — | — | Current input values that may affect available fields |
|
|
180
|
+
| ↳ `pageSize` | `number` | ❌ | — | — | Number of input fields per page |
|
|
181
|
+
| ↳ `maxItems` | `number` | ❌ | — | — | Maximum total items to return across all pages |
|
|
170
182
|
|
|
171
183
|
**Returns:** `Promise<PaginatedResult<RootFieldItemItem>>`
|
|
172
184
|
|
|
@@ -174,6 +186,7 @@ Get the input fields required for a specific action
|
|
|
174
186
|
|
|
175
187
|
```typescript
|
|
176
188
|
const result = await sdk.listInputFields({
|
|
189
|
+
options: "example-value",
|
|
177
190
|
appKey: "example-key",
|
|
178
191
|
actionType: "read",
|
|
179
192
|
actionKey: "example-key",
|
|
@@ -186,15 +199,16 @@ Execute an action with the given inputs
|
|
|
186
199
|
|
|
187
200
|
**Parameters:**
|
|
188
201
|
|
|
189
|
-
| Name
|
|
190
|
-
|
|
|
191
|
-
| `
|
|
192
|
-
| `
|
|
193
|
-
| `
|
|
194
|
-
| `
|
|
195
|
-
| `
|
|
196
|
-
| `
|
|
197
|
-
| `
|
|
202
|
+
| Name | Type | Required | Default | Possible Values | Description |
|
|
203
|
+
| -------------------- | -------- | -------- | ------- | ---------------------------------------------------------------------------------------------- | -------------------------------------------------- |
|
|
204
|
+
| `options` | `string` | ✅ | — | — | Execute an action with the given inputs |
|
|
205
|
+
| ↳ `appKey` | `string` | ✅ | — | — | App key (e.g., 'SlackCLIAPI') |
|
|
206
|
+
| ↳ `actionType` | `string` | ✅ | — | `read`, `read_bulk`, `write`, `run`, `search`, `search_or_write`, `search_and_write`, `filter` | Action type that matches the action's defined type |
|
|
207
|
+
| ↳ `actionKey` | `string` | ✅ | — | — | Action key to execute |
|
|
208
|
+
| ↳ `authenticationId` | `string` | ❌ | — | — | Authentication ID to use for this action |
|
|
209
|
+
| ↳ `inputs` | `object` | ❌ | — | — | Input parameters for the action |
|
|
210
|
+
| ↳ `pageSize` | `number` | ❌ | — | — | Number of results per page |
|
|
211
|
+
| ↳ `maxItems` | `number` | ❌ | — | — | Maximum total items to return across all pages |
|
|
198
212
|
|
|
199
213
|
**Returns:** `Promise<PaginatedResult<ActionResultItem>>`
|
|
200
214
|
|
|
@@ -202,6 +216,7 @@ Execute an action with the given inputs
|
|
|
202
216
|
|
|
203
217
|
```typescript
|
|
204
218
|
const result = await sdk.runAction({
|
|
219
|
+
options: "example-value",
|
|
205
220
|
appKey: "example-key",
|
|
206
221
|
actionType: "read",
|
|
207
222
|
actionKey: "example-key",
|
|
@@ -216,9 +231,10 @@ Get detailed information about a specific app
|
|
|
216
231
|
|
|
217
232
|
**Parameters:**
|
|
218
233
|
|
|
219
|
-
| Name
|
|
220
|
-
|
|
|
221
|
-
| `
|
|
234
|
+
| Name | Type | Required | Default | Possible Values | Description |
|
|
235
|
+
| ---------- | -------- | -------- | ------- | --------------- | --------------------------------------------- |
|
|
236
|
+
| `options` | `string` | ✅ | — | — | Get detailed information about a specific app |
|
|
237
|
+
| ↳ `appKey` | `string` | ✅ | — | — | App key of app to fetch (e.g., 'SlackCLIAPI') |
|
|
222
238
|
|
|
223
239
|
**Returns:** `Promise<AppItem>`
|
|
224
240
|
|
|
@@ -226,6 +242,7 @@ Get detailed information about a specific app
|
|
|
226
242
|
|
|
227
243
|
```typescript
|
|
228
244
|
const result = await sdk.getApp({
|
|
245
|
+
options: "example-value",
|
|
229
246
|
appKey: "example-key",
|
|
230
247
|
});
|
|
231
248
|
```
|
|
@@ -236,19 +253,22 @@ List all available apps with optional filtering
|
|
|
236
253
|
|
|
237
254
|
**Parameters:**
|
|
238
255
|
|
|
239
|
-
| Name
|
|
240
|
-
|
|
|
241
|
-
| `
|
|
242
|
-
| `
|
|
243
|
-
| `
|
|
244
|
-
| `
|
|
256
|
+
| Name | Type | Required | Default | Possible Values | Description |
|
|
257
|
+
| ------------ | -------- | -------- | ------- | --------------- | ------------------------------------------------------------------- |
|
|
258
|
+
| `options` | `string` | ✅ | — | — | List all available apps with optional filtering |
|
|
259
|
+
| ↳ `appKeys` | `array` | ❌ | — | — | Filter apps by app keys (e.g., 'SlackCLIAPI' or slug like 'github') |
|
|
260
|
+
| ↳ `search` | `string` | ❌ | — | — | Search for apps by name |
|
|
261
|
+
| ↳ `pageSize` | `number` | ❌ | — | — | Number of apps per page |
|
|
262
|
+
| ↳ `maxItems` | `number` | ❌ | — | — | Maximum total items to return across all pages |
|
|
245
263
|
|
|
246
264
|
**Returns:** `Promise<PaginatedResult<AppItem>>`
|
|
247
265
|
|
|
248
266
|
**Example:**
|
|
249
267
|
|
|
250
268
|
```typescript
|
|
251
|
-
const result = await sdk.listApps(
|
|
269
|
+
const result = await sdk.listApps({
|
|
270
|
+
options: "example-value",
|
|
271
|
+
});
|
|
252
272
|
```
|
|
253
273
|
|
|
254
274
|
### Authentications
|
|
@@ -259,20 +279,23 @@ Find the first authentication matching the criteria
|
|
|
259
279
|
|
|
260
280
|
**Parameters:**
|
|
261
281
|
|
|
262
|
-
| Name
|
|
263
|
-
|
|
|
264
|
-
| `
|
|
265
|
-
| `
|
|
266
|
-
| `
|
|
267
|
-
| `
|
|
268
|
-
| `
|
|
282
|
+
| Name | Type | Required | Default | Possible Values | Description |
|
|
283
|
+
| ------------- | -------- | -------- | ------- | --------------- | ------------------------------------------------------- |
|
|
284
|
+
| `options` | `string` | ✅ | — | — | Find the first authentication matching the criteria |
|
|
285
|
+
| ↳ `appKey` | `string` | ❌ | — | — | App key of authentication to find (e.g., 'SlackCLIAPI') |
|
|
286
|
+
| ↳ `search` | `string` | ❌ | — | — | Search term to filter authentications by title |
|
|
287
|
+
| ↳ `title` | `string` | ❌ | — | — | Filter authentications by exact title match |
|
|
288
|
+
| ↳ `accountId` | `string` | ❌ | — | — | Filter by account ID |
|
|
289
|
+
| ↳ `owner` | `string` | ❌ | — | — | Filter by owner |
|
|
269
290
|
|
|
270
291
|
**Returns:** `Promise<AuthenticationItem>`
|
|
271
292
|
|
|
272
293
|
**Example:**
|
|
273
294
|
|
|
274
295
|
```typescript
|
|
275
|
-
const result = await sdk.findFirstAuthentication(
|
|
296
|
+
const result = await sdk.findFirstAuthentication({
|
|
297
|
+
options: "example-value",
|
|
298
|
+
});
|
|
276
299
|
```
|
|
277
300
|
|
|
278
301
|
#### `findUniqueAuthentication`
|
|
@@ -281,20 +304,23 @@ Find a unique authentication matching the criteria
|
|
|
281
304
|
|
|
282
305
|
**Parameters:**
|
|
283
306
|
|
|
284
|
-
| Name
|
|
285
|
-
|
|
|
286
|
-
| `
|
|
287
|
-
| `
|
|
288
|
-
| `
|
|
289
|
-
| `
|
|
290
|
-
| `
|
|
307
|
+
| Name | Type | Required | Default | Possible Values | Description |
|
|
308
|
+
| ------------- | -------- | -------- | ------- | --------------- | ------------------------------------------------------- |
|
|
309
|
+
| `options` | `string` | ✅ | — | — | Find a unique authentication matching the criteria |
|
|
310
|
+
| ↳ `appKey` | `string` | ❌ | — | — | App key of authentication to find (e.g., 'SlackCLIAPI') |
|
|
311
|
+
| ↳ `search` | `string` | ❌ | — | — | Search term to filter authentications by title |
|
|
312
|
+
| ↳ `title` | `string` | ❌ | — | — | Filter authentications by exact title match |
|
|
313
|
+
| ↳ `accountId` | `string` | ❌ | — | — | Filter by account ID |
|
|
314
|
+
| ↳ `owner` | `string` | ❌ | — | — | Filter by owner |
|
|
291
315
|
|
|
292
316
|
**Returns:** `Promise<AuthenticationItem>`
|
|
293
317
|
|
|
294
318
|
**Example:**
|
|
295
319
|
|
|
296
320
|
```typescript
|
|
297
|
-
const result = await sdk.findUniqueAuthentication(
|
|
321
|
+
const result = await sdk.findUniqueAuthentication({
|
|
322
|
+
options: "example-value",
|
|
323
|
+
});
|
|
298
324
|
```
|
|
299
325
|
|
|
300
326
|
#### `getAuthentication`
|
|
@@ -303,9 +329,10 @@ Get a specific authentication by ID
|
|
|
303
329
|
|
|
304
330
|
**Parameters:**
|
|
305
331
|
|
|
306
|
-
| Name
|
|
307
|
-
|
|
|
308
|
-
| `
|
|
332
|
+
| Name | Type | Required | Default | Possible Values | Description |
|
|
333
|
+
| -------------------- | -------- | -------- | ------- | --------------- | ----------------------------------- |
|
|
334
|
+
| `options` | `string` | ✅ | — | — | Get a specific authentication by ID |
|
|
335
|
+
| ↳ `authenticationId` | `number` | ✅ | — | — | Authentication ID to retrieve |
|
|
309
336
|
|
|
310
337
|
**Returns:** `Promise<AuthenticationItem>`
|
|
311
338
|
|
|
@@ -313,6 +340,7 @@ Get a specific authentication by ID
|
|
|
313
340
|
|
|
314
341
|
```typescript
|
|
315
342
|
const result = await sdk.getAuthentication({
|
|
343
|
+
options: "example-value",
|
|
316
344
|
authenticationId: 12345,
|
|
317
345
|
});
|
|
318
346
|
```
|
|
@@ -323,43 +351,72 @@ List available authentications with optional filtering
|
|
|
323
351
|
|
|
324
352
|
**Parameters:**
|
|
325
353
|
|
|
326
|
-
| Name
|
|
327
|
-
|
|
|
328
|
-
| `
|
|
329
|
-
| `
|
|
330
|
-
| `
|
|
331
|
-
| `
|
|
332
|
-
| `
|
|
333
|
-
| `
|
|
334
|
-
| `
|
|
335
|
-
| `
|
|
354
|
+
| Name | Type | Required | Default | Possible Values | Description |
|
|
355
|
+
| --------------------- | -------- | -------- | ------- | --------------- | -------------------------------------------------------- |
|
|
356
|
+
| `options` | `string` | ✅ | — | — | List available authentications with optional filtering |
|
|
357
|
+
| ↳ `appKey` | `string` | ❌ | — | — | App key of authentications to list (e.g., 'SlackCLIAPI') |
|
|
358
|
+
| ↳ `authenticationIds` | `array` | ❌ | — | — | List of authentication IDs to filter by |
|
|
359
|
+
| ↳ `search` | `string` | ❌ | — | — | Search term to filter authentications by title |
|
|
360
|
+
| ↳ `title` | `string` | ❌ | — | — | Filter authentications by exact title match |
|
|
361
|
+
| ↳ `accountId` | `string` | ❌ | — | — | Filter by account ID |
|
|
362
|
+
| ↳ `owner` | `string` | ❌ | — | — | Filter by owner |
|
|
363
|
+
| ↳ `pageSize` | `number` | ❌ | — | — | Number of authentications per page |
|
|
364
|
+
| ↳ `maxItems` | `number` | ❌ | — | — | Maximum total items to return across all pages |
|
|
336
365
|
|
|
337
366
|
**Returns:** `Promise<PaginatedResult<AuthenticationItem>>`
|
|
338
367
|
|
|
339
368
|
**Example:**
|
|
340
369
|
|
|
341
370
|
```typescript
|
|
342
|
-
const result = await sdk.listAuthentications(
|
|
371
|
+
const result = await sdk.listAuthentications({
|
|
372
|
+
options: "example-value",
|
|
373
|
+
});
|
|
343
374
|
```
|
|
344
375
|
|
|
345
376
|
### HTTP Requests
|
|
346
377
|
|
|
378
|
+
#### `fetch`
|
|
379
|
+
|
|
380
|
+
Execute fetch
|
|
381
|
+
|
|
382
|
+
**Parameters:**
|
|
383
|
+
|
|
384
|
+
| Name | Type | Required | Default | Possible Values | Description |
|
|
385
|
+
| -------------------------- | -------- | -------- | ------- | ---------------------------------------------------------- | -------------------------------------------------------------------- |
|
|
386
|
+
| `url` | `string` | ✅ | — | — | The URL to fetch |
|
|
387
|
+
| `init` | `string` | ❌ | — | — | Fetch options including authentication |
|
|
388
|
+
| ↳ `method` | `string` | ❌ | — | `GET`, `POST`, `PUT`, `DELETE`, `PATCH`, `HEAD`, `OPTIONS` | |
|
|
389
|
+
| ↳ `headers` | `object` | ❌ | — | — | |
|
|
390
|
+
| ↳ `body` | `string` | ❌ | — | — | |
|
|
391
|
+
| ↳ `authenticationId` | `number` | ❌ | — | — | Zapier authentication ID to use for the request |
|
|
392
|
+
| ↳ `callbackUrl` | `string` | ❌ | — | — | URL to send async response to (makes request async) |
|
|
393
|
+
| ↳ `authenticationTemplate` | `string` | ❌ | — | — | Optional JSON string authentication template to bypass Notary lookup |
|
|
394
|
+
|
|
395
|
+
**Returns:** `Promise<Response>`
|
|
396
|
+
|
|
397
|
+
**Example:**
|
|
398
|
+
|
|
399
|
+
```typescript
|
|
400
|
+
const result = await sdk.fetch("https://example.com");
|
|
401
|
+
```
|
|
402
|
+
|
|
347
403
|
#### `request`
|
|
348
404
|
|
|
349
405
|
Make authenticated HTTP requests through Zapier's Relay service
|
|
350
406
|
|
|
351
407
|
**Parameters:**
|
|
352
408
|
|
|
353
|
-
| Name
|
|
354
|
-
|
|
|
355
|
-
| `
|
|
356
|
-
| `
|
|
357
|
-
| `
|
|
358
|
-
| `
|
|
359
|
-
| `
|
|
360
|
-
| `
|
|
361
|
-
| `
|
|
362
|
-
| `
|
|
409
|
+
| Name | Type | Required | Default | Possible Values | Description |
|
|
410
|
+
| -------------------------- | -------- | -------- | ------- | ---------------------------------------------------------- | -------------------------------------------------------------------- |
|
|
411
|
+
| `options` | `string` | ✅ | — | — | Make authenticated HTTP requests through Zapier's Relay service |
|
|
412
|
+
| ↳ `url` | `string` | ✅ | — | — | The URL to request (will be proxied through Relay) |
|
|
413
|
+
| ↳ `method` | `string` | ❌ | — | `GET`, `POST`, `PUT`, `DELETE`, `PATCH`, `HEAD`, `OPTIONS` | HTTP method |
|
|
414
|
+
| ↳ `body` | `string` | ❌ | — | — | Request body as a string |
|
|
415
|
+
| ↳ `authenticationId` | `number` | ❌ | — | — | Zapier authentication ID to use for the request |
|
|
416
|
+
| ↳ `callbackUrl` | `string` | ❌ | — | — | URL to send async response to (makes request async) |
|
|
417
|
+
| ↳ `authenticationTemplate` | `string` | ❌ | — | — | Optional JSON string authentication template to bypass Notary lookup |
|
|
418
|
+
| ↳ `headers` | `string` | ❌ | — | — | Request headers |
|
|
419
|
+
| ↳ `relayBaseUrl` | `string` | ❌ | — | — | Base URL for Relay service |
|
|
363
420
|
|
|
364
421
|
**Returns:** `Promise<Response>`
|
|
365
422
|
|
|
@@ -367,6 +424,7 @@ Make authenticated HTTP requests through Zapier's Relay service
|
|
|
367
424
|
|
|
368
425
|
```typescript
|
|
369
426
|
const result = await sdk.request({
|
|
427
|
+
options: "example-value",
|
|
370
428
|
url: "https://example.com",
|
|
371
429
|
});
|
|
372
430
|
```
|
package/dist/index.cjs
CHANGED
|
@@ -298,6 +298,21 @@ var appsPlugin = ({ sdk }) => {
|
|
|
298
298
|
apps: createAppsProxy({ sdk })
|
|
299
299
|
};
|
|
300
300
|
};
|
|
301
|
+
var FetchUrlSchema = zod.z.union([zod.z.string(), zod.z.instanceof(URL)]).describe("The URL to fetch");
|
|
302
|
+
var FetchInitSchema = zod.z.object({
|
|
303
|
+
method: zod.z.enum(["GET", "POST", "PUT", "DELETE", "PATCH", "HEAD", "OPTIONS"]).optional(),
|
|
304
|
+
headers: zod.z.record(zod.z.string()).optional(),
|
|
305
|
+
body: zod.z.union([
|
|
306
|
+
zod.z.string(),
|
|
307
|
+
zod.z.instanceof(FormData),
|
|
308
|
+
zod.z.instanceof(URLSearchParams)
|
|
309
|
+
]).optional(),
|
|
310
|
+
authenticationId: zod.z.number().optional().describe("Zapier authentication ID to use for the request"),
|
|
311
|
+
callbackUrl: zod.z.string().optional().describe("URL to send async response to (makes request async)"),
|
|
312
|
+
authenticationTemplate: zod.z.string().optional().describe(
|
|
313
|
+
"Optional JSON string authentication template to bypass Notary lookup"
|
|
314
|
+
)
|
|
315
|
+
}).optional().describe("Fetch options including authentication");
|
|
301
316
|
|
|
302
317
|
// src/plugins/fetch/index.ts
|
|
303
318
|
var fetchPlugin = ({ sdk }) => {
|
|
@@ -318,6 +333,19 @@ var fetchPlugin = ({ sdk }) => {
|
|
|
318
333
|
callbackUrl,
|
|
319
334
|
authenticationTemplate
|
|
320
335
|
});
|
|
336
|
+
},
|
|
337
|
+
context: {
|
|
338
|
+
meta: {
|
|
339
|
+
fetch: {
|
|
340
|
+
packages: ["sdk"],
|
|
341
|
+
categories: ["http"],
|
|
342
|
+
returnType: "Response",
|
|
343
|
+
inputParameters: [
|
|
344
|
+
{ name: "url", schema: FetchUrlSchema },
|
|
345
|
+
{ name: "init", schema: FetchInitSchema }
|
|
346
|
+
]
|
|
347
|
+
}
|
|
348
|
+
}
|
|
321
349
|
}
|
|
322
350
|
};
|
|
323
351
|
};
|
|
@@ -3495,37 +3523,53 @@ var registryPlugin = ({ sdk, context }) => {
|
|
|
3495
3523
|
itemType: meta.itemType,
|
|
3496
3524
|
returnType: meta.returnType,
|
|
3497
3525
|
inputSchema: meta.inputSchema,
|
|
3526
|
+
inputParameters: meta.inputParameters,
|
|
3498
3527
|
outputSchema: meta.outputSchema,
|
|
3499
3528
|
categories: meta.categories || [],
|
|
3500
|
-
resolvers: meta.resolvers
|
|
3529
|
+
resolvers: meta.resolvers,
|
|
3530
|
+
packages: meta.packages
|
|
3501
3531
|
};
|
|
3502
3532
|
}).sort((a, b) => a.name.localeCompare(b.name));
|
|
3503
3533
|
const knownCategories = Object.keys(categoryDefinitions);
|
|
3504
|
-
const
|
|
3505
|
-
|
|
3506
|
-
|
|
3507
|
-
const
|
|
3508
|
-
|
|
3509
|
-
|
|
3510
|
-
|
|
3511
|
-
const
|
|
3512
|
-
(f) =>
|
|
3513
|
-
|
|
3514
|
-
|
|
3515
|
-
|
|
3516
|
-
|
|
3517
|
-
|
|
3518
|
-
|
|
3519
|
-
|
|
3520
|
-
|
|
3521
|
-
|
|
3522
|
-
|
|
3523
|
-
|
|
3524
|
-
|
|
3525
|
-
|
|
3526
|
-
|
|
3527
|
-
|
|
3534
|
+
const registryCache = /* @__PURE__ */ new Map();
|
|
3535
|
+
function getRegistry(options) {
|
|
3536
|
+
const packageFilter = options?.package;
|
|
3537
|
+
const cacheKey = packageFilter || "__all__";
|
|
3538
|
+
if (registryCache.has(cacheKey)) {
|
|
3539
|
+
return registryCache.get(cacheKey);
|
|
3540
|
+
}
|
|
3541
|
+
const filteredFunctions = packageFilter ? functions.filter(
|
|
3542
|
+
(f) => (
|
|
3543
|
+
// Include if packages is undefined (belongs to all packages) or includes the specified package
|
|
3544
|
+
!f.packages || f.packages.includes(packageFilter)
|
|
3545
|
+
)
|
|
3546
|
+
) : functions;
|
|
3547
|
+
const filteredCategories = knownCategories.sort((a, b) => {
|
|
3548
|
+
if (a === "other") return 1;
|
|
3549
|
+
if (b === "other") return -1;
|
|
3550
|
+
const titleA = categoryDefinitions[a].title;
|
|
3551
|
+
const titleB = categoryDefinitions[b].title;
|
|
3552
|
+
return titleA.localeCompare(titleB);
|
|
3553
|
+
}).map((categoryKey) => {
|
|
3554
|
+
const categoryFunctions = filteredFunctions.filter(
|
|
3555
|
+
(f) => f.categories.includes(categoryKey) || // If the category is "other" and the function is not in any other category, include it
|
|
3556
|
+
categoryKey === "other" && !f.categories.some((c) => knownCategories.includes(c))
|
|
3557
|
+
).map((f) => f.name).sort();
|
|
3558
|
+
const definition = categoryDefinitions[categoryKey];
|
|
3559
|
+
const title = definition.title;
|
|
3560
|
+
return {
|
|
3561
|
+
key: categoryKey,
|
|
3562
|
+
title,
|
|
3563
|
+
titlePlural: definition.titlePlural ?? `${title}s`,
|
|
3564
|
+
functions: categoryFunctions
|
|
3565
|
+
};
|
|
3566
|
+
}).filter((category) => category.functions.length > 0);
|
|
3567
|
+
const result = {
|
|
3568
|
+
functions: filteredFunctions,
|
|
3569
|
+
categories: filteredCategories
|
|
3528
3570
|
};
|
|
3571
|
+
registryCache.set(cacheKey, result);
|
|
3572
|
+
return result;
|
|
3529
3573
|
}
|
|
3530
3574
|
return {
|
|
3531
3575
|
getRegistry
|