@zapier/zapier-sdk 0.35.0 → 0.37.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.
Files changed (71) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/CLAUDE.md +50 -0
  3. package/README.md +91 -32
  4. package/dist/constants.d.ts +4 -0
  5. package/dist/constants.d.ts.map +1 -1
  6. package/dist/constants.js +4 -0
  7. package/dist/index.cjs +386 -169
  8. package/dist/index.d.mts +70 -9
  9. package/dist/index.d.ts +2 -0
  10. package/dist/index.d.ts.map +1 -1
  11. package/dist/index.js +3 -0
  12. package/dist/index.mjs +380 -170
  13. package/dist/plugins/apps/index.d.ts.map +1 -1
  14. package/dist/plugins/apps/index.js +61 -24
  15. package/dist/plugins/apps/schemas.d.ts +4 -1
  16. package/dist/plugins/apps/schemas.d.ts.map +1 -1
  17. package/dist/plugins/apps/schemas.js +4 -2
  18. package/dist/plugins/connections/index.d.ts +11 -0
  19. package/dist/plugins/connections/index.d.ts.map +1 -0
  20. package/dist/plugins/connections/index.js +21 -0
  21. package/dist/plugins/fetch/index.d.ts +4 -1
  22. package/dist/plugins/fetch/index.d.ts.map +1 -1
  23. package/dist/plugins/fetch/index.js +9 -3
  24. package/dist/plugins/fetch/schemas.d.ts +1 -0
  25. package/dist/plugins/fetch/schemas.d.ts.map +1 -1
  26. package/dist/plugins/fetch/schemas.js +2 -1
  27. package/dist/plugins/listActions/index.d.ts.map +1 -1
  28. package/dist/plugins/listActions/index.js +2 -1
  29. package/dist/plugins/listApps/index.d.ts.map +1 -1
  30. package/dist/plugins/listApps/index.js +5 -2
  31. package/dist/plugins/listClientCredentials/index.d.ts.map +1 -1
  32. package/dist/plugins/listClientCredentials/index.js +6 -4
  33. package/dist/plugins/listConnections/index.d.ts.map +1 -1
  34. package/dist/plugins/listConnections/index.js +6 -4
  35. package/dist/plugins/listInputFieldChoices/index.d.ts.map +1 -1
  36. package/dist/plugins/listInputFieldChoices/index.js +2 -1
  37. package/dist/plugins/listInputFields/index.d.ts.map +1 -1
  38. package/dist/plugins/listInputFields/index.js +2 -1
  39. package/dist/plugins/manifest/index.d.ts +2 -0
  40. package/dist/plugins/manifest/index.d.ts.map +1 -1
  41. package/dist/plugins/manifest/index.js +14 -6
  42. package/dist/plugins/manifest/schemas.d.ts +27 -7
  43. package/dist/plugins/manifest/schemas.d.ts.map +1 -1
  44. package/dist/plugins/manifest/schemas.js +8 -10
  45. package/dist/plugins/runAction/index.d.ts +4 -1
  46. package/dist/plugins/runAction/index.d.ts.map +1 -1
  47. package/dist/plugins/runAction/index.js +78 -14
  48. package/dist/plugins/runAction/schemas.d.ts +1 -0
  49. package/dist/plugins/runAction/schemas.d.ts.map +1 -1
  50. package/dist/plugins/runAction/schemas.js +2 -1
  51. package/dist/plugins/tables/listTableRecords/index.d.ts.map +1 -1
  52. package/dist/plugins/tables/listTableRecords/index.js +6 -4
  53. package/dist/plugins/tables/listTables/index.d.ts.map +1 -1
  54. package/dist/plugins/tables/listTables/index.js +6 -4
  55. package/dist/sdk.d.ts +5 -1
  56. package/dist/sdk.d.ts.map +1 -1
  57. package/dist/sdk.js +3 -0
  58. package/dist/types/connections.d.ts +19 -0
  59. package/dist/types/connections.d.ts.map +1 -0
  60. package/dist/types/connections.js +18 -0
  61. package/dist/types/properties.d.ts +2 -0
  62. package/dist/types/properties.d.ts.map +1 -1
  63. package/dist/types/properties.js +3 -0
  64. package/dist/types/sdk.d.ts.map +1 -1
  65. package/dist/utils/domain-utils.d.ts +15 -0
  66. package/dist/utils/domain-utils.d.ts.map +1 -1
  67. package/dist/utils/domain-utils.js +30 -0
  68. package/dist/utils/function-utils.d.ts +2 -2
  69. package/dist/utils/function-utils.d.ts.map +1 -1
  70. package/dist/utils/function-utils.js +2 -3
  71. package/package.json +6 -1
package/CHANGELOG.md CHANGED
@@ -1,5 +1,17 @@
1
1
  # @zapier/zapier-sdk
2
2
 
3
+ ## 0.37.0
4
+
5
+ ### Minor Changes
6
+
7
+ - 307aa98: Add named connections support. A new `connection` parameter on `runAction`, the apps proxy, and `fetch` resolves a connection alias (string) from a connections map, or accepts a numeric `connectionId` directly. The map is provided via the `connections` field in `.zapierrc` (or the inline `manifest` option on `createZapierSdk()`).
8
+
9
+ ## 0.36.0
10
+
11
+ ### Minor Changes
12
+
13
+ - 3a447d3: Add support for pagination in Run Action
14
+
3
15
  ## 0.35.0
4
16
 
5
17
  ### Minor Changes
package/CLAUDE.md CHANGED
@@ -237,6 +237,56 @@ Run `add` again when:
237
237
  - An app has been updated and you want the latest fields
238
238
  - You've deleted your generated types
239
239
 
240
+ ## Named Connections
241
+
242
+ Named connections let you decouple workflow code from specific connection IDs. An external system (like an execution engine) provides the mapping via `.zapierrc`, and the workflow code references connections by name.
243
+
244
+ ### Providing the Mapping
245
+
246
+ Connections are configured in `.zapierrc` alongside app version pins, or inline via the `manifest` option:
247
+
248
+ ```typescript
249
+ const zapier = createZapierSdk({
250
+ manifest: {
251
+ apps: { slack: { implementationName: "SlackCLIAPI", version: "1.21.1" } },
252
+ connections: {
253
+ slack_work: { connectionId: 12345 },
254
+ google_sheets: { connectionId: 67890 },
255
+ },
256
+ },
257
+ });
258
+ ```
259
+
260
+ ### Using Named Connections
261
+
262
+ ```typescript
263
+ // Per-call with alias
264
+ await zapier.apps.slack.read.channels({ connection: "slack_work" });
265
+
266
+ // Factory binding
267
+ const slack = zapier.apps.slack({ connection: "slack_work" });
268
+ await slack.read.channels({});
269
+
270
+ // Lower-level API
271
+ await zapier.runAction({
272
+ appKey: "slack",
273
+ actionType: "read",
274
+ actionKey: "channels",
275
+ connection: "slack_work",
276
+ });
277
+
278
+ // Direct connectionId also works
279
+ await zapier.apps.slack.read.channels({ connection: 12345 });
280
+ ```
281
+
282
+ ### Resolution Precedence
283
+
284
+ For `connectionId`: explicit `connectionId` > `connection` alias lookup (strings) or direct use (numbers) > factory binding > deprecated `authenticationId`.
285
+
286
+ App version is always resolved from the `.zapierrc` manifest, not from connections.
287
+
288
+ `connectionId` and `connection` are mutually exclusive in the same call.
289
+
240
290
  ## Error Handling
241
291
 
242
292
  ### Debugging
package/README.md CHANGED
@@ -329,6 +329,61 @@ The `createZapierSdk(...)` factory function is the main entry point for the SDK.
329
329
  | `maxNetworkRetries` | `number` | ❌ | — | — | Max retries for rate-limited requests (default: 3). |
330
330
  | `maxNetworkRetryDelayMs` | `number` | ❌ | — | — | Max delay in ms to wait for retry (default: 60000). |
331
331
 
332
+ ## Named Connections
333
+
334
+ Named connections let you decouple workflow code from specific connection IDs. Instead of hardcoding a `connectionId`, you reference a connection by name and the SDK resolves it from a mapping.
335
+
336
+ This is useful when an execution engine or deployment system manages which connections a workflow should use.
337
+
338
+ ### Providing the mapping
339
+
340
+ Connections are configured in `.zapierrc` alongside app version pins, or inline via the `manifest` option:
341
+
342
+ ```typescript
343
+ const zapier = createZapierSdk({
344
+ manifest: {
345
+ apps: { slack: { implementationName: "SlackCLIAPI", version: "1.21.1" } },
346
+ connections: {
347
+ slack_work: { connectionId: 12345 },
348
+ google_sheets: { connectionId: 67890 },
349
+ },
350
+ },
351
+ });
352
+ ```
353
+
354
+ Each connection entry maps a name to a `connectionId`. App version resolution is handled separately via the `apps` section of `.zapierrc`.
355
+
356
+ ### Using named connections
357
+
358
+ Reference connections by alias using the `connection` parameter. String values are resolved from the connections map; numeric values are used directly as a `connectionId`.
359
+
360
+ ```typescript
361
+ // Per-call with alias
362
+ await zapier.apps.slack.read.channels({ connection: "slack_work" });
363
+
364
+ // Factory binding
365
+ const slack = zapier.apps.slack({ connection: "slack_work" });
366
+ await slack.read.channels({});
367
+
368
+ // Lower-level runAction
369
+ await zapier.runAction({
370
+ appKey: "slack",
371
+ actionType: "read",
372
+ actionKey: "channels",
373
+ connection: "slack_work",
374
+ });
375
+
376
+ // Authenticated fetch
377
+ await zapier.fetch("https://slack.com/api/auth.test", {
378
+ connection: "slack_work",
379
+ });
380
+
381
+ // Direct connectionId also works
382
+ await zapier.apps.slack.read.channels({ connection: 12345 });
383
+ ```
384
+
385
+ `connection` and `connectionId` are mutually exclusive in the same call. You can still use `connectionId` directly if you prefer.
386
+
332
387
  ## Available Functions
333
388
 
334
389
  ### Accounts
@@ -561,18 +616,19 @@ Execute an action with the given inputs
561
616
 
562
617
  **Parameters:**
563
618
 
564
- | Name | Type | Required | Default | Possible Values | Description |
565
- | ---------------- | ---------------- | -------- | ------- | ---------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------- |
566
- | `options` | `object` | ✅ | — | — | |
567
- | ↳ `appKey` | `string` | ✅ | — | — | App key (e.g., 'SlackCLIAPI' or slug like 'github') |
568
- | ↳ `actionType` | `string` | ✅ | — | `read`, `read_bulk`, `write`, `run`, `search`, `search_or_write`, `search_and_write`, `filter` | Action type that matches the action's defined type |
569
- | ↳ `actionKey` | `string` | ✅ | — | — | Action key to execute |
570
- | ↳ `connectionId` | `string, number` | ❌ | — | — | Connection ID to use when running the action. Required if the action needs a connection to authenticate and interact with the service. |
571
- | ↳ `inputs` | `object` | ❌ | — | — | Input parameters for the action |
572
- | ↳ `timeoutMs` | `number` | ❌ | — | — | Maximum time to wait for action completion in milliseconds (default: 180000) |
573
- | ↳ `pageSize` | `number` | ❌ | — | — | Number of results per page |
574
- | ↳ `maxItems` | `number` | ❌ | — | — | Maximum total items to return across all pages |
575
- | ↳ `cursor` | `string` | ❌ | — | — | Cursor to start from |
619
+ | Name | Type | Required | Default | Possible Values | Description |
620
+ | ---------------- | ---------------- | -------- | ------- | ---------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
621
+ | `options` | `object` | ✅ | — | — | |
622
+ | ↳ `appKey` | `string` | ✅ | — | — | App key (e.g., 'SlackCLIAPI' or slug like 'github') |
623
+ | ↳ `actionType` | `string` | ✅ | — | `read`, `read_bulk`, `write`, `run`, `search`, `search_or_write`, `search_and_write`, `filter` | Action type that matches the action's defined type |
624
+ | ↳ `actionKey` | `string` | ✅ | — | — | Action key to execute |
625
+ | ↳ `connectionId` | `string, number` | ❌ | — | — | Connection ID to use when running the action. Required if the action needs a connection to authenticate and interact with the service. |
626
+ | ↳ `connection` | `string, number` | ❌ | — | — | Connection alias (string) or numeric connectionId. Strings are resolved from the connections map; numbers are used directly. Mutually exclusive with connectionId. |
627
+ | ↳ `inputs` | `object` | ❌ | — | — | Input parameters for the action |
628
+ | ↳ `timeoutMs` | `number` | ❌ | — | — | Maximum time to wait for action completion in milliseconds (default: 180000) |
629
+ | ↳ `pageSize` | `number` | ❌ | — | — | Number of results per page |
630
+ | ↳ `maxItems` | `number` | ❌ | — | — | Maximum total items to return across all pages |
631
+ | ↳ `cursor` | `string` | ❌ | — | — | Cursor to start from |
576
632
 
577
633
  **Returns:** `Promise<PaginatedResult<ActionResultItem>>`
578
634
 
@@ -611,14 +667,15 @@ for await (const actionResult of zapier
611
667
 
612
668
  #### `apps.{appKey}`
613
669
 
614
- Bind a connection ID to an app
670
+ Bind a connection alias or numeric connectionId to an app
615
671
 
616
672
  **Parameters:**
617
673
 
618
- | Name | Type | Required | Default | Possible Values | Description |
619
- | ---------------- | ---------------- | -------- | ------- | --------------- | ------------------------------------ |
620
- | `options` | `object` | ✅ | — | — | |
621
- | ↳ `connectionId` | `string, number` | ❌ | — | — | Connection ID to use for this action |
674
+ | Name | Type | Required | Default | Possible Values | Description |
675
+ | ---------------- | ---------------- | -------- | ------- | --------------- | ---------------------------------------------------------------------------------------------------------------------------- |
676
+ | `options` | `object` | ✅ | — | — | |
677
+ | ↳ `connectionId` | `string, number` | ❌ | — | — | Connection ID to use for this action |
678
+ | ↳ `connection` | `string, number` | ❌ | — | — | Connection alias (string) or numeric connectionId. Strings are resolved from the connections map; numbers are used directly. |
622
679
 
623
680
  **Returns:** `Promise<AppProxy>`
624
681
 
@@ -634,12 +691,13 @@ Execute an action with the given inputs for the bound app, as an alternative to
634
691
 
635
692
  **Parameters:**
636
693
 
637
- | Name | Type | Required | Default | Possible Values | Description |
638
- | ---------------- | ---------------- | -------- | ------- | --------------- | ---------------------------------------------------------------------------- |
639
- | `options` | `object` | ✅ | — | — | |
640
- | ↳ `inputs` | `object` | ❌ | — | — | |
641
- | ↳ `connectionId` | `string, number` | ❌ | — | — | Connection ID to use for this action |
642
- | ↳ `timeoutMs` | `number` | ❌ | — | — | Maximum time to wait for action completion in milliseconds (default: 180000) |
694
+ | Name | Type | Required | Default | Possible Values | Description |
695
+ | ---------------- | ---------------- | -------- | ------- | --------------- | ---------------------------------------------------------------------------------------------------------------------------- |
696
+ | `options` | `object` | ✅ | — | — | |
697
+ | ↳ `inputs` | `object` | ❌ | — | — | |
698
+ | ↳ `connectionId` | `string, number` | ❌ | — | — | Connection ID to use for this action |
699
+ | ↳ `connection` | `string, number` | ❌ | — | — | Connection alias (string) or numeric connectionId. Strings are resolved from the connections map; numbers are used directly. |
700
+ | ↳ `timeoutMs` | `number` | ❌ | — | — | Maximum time to wait for action completion in milliseconds (default: 180000) |
643
701
 
644
702
  **Returns:** `Promise<PaginatedResult<ActionResultItem>>`
645
703
 
@@ -912,15 +970,16 @@ Make authenticated HTTP requests to any API through Zapier. Pass a connectionId
912
970
 
913
971
  **Parameters:**
914
972
 
915
- | Name | Type | Required | Default | Possible Values | Description |
916
- | ---------------- | ------------------------ | -------- | ------- | ---------------------------------------------------------- | --------------------------------------------------------------------------------------------------- |
917
- | `url` | `string, custom` | ✅ | — | — | The full URL of the API endpoint to call (proxied through Zapier's Relay service) |
918
- | `init` | `object` | ❌ | — | — | Request options including method, headers, body, and authentication |
919
- | ↳ `method` | `string` | ❌ | — | `GET`, `POST`, `PUT`, `DELETE`, `PATCH`, `HEAD`, `OPTIONS` | HTTP method for the request (defaults to GET) |
920
- | ↳ `headers` | `object` | ❌ | — | — | HTTP headers to include in the request |
921
- | ↳ `body` | `string, custom, record` | ❌ | — | — | Request body — plain objects and JSON strings are auto-detected and Content-Type is set accordingly |
922
- | ↳ `connectionId` | `string, number` | ❌ | — | — | Connection ID to use for this action |
923
- | ↳ `callbackUrl` | `string` | ❌ | — | — | URL to send async response to (makes request async) |
973
+ | Name | Type | Required | Default | Possible Values | Description |
974
+ | ---------------- | ------------------------ | -------- | ------- | ---------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------- |
975
+ | `url` | `string, custom` | ✅ | — | — | The full URL of the API endpoint to call (proxied through Zapier's Relay service) |
976
+ | `init` | `object` | ❌ | — | — | Request options including method, headers, body, and authentication |
977
+ | ↳ `method` | `string` | ❌ | — | `GET`, `POST`, `PUT`, `DELETE`, `PATCH`, `HEAD`, `OPTIONS` | HTTP method for the request (defaults to GET) |
978
+ | ↳ `headers` | `object` | ❌ | — | — | HTTP headers to include in the request |
979
+ | ↳ `body` | `string, custom, record` | ❌ | — | — | Request body — plain objects and JSON strings are auto-detected and Content-Type is set accordingly |
980
+ | ↳ `connectionId` | `string, number` | ❌ | — | — | Connection ID to use for this action |
981
+ | ↳ `connection` | `string, number` | ❌ | — | — | Connection alias (string) or numeric connectionId. Strings are resolved from the connections map; numbers are used directly. |
982
+ | ↳ `callbackUrl` | `string` | ❌ | — | — | URL to send async response to (makes request async) |
924
983
 
925
984
  **Returns:** `Promise<Response>`
926
985
 
@@ -11,6 +11,10 @@ export declare const ZAPIER_BASE_URL: string;
11
11
  * Maximum number of items that can be requested per page across all paginated functions
12
12
  */
13
13
  export declare const MAX_PAGE_LIMIT = 10000;
14
+ /**
15
+ * Default number of items per page for paginated functions
16
+ */
17
+ export declare const DEFAULT_PAGE_SIZE = 100;
14
18
  /**
15
19
  * Default timeout for action execution (in milliseconds)
16
20
  */
@@ -1 +1 @@
1
- {"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH;;GAEG;AACH,eAAO,MAAM,eAAe,QACyB,CAAC;AAEtD;;GAEG;AACH,eAAO,MAAM,cAAc,QAAQ,CAAC;AAEpC;;GAEG;AACH,eAAO,MAAM,yBAAyB,SAAU,CAAC;AAejD;;GAEG;AACH,eAAO,MAAM,0BAA0B,QACY,CAAC;AACpD,eAAO,MAAM,iCAAiC,QACiB,CAAC"}
1
+ {"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH;;GAEG;AACH,eAAO,MAAM,eAAe,QACyB,CAAC;AAEtD;;GAEG;AACH,eAAO,MAAM,cAAc,QAAQ,CAAC;AAEpC;;GAEG;AACH,eAAO,MAAM,iBAAiB,MAAM,CAAC;AAErC;;GAEG;AACH,eAAO,MAAM,yBAAyB,SAAU,CAAC;AAejD;;GAEG;AACH,eAAO,MAAM,0BAA0B,QACY,CAAC;AACpD,eAAO,MAAM,iCAAiC,QACiB,CAAC"}
package/dist/constants.js CHANGED
@@ -11,6 +11,10 @@ export const ZAPIER_BASE_URL = process.env.ZAPIER_BASE_URL || "https://zapier.co
11
11
  * Maximum number of items that can be requested per page across all paginated functions
12
12
  */
13
13
  export const MAX_PAGE_LIMIT = 10000;
14
+ /**
15
+ * Default number of items per page for paginated functions
16
+ */
17
+ export const DEFAULT_PAGE_SIZE = 100;
14
18
  /**
15
19
  * Default timeout for action execution (in milliseconds)
16
20
  */