@zapier/zapier-sdk 0.60.0 → 0.62.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 (66) hide show
  1. package/CHANGELOG.md +24 -0
  2. package/README.md +229 -1
  3. package/dist/experimental.cjs +384 -10
  4. package/dist/experimental.d.mts +182 -2
  5. package/dist/experimental.d.ts +180 -0
  6. package/dist/experimental.d.ts.map +1 -1
  7. package/dist/experimental.js +14 -0
  8. package/dist/experimental.mjs +384 -11
  9. package/dist/{index-iKbnOz6r.d.mts → index-3fBEDEsp.d.mts} +25 -1
  10. package/dist/{index-iKbnOz6r.d.ts → index-3fBEDEsp.d.ts} +25 -1
  11. package/dist/index.cjs +19 -9
  12. package/dist/index.d.mts +1 -1
  13. package/dist/index.mjs +19 -10
  14. package/dist/plugins/codeSubstrate/createWorkflow/index.d.ts +45 -0
  15. package/dist/plugins/codeSubstrate/createWorkflow/index.d.ts.map +1 -0
  16. package/dist/plugins/codeSubstrate/createWorkflow/index.js +19 -0
  17. package/dist/plugins/codeSubstrate/createWorkflow/schemas.d.ts +16 -0
  18. package/dist/plugins/codeSubstrate/createWorkflow/schemas.d.ts.map +1 -0
  19. package/dist/plugins/codeSubstrate/createWorkflow/schemas.js +25 -0
  20. package/dist/plugins/codeSubstrate/deleteWorkflow/index.d.ts +39 -0
  21. package/dist/plugins/codeSubstrate/deleteWorkflow/index.d.ts.map +1 -0
  22. package/dist/plugins/codeSubstrate/deleteWorkflow/index.js +27 -0
  23. package/dist/plugins/codeSubstrate/deleteWorkflow/schemas.d.ts +6 -0
  24. package/dist/plugins/codeSubstrate/deleteWorkflow/schemas.d.ts.map +1 -0
  25. package/dist/plugins/codeSubstrate/deleteWorkflow/schemas.js +6 -0
  26. package/dist/plugins/codeSubstrate/disableWorkflow/index.d.ts +40 -0
  27. package/dist/plugins/codeSubstrate/disableWorkflow/index.d.ts.map +1 -0
  28. package/dist/plugins/codeSubstrate/disableWorkflow/index.js +20 -0
  29. package/dist/plugins/codeSubstrate/disableWorkflow/schemas.d.ts +11 -0
  30. package/dist/plugins/codeSubstrate/disableWorkflow/schemas.d.ts.map +1 -0
  31. package/dist/plugins/codeSubstrate/disableWorkflow/schemas.js +12 -0
  32. package/dist/plugins/codeSubstrate/enableWorkflow/index.d.ts +40 -0
  33. package/dist/plugins/codeSubstrate/enableWorkflow/index.d.ts.map +1 -0
  34. package/dist/plugins/codeSubstrate/enableWorkflow/index.js +20 -0
  35. package/dist/plugins/codeSubstrate/enableWorkflow/schemas.d.ts +11 -0
  36. package/dist/plugins/codeSubstrate/enableWorkflow/schemas.d.ts.map +1 -0
  37. package/dist/plugins/codeSubstrate/enableWorkflow/schemas.js +12 -0
  38. package/dist/plugins/codeSubstrate/getDurableRun/index.d.ts +89 -0
  39. package/dist/plugins/codeSubstrate/getDurableRun/index.d.ts.map +1 -0
  40. package/dist/plugins/codeSubstrate/getDurableRun/index.js +20 -0
  41. package/dist/plugins/codeSubstrate/getDurableRun/schemas.d.ts +178 -0
  42. package/dist/plugins/codeSubstrate/getDurableRun/schemas.d.ts.map +1 -0
  43. package/dist/plugins/codeSubstrate/getDurableRun/schemas.js +130 -0
  44. package/dist/plugins/codeSubstrate/listDurableRuns/index.d.ts +55 -0
  45. package/dist/plugins/codeSubstrate/listDurableRuns/index.d.ts.map +1 -0
  46. package/dist/plugins/codeSubstrate/listDurableRuns/index.js +27 -0
  47. package/dist/plugins/codeSubstrate/listDurableRuns/schemas.d.ts +73 -0
  48. package/dist/plugins/codeSubstrate/listDurableRuns/schemas.d.ts.map +1 -0
  49. package/dist/plugins/codeSubstrate/listDurableRuns/schemas.js +59 -0
  50. package/dist/plugins/codeSubstrate/updateWorkflow/index.d.ts +47 -0
  51. package/dist/plugins/codeSubstrate/updateWorkflow/index.d.ts.map +1 -0
  52. package/dist/plugins/codeSubstrate/updateWorkflow/index.js +27 -0
  53. package/dist/plugins/codeSubstrate/updateWorkflow/schemas.d.ts +18 -0
  54. package/dist/plugins/codeSubstrate/updateWorkflow/schemas.d.ts.map +1 -0
  55. package/dist/plugins/codeSubstrate/updateWorkflow/schemas.js +30 -0
  56. package/dist/plugins/deleteClientCredentials/index.d.ts.map +1 -1
  57. package/dist/plugins/deleteClientCredentials/index.js +1 -4
  58. package/dist/resolvers/clientId.d.ts.map +1 -1
  59. package/dist/resolvers/clientId.js +2 -4
  60. package/dist/resolvers/durableRunId.d.ts +4 -0
  61. package/dist/resolvers/durableRunId.d.ts.map +1 -0
  62. package/dist/resolvers/durableRunId.js +14 -0
  63. package/dist/resolvers/index.d.ts +1 -0
  64. package/dist/resolvers/index.d.ts.map +1 -1
  65. package/dist/resolvers/index.js +1 -0
  66. package/package.json +1 -1
package/CHANGELOG.md CHANGED
@@ -1,5 +1,29 @@
1
1
  # @zapier/zapier-sdk
2
2
 
3
+ ## 0.62.0
4
+
5
+ ### Minor Changes
6
+
7
+ - eb9b408: Add the durable-run-read experimental code-substrate plugins: `listDurableRuns` and `getDurableRun`. Both are registered only in `@zapier/zapier-sdk/experimental`; the stable subpath does not expose them. `listDurableRuns` is paginated (cursor + pageSize) per the sdkdurableapi `/api/v0/runs` contract; `getDurableRun` returns the full run state with nested execution and operations journal. Handlers pass API responses through verbatim (no client-side `.parse()` re-emission) so callers see any richer fields the server adds later without an SDK release. Also adds `durableRunIdResolver` in `src/resolvers/durableRunId.ts` so commands that take a run id present an interactive picker via `sdk.listDurableRuns()` in the CLI (uses `toIterable` to pull across pages). Input field naming follows the in-tree convention (`run` rather than the fork's `runId`); input is validated as a UUID at the boundary so non-UUID strings fail with a clear schema error instead of an opaque 500 from the backend's `::uuid` cast.
8
+
9
+ ## 0.61.0
10
+
11
+ ### Minor Changes
12
+
13
+ - 4827ffe: Add the workflow-write experimental code-substrate plugins: `createWorkflow`, `updateWorkflow`, `enableWorkflow`, `disableWorkflow`, `deleteWorkflow`. All five are registered only in `@zapier/zapier-sdk/experimental`; the stable subpath does not expose them. The four ID-based ops (update, enable, disable, delete) reuse `workflowIdResolver` so callers get an interactive picker via `sdk.listWorkflows()`. `deleteWorkflow` is marked `confirm: "delete"` for an explicit confirmation prompt before the destructive call. Input field naming follows the in-tree convention (`workflow` rather than the fork's `workflowId`, matching `tableIdResolver`'s shape) and is validated as a UUID at the input boundary so non-UUID strings fail with a clear schema error instead of an opaque 500 from the backend's `::uuid` cast. Response shapes match what the durableworkflowzaps handlers actually emit — no fabricated `is_private` / `created_by_user_id` / `triggers` fields. Handlers pass API responses through verbatim (no client-side `.parse()` re-emission) so callers see any richer fields the server adds later without an SDK release.
14
+
15
+ ### Patch Changes
16
+
17
+ - 104daa3: Fix login/logout reliability bugs.
18
+
19
+ **Bug fixes:**
20
+ - `logout` now warns and still clears local keychain/registry state when the server returns 401 during revocation (404 is still silently swallowed; 401 is surfaced as a console warning so users know to verify or revoke the credential manually if needed)
21
+ - Re-login no longer fails with "already exists" when a locally-orphaned registry entry has the same name as the desired new credential
22
+ - `logout` no longer prompts for confirmation before deleting credentials; it always proceeds immediately, which also fixes hangs in non-TTY/CI environments
23
+
24
+ **Deprecations:**
25
+ - `--skip-prompts` on `login` and `init` is deprecated in favour of `--non-interactive`. The old flag continues to work with a deprecation warning.
26
+
3
27
  ## 0.60.0
4
28
 
5
29
  ### Minor Changes
package/README.md CHANGED
@@ -27,8 +27,15 @@
27
27
  - [`deleteClientCredentials`](#deleteclientcredentials)
28
28
  - [`listClientCredentials`](#listclientcredentials)
29
29
  - [Code Workflows (Experimental)](#code-workflows-experimental)
30
+ - [`createWorkflow`](#createworkflow--experimental)
31
+ - [`deleteWorkflow`](#deleteworkflow--experimental)
32
+ - [`disableWorkflow`](#disableworkflow--experimental)
33
+ - [`enableWorkflow`](#enableworkflow--experimental)
34
+ - [`getDurableRun`](#getdurablerun--experimental)
30
35
  - [`getWorkflow`](#getworkflow--experimental)
36
+ - [`listDurableRuns`](#listdurableruns--experimental)
31
37
  - [`listWorkflows`](#listworkflows--experimental)
38
+ - [`updateWorkflow`](#updateworkflow--experimental)
32
39
  - [Connections](#connections)
33
40
  - [`findFirstConnection`](#findfirstconnection)
34
41
  - [`findUniqueConnection`](#finduniqueconnection)
@@ -88,7 +95,7 @@ The following will create a new project from scratch, set up the SDK and the SDK
88
95
  npx @zapier/zapier-sdk-cli init my-zapier-app
89
96
 
90
97
  # Or skip the interactive prompts and accept all defaults.
91
- npx @zapier/zapier-sdk-cli init my-zapier-app --skip-prompts
98
+ npx @zapier/zapier-sdk-cli init my-zapier-app --non-interactive
92
99
  ```
93
100
 
94
101
  ## Installation
@@ -1087,6 +1094,147 @@ for await (const clientCredentials of zapier.listClientCredentials().items()) {
1087
1094
 
1088
1095
  > ℹ️ **Experimental.** Import from `"@zapier/zapier-sdk/experimental"` to use these methods. Methods and behavior may change.
1089
1096
 
1097
+ #### `createWorkflow` 🧪 _experimental_
1098
+
1099
+ Create a durable workflow container. Starts disabled with no version; publish a version to add code.
1100
+
1101
+ **Parameters:**
1102
+
1103
+ | Name | Type | Required | Default | Possible Values | Description |
1104
+ | ----------------- | -------- | -------- | ------- | --------------- | ------------------------------------- |
1105
+ | `options` | `object` | ✅ | — | — | |
1106
+ | ​ ↳ `name` | `string` | ✅ | — | — | Workflow name |
1107
+ | ​ ↳ `description` | `string` | ❌ | — | — | Optional description for the workflow |
1108
+
1109
+ **Returns:** `Promise<WorkflowItem>`
1110
+
1111
+ | Name | Type | Required | Possible Values | Description |
1112
+ | ----------------- | --------- | -------- | --------------- | --------------------------------------------------------------------------------------------------------------------------- |
1113
+ | `data` | `object` | ✅ | — | |
1114
+ | ​ ↳ `id` | `string` | ✅ | — | Workflow ID (UUID) |
1115
+ | ​ ↳ `name` | `string` | ✅ | — | Workflow name |
1116
+ | ​ ↳ `description` | `string` | ✅ | — | Workflow description (null if unset) |
1117
+ | ​ ↳ `trigger_url` | `string` | ✅ | — | Public webhook URL that fires this workflow when POSTed to. Embeds a secret trigger token in the path — treat as sensitive. |
1118
+ | ​ ↳ `enabled` | `boolean` | ✅ | — | Whether the workflow currently accepts triggers. Always false on a new workflow until enabled. |
1119
+ | ​ ↳ `created_at` | `string` | ✅ | — | When the workflow was created (ISO-8601) |
1120
+
1121
+ **Example:**
1122
+
1123
+ ```typescript
1124
+ const result = await zapier.createWorkflow({
1125
+ name: "example-name",
1126
+ });
1127
+ ```
1128
+
1129
+ #### `deleteWorkflow` 🧪 _experimental_
1130
+
1131
+ Delete a durable workflow. Throws `ZapierNotFoundError` if the workflow doesn't exist; callers wanting idempotency should catch that themselves.
1132
+
1133
+ **Parameters:**
1134
+
1135
+ | Name | Type | Required | Default | Possible Values | Description |
1136
+ | -------------- | -------- | -------- | ------- | --------------- | ------------------- |
1137
+ | `options` | `object` | ✅ | — | — | |
1138
+ | ​ ↳ `workflow` | `string` | ✅ | — | — | Durable workflow ID |
1139
+
1140
+ **Returns:** `Promise<{ success: boolean }>`
1141
+
1142
+ **Example:**
1143
+
1144
+ ```typescript
1145
+ const result = await zapier.deleteWorkflow({
1146
+ workflow: "example-workflow",
1147
+ });
1148
+ ```
1149
+
1150
+ #### `disableWorkflow` 🧪 _experimental_
1151
+
1152
+ Disable a durable workflow so it stops accepting triggers
1153
+
1154
+ **Parameters:**
1155
+
1156
+ | Name | Type | Required | Default | Possible Values | Description |
1157
+ | -------------- | -------- | -------- | ------- | --------------- | ------------------- |
1158
+ | `options` | `object` | ✅ | — | — | |
1159
+ | ​ ↳ `workflow` | `string` | ✅ | — | — | Durable workflow ID |
1160
+
1161
+ **Returns:** `Promise<WorkflowItem>`
1162
+
1163
+ | Name | Type | Required | Possible Values | Description |
1164
+ | ------------- | --------- | -------- | --------------- | --------------------------------------------------------------------------------------------------------------------------------------------- |
1165
+ | `data` | `object` | ✅ | — | |
1166
+ | ​ ↳ `id` | `string` | ✅ | — | Workflow ID (UUID) |
1167
+ | ​ ↳ `enabled` | `boolean` | ✅ | — | Workflow's enabled state after the operation. Typically false; mirrors the row's true state in case a concurrent enable raced with this call. |
1168
+
1169
+ **Example:**
1170
+
1171
+ ```typescript
1172
+ const result = await zapier.disableWorkflow({
1173
+ workflow: "example-workflow",
1174
+ });
1175
+ ```
1176
+
1177
+ #### `enableWorkflow` 🧪 _experimental_
1178
+
1179
+ Enable a durable workflow so it accepts triggers
1180
+
1181
+ **Parameters:**
1182
+
1183
+ | Name | Type | Required | Default | Possible Values | Description |
1184
+ | -------------- | -------- | -------- | ------- | --------------- | ------------------- |
1185
+ | `options` | `object` | ✅ | — | — | |
1186
+ | ​ ↳ `workflow` | `string` | ✅ | — | — | Durable workflow ID |
1187
+
1188
+ **Returns:** `Promise<WorkflowItem>`
1189
+
1190
+ | Name | Type | Required | Possible Values | Description |
1191
+ | ------------- | --------- | -------- | --------------- | ---------------------------------------------------------- |
1192
+ | `data` | `object` | ✅ | — | |
1193
+ | ​ ↳ `id` | `string` | ✅ | — | Workflow ID (UUID) |
1194
+ | ​ ↳ `enabled` | `boolean` | ✅ | — | Workflow's enabled state after the operation (always true) |
1195
+
1196
+ **Example:**
1197
+
1198
+ ```typescript
1199
+ const result = await zapier.enableWorkflow({
1200
+ workflow: "example-workflow",
1201
+ });
1202
+ ```
1203
+
1204
+ #### `getDurableRun` 🧪 _experimental_
1205
+
1206
+ Get the full state of a run-once durable run, including its operations journal
1207
+
1208
+ **Parameters:**
1209
+
1210
+ | Name | Type | Required | Default | Possible Values | Description |
1211
+ | --------- | -------- | -------- | ------- | --------------- | -------------- |
1212
+ | `options` | `object` | ✅ | — | — | |
1213
+ | ​ ↳ `run` | `string` | ✅ | — | — | Durable run ID |
1214
+
1215
+ **Returns:** `Promise<DurableRunItem>`
1216
+
1217
+ | Name | Type | Required | Possible Values | Description |
1218
+ | ---------------- | --------- | -------- | ----------------------------------------------------------- | ------------------------------------------------------------------------------------------------------- |
1219
+ | `data` | `object` | ✅ | — | |
1220
+ | ​ ↳ `id` | `string` | ✅ | — | Run ID (UUID) |
1221
+ | ​ ↳ `status` | `string` | ✅ | `initialized`, `started`, `finished`, `failed`, `cancelled` | Run lifecycle status. `finished` / `failed` / `cancelled` are terminal. |
1222
+ | ​ ↳ `input` | `string` | ✅ | — | Input data passed to the run |
1223
+ | ​ ↳ `output` | `string` | ✅ | — | Return value, present when status is `finished` |
1224
+ | ​ ↳ `error` | `object` | ✅ | — | Structured error details when the run failed (null otherwise) |
1225
+ | ​ ↳ `execution` | `object` | ✅ | — | Linked execution, including the operations journal. Null while the run is still in `initialized` state. |
1226
+ | ​ ↳ `is_private` | `boolean` | ✅ | — | When true, the run is visible only to the creating user; otherwise visible across the account. |
1227
+ | ​ ↳ `created_at` | `string` | ✅ | — | When the run was created (ISO-8601) |
1228
+ | ​ ↳ `updated_at` | `string` | ✅ | — | When the run was last updated (ISO-8601) |
1229
+
1230
+ **Example:**
1231
+
1232
+ ```typescript
1233
+ const { data: durableRun } = await zapier.getDurableRun({
1234
+ run: "example-run",
1235
+ });
1236
+ ```
1237
+
1090
1238
  #### `getWorkflow` 🧪 _experimental_
1091
1239
 
1092
1240
  Get a durable workflow with its current version details and trigger claim status
@@ -1127,6 +1275,52 @@ const { data: workflow } = await zapier.getWorkflow({
1127
1275
  });
1128
1276
  ```
1129
1277
 
1278
+ #### `listDurableRuns` 🧪 _experimental_
1279
+
1280
+ List run-once durable runs for the authenticated account, newest first
1281
+
1282
+ **Parameters:**
1283
+
1284
+ | Name | Type | Required | Default | Possible Values | Description |
1285
+ | -------------- | -------- | -------- | ------- | --------------- | ---------------------------------------------- |
1286
+ | `options` | `object` | ✅ | — | — | |
1287
+ | ​ ↳ `pageSize` | `number` | ❌ | — | — | Number of runs per page (max 100) |
1288
+ | ​ ↳ `cursor` | `string` | ❌ | — | — | Pagination cursor |
1289
+ | ​ ↳ `maxItems` | `number` | ❌ | — | — | Maximum total items to return across all pages |
1290
+
1291
+ **Returns:** `Promise<PaginatedResult<DurableRunItem>>`
1292
+
1293
+ | Name | Type | Required | Possible Values | Description |
1294
+ | ------------------ | ---------- | -------- | ----------------------------------------------------------- | ---------------------------------------------------------------------------------------------- |
1295
+ | `data[]` | `object[]` | ✅ | — | |
1296
+ | ​ ↳ `id` | `string` | ✅ | — | Run ID (UUID) |
1297
+ | ​ ↳ `status` | `string` | ✅ | `initialized`, `started`, `finished`, `failed`, `cancelled` | Run lifecycle status. `finished` / `failed` / `cancelled` are terminal. |
1298
+ | ​ ↳ `input` | `string` | ✅ | — | Input data passed to the run |
1299
+ | ​ ↳ `output` | `string` | ✅ | — | Return value, present when status is `finished` |
1300
+ | ​ ↳ `error` | `object` | ✅ | — | Structured error details when the run failed (null otherwise) |
1301
+ | ​ ↳ `execution_id` | `string` | ✅ | — | Linked execution ID. Null until the run leaves the `initialized` state. |
1302
+ | ​ ↳ `is_private` | `boolean` | ✅ | — | When true, the run is visible only to the creating user; otherwise visible across the account. |
1303
+ | ​ ↳ `created_at` | `string` | ✅ | — | When the run was created (ISO-8601) |
1304
+ | ​ ↳ `updated_at` | `string` | ✅ | — | When the run was last updated (ISO-8601) |
1305
+ | `nextCursor` | `string` | ❌ | — | Cursor for the next page; omitted when there are no more pages |
1306
+
1307
+ **Example:**
1308
+
1309
+ ```typescript
1310
+ // Get first page and a cursor for the second page
1311
+ const { data: durableRuns, nextCursor } = await zapier.listDurableRuns();
1312
+
1313
+ // Or iterate over all pages
1314
+ for await (const page of zapier.listDurableRuns()) {
1315
+ // Do something with each page
1316
+ }
1317
+
1318
+ // Or iterate over individual items across all pages
1319
+ for await (const durableRun of zapier.listDurableRuns().items()) {
1320
+ // Do something with each durableRun
1321
+ }
1322
+ ```
1323
+
1130
1324
  #### `listWorkflows` 🧪 _experimental_
1131
1325
 
1132
1326
  List all active durable workflows for the authenticated account
@@ -1172,6 +1366,40 @@ for await (const workflow of zapier.listWorkflows().items()) {
1172
1366
  }
1173
1367
  ```
1174
1368
 
1369
+ #### `updateWorkflow` 🧪 _experimental_
1370
+
1371
+ Update a durable workflow's name and/or description
1372
+
1373
+ **Parameters:**
1374
+
1375
+ | Name | Type | Required | Default | Possible Values | Description |
1376
+ | ----------------- | -------- | -------- | ------- | --------------- | ----------------------------------------------------- |
1377
+ | `options` | `object` | ✅ | — | — | |
1378
+ | ​ ↳ `workflow` | `string` | ✅ | — | — | Durable workflow ID |
1379
+ | ​ ↳ `name` | `string` | ❌ | — | — | New name for the workflow |
1380
+ | ​ ↳ `description` | `string` | ❌ | — | — | New description for the workflow (pass null to clear) |
1381
+
1382
+ **Returns:** `Promise<WorkflowItem>`
1383
+
1384
+ | Name | Type | Required | Possible Values | Description |
1385
+ | ----------------- | --------- | -------- | --------------- | --------------------------------------------------------------------------------------------------------------------------- |
1386
+ | `data` | `object` | ✅ | — | |
1387
+ | ​ ↳ `id` | `string` | ✅ | — | Workflow ID (UUID) |
1388
+ | ​ ↳ `name` | `string` | ✅ | — | Workflow name (post-update) |
1389
+ | ​ ↳ `description` | `string` | ✅ | — | Workflow description, post-update (null if unset) |
1390
+ | ​ ↳ `trigger_url` | `string` | ✅ | — | Public webhook URL that fires this workflow when POSTed to. Embeds a secret trigger token in the path — treat as sensitive. |
1391
+ | ​ ↳ `enabled` | `boolean` | ✅ | — | Whether the workflow currently accepts triggers |
1392
+ | ​ ↳ `created_at` | `string` | ✅ | — | When the workflow was created (ISO-8601) |
1393
+ | ​ ↳ `updated_at` | `string` | ✅ | — | When this update was applied (ISO-8601) |
1394
+
1395
+ **Example:**
1396
+
1397
+ ```typescript
1398
+ const result = await zapier.updateWorkflow({
1399
+ workflow: "example-workflow",
1400
+ });
1401
+ ```
1402
+
1175
1403
  ### Connections
1176
1404
 
1177
1405
  #### `findFirstConnection`