@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/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,20 @@
|
|
|
1
1
|
# @zapier/zapier-sdk
|
|
2
2
|
|
|
3
|
+
## 0.25.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- b0b7eb3: Add timeoutMs for setting the timeout for polling action results.
|
|
8
|
+
|
|
9
|
+
## 0.24.0
|
|
10
|
+
|
|
11
|
+
### Minor Changes
|
|
12
|
+
|
|
13
|
+
- d72cda1: Deprecates request() in favor of self-contained fetch(). The fetch plugin now handles URL-to-relay transformation, header normalization,
|
|
14
|
+
and body content-type inference directly instead of delegating to request. The request plugin is preserved as a backward-compatible
|
|
15
|
+
shim that forwards to fetch. CLI and MCP now expose a fetch command via a new inputParameters registry concept for
|
|
16
|
+
multi-positional-argument functions.
|
|
17
|
+
|
|
3
18
|
## 0.23.2
|
|
4
19
|
|
|
5
20
|
### 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
|
|
|
@@ -454,17 +453,18 @@ Execute an action with the given inputs
|
|
|
454
453
|
|
|
455
454
|
**Parameters:**
|
|
456
455
|
|
|
457
|
-
| Name | Type | Required | Default | Possible Values | Description
|
|
458
|
-
| -------------------- | ---------------- | -------- | ------- | ---------------------------------------------------------------------------------------------- |
|
|
459
|
-
| `options` | `object` | ✅ | — | — |
|
|
460
|
-
| ↳ `appKey` | `string` | ✅ | — | — | App key (e.g., 'SlackCLIAPI' or slug like 'github')
|
|
461
|
-
| ↳ `actionType` | `string` | ✅ | — | `read`, `read_bulk`, `write`, `run`, `search`, `search_or_write`, `search_and_write`, `filter` | Action type that matches the action's defined type
|
|
462
|
-
| ↳ `actionKey` | `string` | ✅ | — | — | Action key to execute
|
|
463
|
-
| ↳ `authenticationId` | `string, number` | ❌ | — | — | Authentication ID to use for this action
|
|
464
|
-
| ↳ `inputs` | `object` | ❌ | — | — | Input parameters for the action
|
|
465
|
-
| ↳ `
|
|
466
|
-
| ↳ `
|
|
467
|
-
| ↳ `
|
|
456
|
+
| Name | Type | Required | Default | Possible Values | Description |
|
|
457
|
+
| -------------------- | ---------------- | -------- | ------- | ---------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------- |
|
|
458
|
+
| `options` | `object` | ✅ | — | — | |
|
|
459
|
+
| ↳ `appKey` | `string` | ✅ | — | — | App key (e.g., 'SlackCLIAPI' or slug like 'github') |
|
|
460
|
+
| ↳ `actionType` | `string` | ✅ | — | `read`, `read_bulk`, `write`, `run`, `search`, `search_or_write`, `search_and_write`, `filter` | Action type that matches the action's defined type |
|
|
461
|
+
| ↳ `actionKey` | `string` | ✅ | — | — | Action key to execute |
|
|
462
|
+
| ↳ `authenticationId` | `string, number` | ❌ | — | — | Authentication ID to use for this action |
|
|
463
|
+
| ↳ `inputs` | `object` | ❌ | — | — | Input parameters for the action |
|
|
464
|
+
| ↳ `timeoutMs` | `number` | ❌ | — | — | Maximum time to wait for action completion in milliseconds (default: 180000) |
|
|
465
|
+
| ↳ `pageSize` | `number` | ❌ | — | — | Number of results per page |
|
|
466
|
+
| ↳ `maxItems` | `number` | ❌ | — | — | Maximum total items to return across all pages |
|
|
467
|
+
| ↳ `cursor` | `string` | ❌ | — | — | Cursor to start from |
|
|
468
468
|
|
|
469
469
|
**Returns:** `Promise<PaginatedResult<ActionResultItem>>`
|
|
470
470
|
|
|
@@ -528,11 +528,12 @@ Execute an action with the given inputs for the bound app, as an alternative to
|
|
|
528
528
|
|
|
529
529
|
**Parameters:**
|
|
530
530
|
|
|
531
|
-
| Name | Type | Required | Default | Possible Values | Description
|
|
532
|
-
| -------------------- | ---------------- | -------- | ------- | --------------- |
|
|
533
|
-
| `options` | `object` | ✅ | — | — |
|
|
534
|
-
| ↳ `inputs` | `object` | ❌ | — | — |
|
|
535
|
-
| ↳ `authenticationId` | `string, number` | ❌ | — | — | Authentication ID to use for this action
|
|
531
|
+
| Name | Type | Required | Default | Possible Values | Description |
|
|
532
|
+
| -------------------- | ---------------- | -------- | ------- | --------------- | ---------------------------------------------------------------------------- |
|
|
533
|
+
| `options` | `object` | ✅ | — | — | |
|
|
534
|
+
| ↳ `inputs` | `object` | ❌ | — | — | |
|
|
535
|
+
| ↳ `authenticationId` | `string, number` | ❌ | — | — | Authentication ID to use for this action |
|
|
536
|
+
| ↳ `timeoutMs` | `number` | ❌ | — | — | Maximum time to wait for action completion in milliseconds (default: 180000) |
|
|
536
537
|
|
|
537
538
|
**Returns:** `Promise<PaginatedResult<ActionResultItem>>`
|
|
538
539
|
|
|
@@ -803,20 +804,20 @@ for await (const clientCredentials of sdk.listClientCredentials().items()) {
|
|
|
803
804
|
|
|
804
805
|
#### `fetch`
|
|
805
806
|
|
|
806
|
-
|
|
807
|
+
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
808
|
|
|
808
809
|
**Parameters:**
|
|
809
810
|
|
|
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
|
|
811
|
+
| Name | Type | Required | Default | Possible Values | Description |
|
|
812
|
+
| -------------------------- | ------------------------ | -------- | ------- | ---------------------------------------------------------- | --------------------------------------------------------------------------------- |
|
|
813
|
+
| `url` | `string, custom` | ✅ | — | — | The full URL of the API endpoint to call (proxied through Zapier's Relay service) |
|
|
814
|
+
| `init` | `object` | ❌ | — | — | Request options including method, headers, body, and authentication |
|
|
815
|
+
| ↳ `method` | `string` | ❌ | — | `GET`, `POST`, `PUT`, `DELETE`, `PATCH`, `HEAD`, `OPTIONS` | HTTP method for the request (defaults to GET) |
|
|
816
|
+
| ↳ `headers` | `object` | ❌ | — | — | HTTP headers to include in the request |
|
|
817
|
+
| ↳ `body` | `string, custom, custom` | ❌ | — | — | Request body — JSON strings are auto-detected and Content-Type is set accordingly |
|
|
818
|
+
| ↳ `authenticationId` | `string, number` | ❌ | — | — | Authentication ID to use for this action |
|
|
819
|
+
| ↳ `callbackUrl` | `string` | ❌ | — | — | URL to send async response to (makes request async) |
|
|
820
|
+
| ↳ `authenticationTemplate` | `string` | ❌ | — | — | Optional JSON string authentication template to bypass Notary lookup |
|
|
820
821
|
|
|
821
822
|
**Returns:** `Promise<Response>`
|
|
822
823
|
|
|
@@ -825,31 +826,3 @@ Execute fetch
|
|
|
825
826
|
```typescript
|
|
826
827
|
const result = await sdk.fetch("example-value", { key: "value" });
|
|
827
828
|
```
|
|
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/api/polling.d.ts
CHANGED
|
@@ -4,6 +4,13 @@
|
|
|
4
4
|
* This module provides utilities for polling HTTP endpoints until completion,
|
|
5
5
|
* with configurable retry logic and exponential backoff.
|
|
6
6
|
*/
|
|
7
|
+
/**
|
|
8
|
+
* Get the appropriate polling interval based on elapsed time.
|
|
9
|
+
* Starts with frequent polling and backs off as time passes.
|
|
10
|
+
* @param elapsedMs Time elapsed since polling started (in milliseconds)
|
|
11
|
+
* @returns The polling interval to use (in milliseconds)
|
|
12
|
+
*/
|
|
13
|
+
export declare function getPollingInterval(elapsedMs: number): number;
|
|
7
14
|
/**
|
|
8
15
|
* Options for the polling function
|
|
9
16
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"polling.d.ts","sourceRoot":"","sources":["../../src/api/polling.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAgCH;;GAEG;AACH,MAAM,WAAW,WAAW,CAAC,OAAO,GAAG,OAAO;IAC5C,8CAA8C;IAC9C,SAAS,EAAE,MAAM,OAAO,CAAC,QAAQ,CAAC,CAAC;IACnC,4DAA4D;IAC5D,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,wDAAwD;IACxD,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,iEAAiE;IACjE,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,uGAAuG;IACvG,SAAS,CAAC,EAAE,CAAC,QAAQ,EAAE,OAAO,KAAK,OAAO,CAAC;IAC3C,uDAAuD;IACvD,eAAe,CAAC,EAAE,CAAC,QAAQ,EAAE,OAAO,KAAK,OAAO,CAAC;IACjD,oEAAoE;IACpE,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB;AAED,mBAAW,UAAU;IACnB,OAAO,YAAY;IACnB,QAAQ,aAAa;CACtB;AAED;;GAEG;AACH,MAAM,MAAM,UAAU,CAAC,OAAO,GAAG,OAAO,IAAI;IAC1C,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,MAAM,EAAE,UAAU,CAAC;IACnB,UAAU,EAAE,MAAM,CAAC;CACpB,CAAC;AAgEF;;;;;;;GAOG;AACH,wBAAsB,iBAAiB,CAAC,OAAO,GAAG,OAAO,EACvD,OAAO,EAAE,WAAW,CAAC,OAAO,CAAC,GAC5B,OAAO,CAAC,OAAO,CAAC,
|
|
1
|
+
{"version":3,"file":"polling.d.ts","sourceRoot":"","sources":["../../src/api/polling.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAgCH;;;;;GAKG;AACH,wBAAgB,kBAAkB,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,CAG5D;AAED;;GAEG;AACH,MAAM,WAAW,WAAW,CAAC,OAAO,GAAG,OAAO;IAC5C,8CAA8C;IAC9C,SAAS,EAAE,MAAM,OAAO,CAAC,QAAQ,CAAC,CAAC;IACnC,4DAA4D;IAC5D,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,wDAAwD;IACxD,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,iEAAiE;IACjE,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,uGAAuG;IACvG,SAAS,CAAC,EAAE,CAAC,QAAQ,EAAE,OAAO,KAAK,OAAO,CAAC;IAC3C,uDAAuD;IACvD,eAAe,CAAC,EAAE,CAAC,QAAQ,EAAE,OAAO,KAAK,OAAO,CAAC;IACjD,oEAAoE;IACpE,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB;AAED,mBAAW,UAAU;IACnB,OAAO,YAAY;IACnB,QAAQ,aAAa;CACtB;AAED;;GAEG;AACH,MAAM,MAAM,UAAU,CAAC,OAAO,GAAG,OAAO,IAAI;IAC1C,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,MAAM,EAAE,UAAU,CAAC;IACnB,UAAU,EAAE,MAAM,CAAC;CACpB,CAAC;AAgEF;;;;;;;GAOG;AACH,wBAAsB,iBAAiB,CAAC,OAAO,GAAG,OAAO,EACvD,OAAO,EAAE,WAAW,CAAC,OAAO,CAAC,GAC5B,OAAO,CAAC,OAAO,CAAC,CAgGlB"}
|
package/dist/api/polling.js
CHANGED
|
@@ -12,18 +12,28 @@ const DEFAULT_TIMEOUT_MS = 180000;
|
|
|
12
12
|
const DEFAULT_SUCCESS_STATUS = 200;
|
|
13
13
|
const DEFAULT_PENDING_STATUS = 202;
|
|
14
14
|
const DEFAULT_INITIAL_DELAY_MS = 50;
|
|
15
|
-
const DEFAULT_MAX_POLLING_INTERVAL_MS =
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
// Note: These are default stages, actual hard timeout is enforced separately below
|
|
19
|
-
const DEFAULT_POLLING_STAGES = [
|
|
15
|
+
const DEFAULT_MAX_POLLING_INTERVAL_MS = 60000;
|
|
16
|
+
// Polling stages: [elapsed_time_threshold_ms, poll_interval_ms]
|
|
17
|
+
const POLLING_STAGES = [
|
|
20
18
|
[125, 125], // Up to 125ms: poll every 125ms
|
|
21
19
|
[375, 250], // Up to 375ms: poll every 250ms
|
|
22
20
|
[875, 500], // Up to 875ms: poll every 500ms
|
|
23
21
|
[10000, 1000], // Up to 10s: poll every 1s
|
|
24
22
|
[30000, 2500], // Up to 30s: poll every 2.5s
|
|
25
23
|
[60000, 5000], // Up to 60s: poll every 5s
|
|
24
|
+
[180000, 10000], // Up to 3min: poll every 10s
|
|
25
|
+
// Beyond 3min: use DEFAULT_MAX_POLLING_INTERVAL_MS (60s)
|
|
26
26
|
];
|
|
27
|
+
/**
|
|
28
|
+
* Get the appropriate polling interval based on elapsed time.
|
|
29
|
+
* Starts with frequent polling and backs off as time passes.
|
|
30
|
+
* @param elapsedMs Time elapsed since polling started (in milliseconds)
|
|
31
|
+
* @returns The polling interval to use (in milliseconds)
|
|
32
|
+
*/
|
|
33
|
+
export function getPollingInterval(elapsedMs) {
|
|
34
|
+
const stage = POLLING_STAGES.find(([threshold]) => elapsedMs < threshold);
|
|
35
|
+
return stage ? stage[1] : DEFAULT_MAX_POLLING_INTERVAL_MS;
|
|
36
|
+
}
|
|
27
37
|
const processResponse = async (response, successStatus, pendingStatus, isPending, resultExtractor, errorCount) => {
|
|
28
38
|
// Handle other error responses
|
|
29
39
|
if (!response.ok) {
|
|
@@ -93,33 +103,25 @@ export async function pollUntilComplete(options) {
|
|
|
93
103
|
const startTime = Date.now();
|
|
94
104
|
let attempts = 0;
|
|
95
105
|
let errorCount = 0;
|
|
96
|
-
// Build polling stages with the actual timeout appended
|
|
97
|
-
const pollingStages = [
|
|
98
|
-
...DEFAULT_POLLING_STAGES,
|
|
99
|
-
[timeoutMs + MAX_TIMEOUT_BUFFER_MS, DEFAULT_MAX_POLLING_INTERVAL_MS], // Up to timeout + 10s: poll every 10s
|
|
100
|
-
];
|
|
101
106
|
// Apply initial delay if specified
|
|
102
107
|
if (initialDelay > 0) {
|
|
103
108
|
await setTimeout(initialDelay);
|
|
104
109
|
}
|
|
105
110
|
while (true) {
|
|
106
|
-
attempts++;
|
|
107
111
|
const elapsedTime = Date.now() - startTime;
|
|
108
|
-
//
|
|
109
|
-
|
|
110
|
-
return elapsedTime < maxTimeForStage;
|
|
111
|
-
});
|
|
112
|
-
// If there isn't a current stage, throw timeout error
|
|
113
|
-
if (!pollingInterval) {
|
|
112
|
+
// Check if we've exceeded the timeout
|
|
113
|
+
if (elapsedTime >= timeoutMs) {
|
|
114
114
|
throw new ZapierTimeoutError(`Operation timed out after ${Math.floor(elapsedTime / 1000)}s (${attempts} attempts)`, {
|
|
115
115
|
attempts,
|
|
116
116
|
});
|
|
117
117
|
}
|
|
118
118
|
// Wait before polling (except on first attempt)
|
|
119
|
-
if (attempts >
|
|
120
|
-
const
|
|
119
|
+
if (attempts > 0) {
|
|
120
|
+
const interval = getPollingInterval(elapsedTime);
|
|
121
|
+
const waitTime = calculateWaitTime(interval, errorCount);
|
|
121
122
|
await setTimeout(waitTime);
|
|
122
123
|
}
|
|
124
|
+
attempts++;
|
|
123
125
|
// Perform the poll request
|
|
124
126
|
try {
|
|
125
127
|
const response = await fetchPoll();
|
package/dist/api/polling.test.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { describe, it, expect, vi, beforeEach, afterEach } from "vitest";
|
|
2
|
-
import { pollUntilComplete } from "./polling";
|
|
2
|
+
import { pollUntilComplete, getPollingInterval } from "./polling";
|
|
3
3
|
import { ZapierTimeoutError, ZapierApiError, ZapierValidationError, } from "../types/errors";
|
|
4
4
|
// Mock the timers/promises module
|
|
5
5
|
vi.mock("timers/promises", () => ({
|
|
@@ -316,3 +316,45 @@ describe("pollUntilComplete", () => {
|
|
|
316
316
|
});
|
|
317
317
|
});
|
|
318
318
|
});
|
|
319
|
+
describe("getPollingInterval", () => {
|
|
320
|
+
it("should return 125ms for elapsed time under 125ms", () => {
|
|
321
|
+
expect(getPollingInterval(0)).toBe(125);
|
|
322
|
+
expect(getPollingInterval(50)).toBe(125);
|
|
323
|
+
expect(getPollingInterval(124)).toBe(125);
|
|
324
|
+
});
|
|
325
|
+
it("should return 250ms for elapsed time 125-375ms", () => {
|
|
326
|
+
expect(getPollingInterval(125)).toBe(250);
|
|
327
|
+
expect(getPollingInterval(200)).toBe(250);
|
|
328
|
+
expect(getPollingInterval(374)).toBe(250);
|
|
329
|
+
});
|
|
330
|
+
it("should return 500ms for elapsed time 375-875ms", () => {
|
|
331
|
+
expect(getPollingInterval(375)).toBe(500);
|
|
332
|
+
expect(getPollingInterval(600)).toBe(500);
|
|
333
|
+
expect(getPollingInterval(874)).toBe(500);
|
|
334
|
+
});
|
|
335
|
+
it("should return 1000ms for elapsed time 875ms-10s", () => {
|
|
336
|
+
expect(getPollingInterval(875)).toBe(1000);
|
|
337
|
+
expect(getPollingInterval(5000)).toBe(1000);
|
|
338
|
+
expect(getPollingInterval(9999)).toBe(1000);
|
|
339
|
+
});
|
|
340
|
+
it("should return 2500ms for elapsed time 10s-30s", () => {
|
|
341
|
+
expect(getPollingInterval(10000)).toBe(2500);
|
|
342
|
+
expect(getPollingInterval(20000)).toBe(2500);
|
|
343
|
+
expect(getPollingInterval(29999)).toBe(2500);
|
|
344
|
+
});
|
|
345
|
+
it("should return 5000ms for elapsed time 30s-60s", () => {
|
|
346
|
+
expect(getPollingInterval(30000)).toBe(5000);
|
|
347
|
+
expect(getPollingInterval(45000)).toBe(5000);
|
|
348
|
+
expect(getPollingInterval(59999)).toBe(5000);
|
|
349
|
+
});
|
|
350
|
+
it("should return 10000ms for elapsed time 60s-180s", () => {
|
|
351
|
+
expect(getPollingInterval(60000)).toBe(10000);
|
|
352
|
+
expect(getPollingInterval(120000)).toBe(10000);
|
|
353
|
+
expect(getPollingInterval(179999)).toBe(10000);
|
|
354
|
+
});
|
|
355
|
+
it("should return 60000ms (max interval) for elapsed time beyond 180s", () => {
|
|
356
|
+
expect(getPollingInterval(180000)).toBe(60000);
|
|
357
|
+
expect(getPollingInterval(300000)).toBe(60000);
|
|
358
|
+
expect(getPollingInterval(600000)).toBe(60000);
|
|
359
|
+
});
|
|
360
|
+
});
|
package/dist/constants.d.ts
CHANGED
|
@@ -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 timeout for action execution (in milliseconds)
|
|
16
|
+
*/
|
|
17
|
+
export declare const DEFAULT_ACTION_TIMEOUT_MS = 180000;
|
|
14
18
|
/**
|
|
15
19
|
* Credentials from environment variables
|
|
16
20
|
*/
|
package/dist/constants.d.ts.map
CHANGED
|
@@ -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,kBAAkB,oBAAiC,CAAC;AACjE,eAAO,MAAM,4BAA4B,oBACC,CAAC;AAC3C,eAAO,MAAM,gCAAgC,oBACC,CAAC;AAC/C,eAAO,MAAM,2BAA2B,oBACC,CAAC;AAC1C,eAAO,MAAM,wBAAwB,oBAAuC,CAAC;AAE7E;;GAEG;AACH,eAAO,MAAM,YAAY,oBAA2B,CAAC;AACrD,eAAO,MAAM,oBAAoB,oBAAmC,CAAC;AACrE,eAAO,MAAM,qBAAqB,oBAAoC,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,yBAAyB,SAAU,CAAC;AAEjD;;GAEG;AACH,eAAO,MAAM,kBAAkB,oBAAiC,CAAC;AACjE,eAAO,MAAM,4BAA4B,oBACC,CAAC;AAC3C,eAAO,MAAM,gCAAgC,oBACC,CAAC;AAC/C,eAAO,MAAM,2BAA2B,oBACC,CAAC;AAC1C,eAAO,MAAM,wBAAwB,oBAAuC,CAAC;AAE7E;;GAEG;AACH,eAAO,MAAM,YAAY,oBAA2B,CAAC;AACrD,eAAO,MAAM,oBAAoB,oBAAmC,CAAC;AACrE,eAAO,MAAM,qBAAqB,oBAAoC,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 timeout for action execution (in milliseconds)
|
|
16
|
+
*/
|
|
17
|
+
export const DEFAULT_ACTION_TIMEOUT_MS = 180000;
|
|
14
18
|
/**
|
|
15
19
|
* Credentials from environment variables
|
|
16
20
|
*/
|