@zapier/zapier-sdk 0.59.0 → 0.61.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 +24 -0
  2. package/README.md +239 -1
  3. package/dist/experimental.cjs +329 -10
  4. package/dist/experimental.d.mts +142 -2
  5. package/dist/experimental.d.ts +140 -0
  6. package/dist/experimental.d.ts.map +1 -1
  7. package/dist/experimental.js +15 -0
  8. package/dist/experimental.mjs +329 -11
  9. package/dist/{index-eliz1Uq3.d.mts → index-iKbnOz6r.d.mts} +15 -1
  10. package/dist/{index-eliz1Uq3.d.ts → index-iKbnOz6r.d.ts} +15 -1
  11. package/dist/index.cjs +23 -9
  12. package/dist/index.d.mts +1 -1
  13. package/dist/index.mjs +23 -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/getWorkflow/index.d.ts +54 -0
  39. package/dist/plugins/codeSubstrate/getWorkflow/index.d.ts.map +1 -0
  40. package/dist/plugins/codeSubstrate/getWorkflow/index.js +21 -0
  41. package/dist/plugins/codeSubstrate/getWorkflow/schemas.d.ts +35 -0
  42. package/dist/plugins/codeSubstrate/getWorkflow/schemas.d.ts.map +1 -0
  43. package/dist/plugins/codeSubstrate/getWorkflow/schemas.js +45 -0
  44. package/dist/plugins/codeSubstrate/listWorkflows/index.d.ts +50 -0
  45. package/dist/plugins/codeSubstrate/listWorkflows/index.d.ts.map +1 -0
  46. package/dist/plugins/codeSubstrate/listWorkflows/index.js +29 -0
  47. package/dist/plugins/codeSubstrate/listWorkflows/schemas.d.ts +40 -0
  48. package/dist/plugins/codeSubstrate/listWorkflows/schemas.d.ts.map +1 -0
  49. package/dist/plugins/codeSubstrate/listWorkflows/schemas.js +54 -0
  50. package/dist/plugins/codeSubstrate/shared.d.ts +16 -0
  51. package/dist/plugins/codeSubstrate/shared.d.ts.map +1 -0
  52. package/dist/plugins/codeSubstrate/shared.js +15 -0
  53. package/dist/plugins/codeSubstrate/updateWorkflow/index.d.ts +47 -0
  54. package/dist/plugins/codeSubstrate/updateWorkflow/index.d.ts.map +1 -0
  55. package/dist/plugins/codeSubstrate/updateWorkflow/index.js +27 -0
  56. package/dist/plugins/codeSubstrate/updateWorkflow/schemas.d.ts +18 -0
  57. package/dist/plugins/codeSubstrate/updateWorkflow/schemas.d.ts.map +1 -0
  58. package/dist/plugins/codeSubstrate/updateWorkflow/schemas.js +30 -0
  59. package/dist/plugins/deleteClientCredentials/index.d.ts.map +1 -1
  60. package/dist/plugins/deleteClientCredentials/index.js +1 -4
  61. package/dist/registry.d.ts.map +1 -1
  62. package/dist/registry.js +4 -0
  63. package/dist/resolvers/clientId.d.ts.map +1 -1
  64. package/dist/resolvers/clientId.js +2 -4
  65. package/dist/resolvers/index.d.ts +1 -0
  66. package/dist/resolvers/index.d.ts.map +1 -1
  67. package/dist/resolvers/index.js +1 -0
  68. package/dist/resolvers/workflowId.d.ts +4 -0
  69. package/dist/resolvers/workflowId.d.ts.map +1 -0
  70. package/dist/resolvers/workflowId.js +14 -0
  71. package/package.json +1 -1
package/CHANGELOG.md CHANGED
@@ -1,5 +1,29 @@
1
1
  # @zapier/zapier-sdk
2
2
 
3
+ ## 0.61.0
4
+
5
+ ### Minor Changes
6
+
7
+ - 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.
8
+
9
+ ### Patch Changes
10
+
11
+ - 104daa3: Fix login/logout reliability bugs.
12
+
13
+ **Bug fixes:**
14
+ - `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)
15
+ - Re-login no longer fails with "already exists" when a locally-orphaned registry entry has the same name as the desired new credential
16
+ - `logout` no longer prompts for confirmation before deleting credentials; it always proceeds immediately, which also fixes hangs in non-TTY/CI environments
17
+
18
+ **Deprecations:**
19
+ - `--skip-prompts` on `login` and `init` is deprecated in favour of `--non-interactive`. The old flag continues to work with a deprecation warning.
20
+
21
+ ## 0.60.0
22
+
23
+ ### Minor Changes
24
+
25
+ - f12598a: Add the workflow-read experimental plugins: `listWorkflows` and `getWorkflow`. Both are registered only in `@zapier/zapier-sdk/experimental`; the stable subpath does not expose them. `listWorkflows` uses `createPaginatedPluginMethod` (page-iterator + `pageSize`/`cursor`/`maxItems` options) so callers can iterate via `for await (const page of sdk.listWorkflows())` or `toIterable(sdk.listWorkflows())`. The backend does not paginate today; the SDK treats a missing `next_cursor` as the last page, so server-side pagination drops in without an SDK API change. Introduces `packages/zapier-sdk/src/plugins/codeSubstrate/shared.ts` with `codeSubstrateDefaults` (`{ categories: ["code-workflow"], experimental: true }`) that subsequent code-workflow plugins spread into their `createPluginMethod` configs. Also adds `workflowIdResolver` in `src/resolvers/workflowId.ts` (mirrors `tableIdResolver` / `triggerInboxResolver`) so commands that take a workflow id present an interactive picker via `sdk.listWorkflows()` in the CLI. Workflow-write commands (`createWorkflow`, `updateWorkflow`, `enable/disable/deleteWorkflow`) land in a follow-up MR.
26
+
3
27
  ## 0.59.0
4
28
 
5
29
  ### Minor Changes
package/README.md CHANGED
@@ -26,6 +26,14 @@
26
26
  - [`createClientCredentials`](#createclientcredentials)
27
27
  - [`deleteClientCredentials`](#deleteclientcredentials)
28
28
  - [`listClientCredentials`](#listclientcredentials)
29
+ - [Code Workflows (Experimental)](#code-workflows-experimental)
30
+ - [`createWorkflow`](#createworkflow--experimental)
31
+ - [`deleteWorkflow`](#deleteworkflow--experimental)
32
+ - [`disableWorkflow`](#disableworkflow--experimental)
33
+ - [`enableWorkflow`](#enableworkflow--experimental)
34
+ - [`getWorkflow`](#getworkflow--experimental)
35
+ - [`listWorkflows`](#listworkflows--experimental)
36
+ - [`updateWorkflow`](#updateworkflow--experimental)
29
37
  - [Connections](#connections)
30
38
  - [`findFirstConnection`](#findfirstconnection)
31
39
  - [`findUniqueConnection`](#finduniqueconnection)
@@ -85,7 +93,7 @@ The following will create a new project from scratch, set up the SDK and the SDK
85
93
  npx @zapier/zapier-sdk-cli init my-zapier-app
86
94
 
87
95
  # Or skip the interactive prompts and accept all defaults.
88
- npx @zapier/zapier-sdk-cli init my-zapier-app --skip-prompts
96
+ npx @zapier/zapier-sdk-cli init my-zapier-app --non-interactive
89
97
  ```
90
98
 
91
99
  ## Installation
@@ -1080,6 +1088,236 @@ for await (const clientCredentials of zapier.listClientCredentials().items()) {
1080
1088
  }
1081
1089
  ```
1082
1090
 
1091
+ ### Code Workflows (Experimental)
1092
+
1093
+ > ℹ️ **Experimental.** Import from `"@zapier/zapier-sdk/experimental"` to use these methods. Methods and behavior may change.
1094
+
1095
+ #### `createWorkflow` 🧪 _experimental_
1096
+
1097
+ Create a durable workflow container. Starts disabled with no version; publish a version to add code.
1098
+
1099
+ **Parameters:**
1100
+
1101
+ | Name | Type | Required | Default | Possible Values | Description |
1102
+ | ----------------- | -------- | -------- | ------- | --------------- | ------------------------------------- |
1103
+ | `options` | `object` | ✅ | — | — | |
1104
+ | ​ ↳ `name` | `string` | ✅ | — | — | Workflow name |
1105
+ | ​ ↳ `description` | `string` | ❌ | — | — | Optional description for the workflow |
1106
+
1107
+ **Returns:** `Promise<WorkflowItem>`
1108
+
1109
+ | Name | Type | Required | Possible Values | Description |
1110
+ | ----------------- | --------- | -------- | --------------- | --------------------------------------------------------------------------------------------------------------------------- |
1111
+ | `data` | `object` | ✅ | — | |
1112
+ | ​ ↳ `id` | `string` | ✅ | — | Workflow ID (UUID) |
1113
+ | ​ ↳ `name` | `string` | ✅ | — | Workflow name |
1114
+ | ​ ↳ `description` | `string` | ✅ | — | Workflow description (null if unset) |
1115
+ | ​ ↳ `trigger_url` | `string` | ✅ | — | Public webhook URL that fires this workflow when POSTed to. Embeds a secret trigger token in the path — treat as sensitive. |
1116
+ | ​ ↳ `enabled` | `boolean` | ✅ | — | Whether the workflow currently accepts triggers. Always false on a new workflow until enabled. |
1117
+ | ​ ↳ `created_at` | `string` | ✅ | — | When the workflow was created (ISO-8601) |
1118
+
1119
+ **Example:**
1120
+
1121
+ ```typescript
1122
+ const result = await zapier.createWorkflow({
1123
+ name: "example-name",
1124
+ });
1125
+ ```
1126
+
1127
+ #### `deleteWorkflow` 🧪 _experimental_
1128
+
1129
+ Delete a durable workflow. Throws `ZapierNotFoundError` if the workflow doesn't exist; callers wanting idempotency should catch that themselves.
1130
+
1131
+ **Parameters:**
1132
+
1133
+ | Name | Type | Required | Default | Possible Values | Description |
1134
+ | -------------- | -------- | -------- | ------- | --------------- | ------------------- |
1135
+ | `options` | `object` | ✅ | — | — | |
1136
+ | ​ ↳ `workflow` | `string` | ✅ | — | — | Durable workflow ID |
1137
+
1138
+ **Returns:** `Promise<{ success: boolean }>`
1139
+
1140
+ **Example:**
1141
+
1142
+ ```typescript
1143
+ const result = await zapier.deleteWorkflow({
1144
+ workflow: "example-workflow",
1145
+ });
1146
+ ```
1147
+
1148
+ #### `disableWorkflow` 🧪 _experimental_
1149
+
1150
+ Disable a durable workflow so it stops accepting triggers
1151
+
1152
+ **Parameters:**
1153
+
1154
+ | Name | Type | Required | Default | Possible Values | Description |
1155
+ | -------------- | -------- | -------- | ------- | --------------- | ------------------- |
1156
+ | `options` | `object` | ✅ | — | — | |
1157
+ | ​ ↳ `workflow` | `string` | ✅ | — | — | Durable workflow ID |
1158
+
1159
+ **Returns:** `Promise<WorkflowItem>`
1160
+
1161
+ | Name | Type | Required | Possible Values | Description |
1162
+ | ------------- | --------- | -------- | --------------- | --------------------------------------------------------------------------------------------------------------------------------------------- |
1163
+ | `data` | `object` | ✅ | — | |
1164
+ | ​ ↳ `id` | `string` | ✅ | — | Workflow ID (UUID) |
1165
+ | ​ ↳ `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. |
1166
+
1167
+ **Example:**
1168
+
1169
+ ```typescript
1170
+ const result = await zapier.disableWorkflow({
1171
+ workflow: "example-workflow",
1172
+ });
1173
+ ```
1174
+
1175
+ #### `enableWorkflow` 🧪 _experimental_
1176
+
1177
+ Enable a durable workflow so it accepts triggers
1178
+
1179
+ **Parameters:**
1180
+
1181
+ | Name | Type | Required | Default | Possible Values | Description |
1182
+ | -------------- | -------- | -------- | ------- | --------------- | ------------------- |
1183
+ | `options` | `object` | ✅ | — | — | |
1184
+ | ​ ↳ `workflow` | `string` | ✅ | — | — | Durable workflow ID |
1185
+
1186
+ **Returns:** `Promise<WorkflowItem>`
1187
+
1188
+ | Name | Type | Required | Possible Values | Description |
1189
+ | ------------- | --------- | -------- | --------------- | ---------------------------------------------------------- |
1190
+ | `data` | `object` | ✅ | — | |
1191
+ | ​ ↳ `id` | `string` | ✅ | — | Workflow ID (UUID) |
1192
+ | ​ ↳ `enabled` | `boolean` | ✅ | — | Workflow's enabled state after the operation (always true) |
1193
+
1194
+ **Example:**
1195
+
1196
+ ```typescript
1197
+ const result = await zapier.enableWorkflow({
1198
+ workflow: "example-workflow",
1199
+ });
1200
+ ```
1201
+
1202
+ #### `getWorkflow` 🧪 _experimental_
1203
+
1204
+ Get a durable workflow with its current version details and trigger claim status
1205
+
1206
+ **Parameters:**
1207
+
1208
+ | Name | Type | Required | Default | Possible Values | Description |
1209
+ | -------------- | -------- | -------- | ------- | --------------- | ------------------- |
1210
+ | `options` | `object` | ✅ | — | — | |
1211
+ | ​ ↳ `workflow` | `string` | ✅ | — | — | Durable workflow ID |
1212
+
1213
+ **Returns:** `Promise<WorkflowItem>`
1214
+
1215
+ | Name | Type | Required | Possible Values | Description |
1216
+ | ------------------------------ | --------- | -------- | --------------- | --------------------------------------------------------------------------------------------------------------------------- |
1217
+ | `data` | `object` | ✅ | — | |
1218
+ | ​ ↳ `id` | `string` | ✅ | — | Workflow ID (UUID) |
1219
+ | ​ ↳ `name` | `string` | ✅ | — | Workflow name |
1220
+ | ​ ↳ `description` | `string` | ✅ | — | Optional workflow description (null if unset) |
1221
+ | ​ ↳ `trigger_url` | `string` | ✅ | — | Public webhook URL that fires this workflow when POSTed to. Embeds a secret trigger token in the path — treat as sensitive. |
1222
+ | ​ ↳ `enabled` | `boolean` | ✅ | — | Whether the workflow currently accepts triggers |
1223
+ | ​ ↳ `current_version` | `object` | ❌ | — | The currently published version, if any. Absent for workflows with no version published yet. |
1224
+ | ​   ↳ `id` | `string` | ✅ | — | Workflow version ID (UUID) |
1225
+ | ​   ↳ `workflow_id` | `string` | ✅ | — | Parent workflow ID |
1226
+ | ​   ↳ `source_files` | `object` | ✅ | — | Source files keyed by filename → contents |
1227
+ | ​   ↳ `zapier_durable_version` | `string` | ✅ | — | Pinned semver of @zapier/zapier-durable used by this version's runs |
1228
+ | ​   ↳ `dependencies` | `object` | ✅ | — | Additional npm dependencies pinned for this version (or null) |
1229
+ | ​   ↳ `created_by_user_id` | `string` | ✅ | — | ID of the user who published this version |
1230
+ | ​   ↳ `created_at` | `string` | ✅ | — | When the version was published (ISO-8601) |
1231
+ | ​ ↳ `created_at` | `string` | ✅ | — | When the workflow was created (ISO-8601) |
1232
+ | ​ ↳ `updated_at` | `string` | ✅ | — | When the workflow was last modified (ISO-8601) |
1233
+
1234
+ **Example:**
1235
+
1236
+ ```typescript
1237
+ const { data: workflow } = await zapier.getWorkflow({
1238
+ workflow: "example-workflow",
1239
+ });
1240
+ ```
1241
+
1242
+ #### `listWorkflows` 🧪 _experimental_
1243
+
1244
+ List all active durable workflows for the authenticated account
1245
+
1246
+ **Parameters:**
1247
+
1248
+ | Name | Type | Required | Default | Possible Values | Description |
1249
+ | -------------- | -------- | -------- | ------- | --------------- | -------------------------------------------------------------------------------------------- |
1250
+ | `options` | `object` | ✅ | — | — | |
1251
+ | ​ ↳ `pageSize` | `number` | ❌ | — | — | Number of workflows per page (server-side pagination forthcoming; ignored until then) |
1252
+ | ​ ↳ `maxItems` | `number` | ❌ | — | — | Maximum total workflows to return across all pages |
1253
+ | ​ ↳ `cursor` | `string` | ❌ | — | — | Cursor to start from for pagination (server-side pagination forthcoming; ignored until then) |
1254
+
1255
+ **Returns:** `Promise<PaginatedResult<WorkflowItem>>`
1256
+
1257
+ | Name | Type | Required | Possible Values | Description |
1258
+ | ------------------------ | ---------- | -------- | --------------- | --------------------------------------------------------------------------------------------------------------------------- |
1259
+ | `data[]` | `object[]` | ✅ | — | |
1260
+ | ​ ↳ `id` | `string` | ✅ | — | Workflow ID (UUID) |
1261
+ | ​ ↳ `name` | `string` | ✅ | — | Workflow name |
1262
+ | ​ ↳ `description` | `string` | ✅ | — | Optional workflow description (null if unset) |
1263
+ | ​ ↳ `trigger_url` | `string` | ✅ | — | Public webhook URL that fires this workflow when POSTed to. Embeds a secret trigger token in the path — treat as sensitive. |
1264
+ | ​ ↳ `enabled` | `boolean` | ✅ | — | Whether the workflow currently accepts triggers |
1265
+ | ​ ↳ `current_version_id` | `string` | ✅ | — | ID of the workflow version that runs handle. Null until a version is published. |
1266
+ | ​ ↳ `created_at` | `string` | ✅ | — | When the workflow was created (ISO-8601) |
1267
+ | ​ ↳ `updated_at` | `string` | ✅ | — | When the workflow was last modified (ISO-8601) |
1268
+ | `nextCursor` | `string` | ❌ | — | Cursor for the next page; omitted when there are no more pages |
1269
+
1270
+ **Example:**
1271
+
1272
+ ```typescript
1273
+ // Get first page and a cursor for the second page
1274
+ const { data: workflows, nextCursor } = await zapier.listWorkflows();
1275
+
1276
+ // Or iterate over all pages
1277
+ for await (const page of zapier.listWorkflows()) {
1278
+ // Do something with each page
1279
+ }
1280
+
1281
+ // Or iterate over individual items across all pages
1282
+ for await (const workflow of zapier.listWorkflows().items()) {
1283
+ // Do something with each workflow
1284
+ }
1285
+ ```
1286
+
1287
+ #### `updateWorkflow` 🧪 _experimental_
1288
+
1289
+ Update a durable workflow's name and/or description
1290
+
1291
+ **Parameters:**
1292
+
1293
+ | Name | Type | Required | Default | Possible Values | Description |
1294
+ | ----------------- | -------- | -------- | ------- | --------------- | ----------------------------------------------------- |
1295
+ | `options` | `object` | ✅ | — | — | |
1296
+ | ​ ↳ `workflow` | `string` | ✅ | — | — | Durable workflow ID |
1297
+ | ​ ↳ `name` | `string` | ❌ | — | — | New name for the workflow |
1298
+ | ​ ↳ `description` | `string` | ❌ | — | — | New description for the workflow (pass null to clear) |
1299
+
1300
+ **Returns:** `Promise<WorkflowItem>`
1301
+
1302
+ | Name | Type | Required | Possible Values | Description |
1303
+ | ----------------- | --------- | -------- | --------------- | --------------------------------------------------------------------------------------------------------------------------- |
1304
+ | `data` | `object` | ✅ | — | |
1305
+ | ​ ↳ `id` | `string` | ✅ | — | Workflow ID (UUID) |
1306
+ | ​ ↳ `name` | `string` | ✅ | — | Workflow name (post-update) |
1307
+ | ​ ↳ `description` | `string` | ✅ | — | Workflow description, post-update (null if unset) |
1308
+ | ​ ↳ `trigger_url` | `string` | ✅ | — | Public webhook URL that fires this workflow when POSTed to. Embeds a secret trigger token in the path — treat as sensitive. |
1309
+ | ​ ↳ `enabled` | `boolean` | ✅ | — | Whether the workflow currently accepts triggers |
1310
+ | ​ ↳ `created_at` | `string` | ✅ | — | When the workflow was created (ISO-8601) |
1311
+ | ​ ↳ `updated_at` | `string` | ✅ | — | When this update was applied (ISO-8601) |
1312
+
1313
+ **Example:**
1314
+
1315
+ ```typescript
1316
+ const result = await zapier.updateWorkflow({
1317
+ workflow: "example-workflow",
1318
+ });
1319
+ ```
1320
+
1083
1321
  ### Connections
1084
1322
 
1085
1323
  #### `findFirstConnection`