@zapier/zapier-sdk 0.62.0 → 0.64.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 (50) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/README.md +185 -0
  3. package/dist/experimental.cjs +310 -2
  4. package/dist/experimental.d.mts +114 -2
  5. package/dist/experimental.d.ts +112 -0
  6. package/dist/experimental.d.ts.map +1 -1
  7. package/dist/experimental.js +10 -0
  8. package/dist/experimental.mjs +310 -3
  9. package/dist/{index-3fBEDEsp.d.mts → index-Bfvj0KLi.d.mts} +15 -1
  10. package/dist/{index-3fBEDEsp.d.ts → index-Bfvj0KLi.d.ts} +15 -1
  11. package/dist/index.cjs +22 -1
  12. package/dist/index.d.mts +1 -1
  13. package/dist/index.mjs +22 -2
  14. package/dist/plugins/codeSubstrate/cancelDurableRun/index.d.ts +40 -0
  15. package/dist/plugins/codeSubstrate/cancelDurableRun/index.d.ts.map +1 -0
  16. package/dist/plugins/codeSubstrate/cancelDurableRun/index.js +27 -0
  17. package/dist/plugins/codeSubstrate/cancelDurableRun/schemas.d.ts +11 -0
  18. package/dist/plugins/codeSubstrate/cancelDurableRun/schemas.d.ts.map +1 -0
  19. package/dist/plugins/codeSubstrate/cancelDurableRun/schemas.js +12 -0
  20. package/dist/plugins/codeSubstrate/getWorkflowVersion/index.d.ts +46 -0
  21. package/dist/plugins/codeSubstrate/getWorkflowVersion/index.d.ts.map +1 -0
  22. package/dist/plugins/codeSubstrate/getWorkflowVersion/index.js +25 -0
  23. package/dist/plugins/codeSubstrate/getWorkflowVersion/schemas.d.ts +17 -0
  24. package/dist/plugins/codeSubstrate/getWorkflowVersion/schemas.d.ts.map +1 -0
  25. package/dist/plugins/codeSubstrate/getWorkflowVersion/schemas.js +25 -0
  26. package/dist/plugins/codeSubstrate/listWorkflowVersions/index.d.ts +49 -0
  27. package/dist/plugins/codeSubstrate/listWorkflowVersions/index.d.ts.map +1 -0
  28. package/dist/plugins/codeSubstrate/listWorkflowVersions/index.js +34 -0
  29. package/dist/plugins/codeSubstrate/listWorkflowVersions/schemas.d.ts +37 -0
  30. package/dist/plugins/codeSubstrate/listWorkflowVersions/schemas.d.ts.map +1 -0
  31. package/dist/plugins/codeSubstrate/listWorkflowVersions/schemas.js +48 -0
  32. package/dist/plugins/codeSubstrate/publishWorkflowVersion/index.d.ts +49 -0
  33. package/dist/plugins/codeSubstrate/publishWorkflowVersion/index.d.ts.map +1 -0
  34. package/dist/plugins/codeSubstrate/publishWorkflowVersion/index.js +33 -0
  35. package/dist/plugins/codeSubstrate/publishWorkflowVersion/schemas.d.ts +20 -0
  36. package/dist/plugins/codeSubstrate/publishWorkflowVersion/schemas.d.ts.map +1 -0
  37. package/dist/plugins/codeSubstrate/publishWorkflowVersion/schemas.js +42 -0
  38. package/dist/plugins/codeSubstrate/runDurable/index.d.ts +53 -0
  39. package/dist/plugins/codeSubstrate/runDurable/index.d.ts.map +1 -0
  40. package/dist/plugins/codeSubstrate/runDurable/index.js +36 -0
  41. package/dist/plugins/codeSubstrate/runDurable/schemas.d.ts +24 -0
  42. package/dist/plugins/codeSubstrate/runDurable/schemas.d.ts.map +1 -0
  43. package/dist/plugins/codeSubstrate/runDurable/schemas.js +61 -0
  44. package/dist/resolvers/index.d.ts +1 -0
  45. package/dist/resolvers/index.d.ts.map +1 -1
  46. package/dist/resolvers/index.js +1 -0
  47. package/dist/resolvers/workflowVersionId.d.ts +6 -0
  48. package/dist/resolvers/workflowVersionId.d.ts.map +1 -0
  49. package/dist/resolvers/workflowVersionId.js +20 -0
  50. package/package.json +1 -1
package/CHANGELOG.md CHANGED
@@ -1,5 +1,17 @@
1
1
  # @zapier/zapier-sdk
2
2
 
3
+ ## 0.64.0
4
+
5
+ ### Minor Changes
6
+
7
+ - 913aa6b: Add the workflow-version experimental code-substrate plugins: `publishWorkflowVersion`, `listWorkflowVersions`, and `getWorkflowVersion`. All three are registered only in `@zapier/zapier-sdk/experimental`; the stable subpath does not expose them. `listWorkflowVersions` is paginated (cursor + pageSize); `publishWorkflowVersion` POSTs `source_files` (filename → contents) plus optional `dependencies`, `zapier_durable_version`, and `enabled` (defaults to true) to publish a new version; `getWorkflowVersion` returns the full version state including source files. 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. Adds `workflowVersionIdResolver` — a dependent resolver scoped to a parent workflow, mirrored on `tableRecordIdResolver`'s shape — so commands that take a version id present an interactive picker via `sdk.listWorkflowVersions({ workflow })` in the CLI. All ID inputs are UUID-validated 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.63.0
10
+
11
+ ### Minor Changes
12
+
13
+ - dfa3cea: Add the durable-run-write experimental code-substrate plugins: `runDurable` and `cancelDurableRun`. Both are registered only in `@zapier/zapier-sdk/experimental`; the stable subpath does not expose them. `runDurable` POSTs to sdkdurableapi `/api/v0/runs` with `source_files` (filename → contents), optional `input`/`dependencies`/`zapier_durable_version`/`connections`/`app_versions`, and a `private` input that maps to `is_private` on the wire. Returns the run ID immediately in `initialized` status — callers that need terminal status poll via `getDurableRun`; no built-in polling. `cancelDurableRun` POSTs to `/api/v0/runs/:id/cancel`, returns `{ id, status: "cancelled" }` on success, and propagates `ZapierNotFoundError` (404) and `ZapierConflictError` (409 — run already terminal) so callers can distinguish those outcomes. `runDurable` passes the API response through verbatim (no client-side `.parse()` re-emission) so callers see any richer fields the server adds later without an SDK release. Input field naming follows the in-tree convention (`run` rather than `runId`); UUID-validated at the input boundary. `cancelDurableRun` reuses `durableRunIdResolver` from the reads MR for ID pickers.
14
+
3
15
  ## 0.62.0
4
16
 
5
17
  ### Minor Changes
package/README.md CHANGED
@@ -27,14 +27,19 @@
27
27
  - [`deleteClientCredentials`](#deleteclientcredentials)
28
28
  - [`listClientCredentials`](#listclientcredentials)
29
29
  - [Code Workflows (Experimental)](#code-workflows-experimental)
30
+ - [`cancelDurableRun`](#canceldurablerun--experimental)
30
31
  - [`createWorkflow`](#createworkflow--experimental)
31
32
  - [`deleteWorkflow`](#deleteworkflow--experimental)
32
33
  - [`disableWorkflow`](#disableworkflow--experimental)
33
34
  - [`enableWorkflow`](#enableworkflow--experimental)
34
35
  - [`getDurableRun`](#getdurablerun--experimental)
35
36
  - [`getWorkflow`](#getworkflow--experimental)
37
+ - [`getWorkflowVersion`](#getworkflowversion--experimental)
36
38
  - [`listDurableRuns`](#listdurableruns--experimental)
39
+ - [`listWorkflowVersions`](#listworkflowversions--experimental)
37
40
  - [`listWorkflows`](#listworkflows--experimental)
41
+ - [`publishWorkflowVersion`](#publishworkflowversion--experimental)
42
+ - [`runDurable`](#rundurable--experimental)
38
43
  - [`updateWorkflow`](#updateworkflow--experimental)
39
44
  - [Connections](#connections)
40
45
  - [`findFirstConnection`](#findfirstconnection)
@@ -1094,6 +1099,27 @@ for await (const clientCredentials of zapier.listClientCredentials().items()) {
1094
1099
 
1095
1100
  > ℹ️ **Experimental.** Import from `"@zapier/zapier-sdk/experimental"` to use these methods. Methods and behavior may change.
1096
1101
 
1102
+ #### `cancelDurableRun` 🧪 _experimental_
1103
+
1104
+ Cancel a run-once durable run in initialized or started status. Returns 409 if the run is already terminal.
1105
+
1106
+ **Parameters:**
1107
+
1108
+ | Name | Type | Required | Default | Possible Values | Description |
1109
+ | --------- | -------- | -------- | ------- | --------------- | -------------- |
1110
+ | `options` | `object` | ✅ | — | — | |
1111
+ | ​ ↳ `run` | `string` | ✅ | — | — | Durable run ID |
1112
+
1113
+ **Returns:** `Promise<DurableRunItem>`
1114
+
1115
+ **Example:**
1116
+
1117
+ ```typescript
1118
+ const result = await zapier.cancelDurableRun({
1119
+ run: "example-run",
1120
+ });
1121
+ ```
1122
+
1097
1123
  #### `createWorkflow` 🧪 _experimental_
1098
1124
 
1099
1125
  Create a durable workflow container. Starts disabled with no version; publish a version to add code.
@@ -1275,6 +1301,40 @@ const { data: workflow } = await zapier.getWorkflow({
1275
1301
  });
1276
1302
  ```
1277
1303
 
1304
+ #### `getWorkflowVersion` 🧪 _experimental_
1305
+
1306
+ Get full details of a workflow version including source files
1307
+
1308
+ **Parameters:**
1309
+
1310
+ | Name | Type | Required | Default | Possible Values | Description |
1311
+ | -------------- | -------- | -------- | ------- | --------------- | ------------------- |
1312
+ | `options` | `object` | ✅ | — | — | |
1313
+ | ​ ↳ `workflow` | `string` | ✅ | — | — | Durable workflow ID |
1314
+ | ​ ↳ `version` | `string` | ✅ | — | — | Workflow version ID |
1315
+
1316
+ **Returns:** `Promise<WorkflowVersionItem>`
1317
+
1318
+ | Name | Type | Required | Possible Values | Description |
1319
+ | ---------------------------- | -------- | -------- | --------------- | ------------------------------------------------------------------- |
1320
+ | `data` | `object` | ✅ | — | |
1321
+ | ​ ↳ `id` | `string` | ✅ | — | Workflow version ID (UUID) |
1322
+ | ​ ↳ `workflow_id` | `string` | ✅ | — | Parent workflow ID (UUID) |
1323
+ | ​ ↳ `source_files` | `object` | ✅ | — | Source files keyed by filename → contents |
1324
+ | ​ ↳ `zapier_durable_version` | `string` | ✅ | — | Pinned semver of @zapier/zapier-durable used by this version's runs |
1325
+ | ​ ↳ `dependencies` | `object` | ✅ | — | Additional npm dependencies pinned for this version (or null) |
1326
+ | ​ ↳ `created_by_user_id` | `string` | ✅ | — | ID of the user who published this version |
1327
+ | ​ ↳ `created_at` | `string` | ✅ | — | When the version was published (ISO-8601) |
1328
+
1329
+ **Example:**
1330
+
1331
+ ```typescript
1332
+ const { data: workflowVersion } = await zapier.getWorkflowVersion({
1333
+ workflow: "example-workflow",
1334
+ version: "example-version",
1335
+ });
1336
+ ```
1337
+
1278
1338
  #### `listDurableRuns` 🧪 _experimental_
1279
1339
 
1280
1340
  List run-once durable runs for the authenticated account, newest first
@@ -1321,6 +1381,59 @@ for await (const durableRun of zapier.listDurableRuns().items()) {
1321
1381
  }
1322
1382
  ```
1323
1383
 
1384
+ #### `listWorkflowVersions` 🧪 _experimental_
1385
+
1386
+ List published versions for a workflow, newest first
1387
+
1388
+ **Parameters:**
1389
+
1390
+ | Name | Type | Required | Default | Possible Values | Description |
1391
+ | -------------- | -------- | -------- | ------- | --------------- | ------------------------------------------------- |
1392
+ | `options` | `object` | ✅ | — | — | |
1393
+ | ​ ↳ `workflow` | `string` | ✅ | — | — | Durable workflow ID |
1394
+ | ​ ↳ `pageSize` | `number` | ❌ | — | — | Number of versions per page (max 100) |
1395
+ | ​ ↳ `cursor` | `string` | ❌ | — | — | Pagination cursor |
1396
+ | ​ ↳ `maxItems` | `number` | ❌ | — | — | Maximum total versions to return across all pages |
1397
+
1398
+ **Returns:** `Promise<PaginatedResult<WorkflowVersionItem>>`
1399
+
1400
+ | Name | Type | Required | Possible Values | Description |
1401
+ | ---------------------------- | ---------- | -------- | --------------- | ------------------------------------------------------------------- |
1402
+ | `data[]` | `object[]` | ✅ | — | |
1403
+ | ​ ↳ `id` | `string` | ✅ | — | Workflow version ID (UUID) |
1404
+ | ​ ↳ `workflow_id` | `string` | ✅ | — | Parent workflow ID (UUID) |
1405
+ | ​ ↳ `zapier_durable_version` | `string` | ✅ | — | Pinned semver of @zapier/zapier-durable used by this version's runs |
1406
+ | ​ ↳ `dependencies` | `object` | ✅ | — | Additional npm dependencies pinned for this version (or null) |
1407
+ | ​ ↳ `created_by_user_id` | `string` | ✅ | — | ID of the user who published this version |
1408
+ | ​ ↳ `created_at` | `string` | ✅ | — | When the version was published (ISO-8601) |
1409
+ | `nextCursor` | `string` | ❌ | — | Cursor for the next page; omitted when there are no more pages |
1410
+
1411
+ **Example:**
1412
+
1413
+ ```typescript
1414
+ // Get first page and a cursor for the second page
1415
+ const { data: workflowVersions, nextCursor } =
1416
+ await zapier.listWorkflowVersions({
1417
+ workflow: "example-workflow",
1418
+ });
1419
+
1420
+ // Or iterate over all pages
1421
+ for await (const page of zapier.listWorkflowVersions({
1422
+ workflow: "example-workflow",
1423
+ })) {
1424
+ // Do something with each page
1425
+ }
1426
+
1427
+ // Or iterate over individual items across all pages
1428
+ for await (const workflowVersion of zapier
1429
+ .listWorkflowVersions({
1430
+ workflow: "example-workflow",
1431
+ })
1432
+ .items()) {
1433
+ // Do something with each workflowVersion
1434
+ }
1435
+ ```
1436
+
1324
1437
  #### `listWorkflows` 🧪 _experimental_
1325
1438
 
1326
1439
  List all active durable workflows for the authenticated account
@@ -1366,6 +1479,78 @@ for await (const workflow of zapier.listWorkflows().items()) {
1366
1479
  }
1367
1480
  ```
1368
1481
 
1482
+ #### `publishWorkflowVersion` 🧪 _experimental_
1483
+
1484
+ Publish a new version of a durable workflow. Enables the workflow by default.
1485
+
1486
+ **Parameters:**
1487
+
1488
+ | Name | Type | Required | Default | Possible Values | Description |
1489
+ | ---------------------------- | --------- | -------- | ------- | --------------- | --------------------------------------------------------------------------------------------------------------- |
1490
+ | `options` | `object` | ✅ | — | — | |
1491
+ | ​ ↳ `workflow` | `string` | ✅ | — | — | Durable workflow ID |
1492
+ | ​ ↳ `source_files` | `object` | ✅ | — | — | Source files keyed by filename → contents |
1493
+ | ​ ↳ `dependencies` | `object` | ❌ | — | — | Optional npm package dependencies |
1494
+ | ​ ↳ `zapier_durable_version` | `string` | ❌ | — | — | Exact semver of @zapier/zapier-durable to use (e.g. "1.2.3"). Defaults to server-configured version if omitted. |
1495
+ | ​ ↳ `enabled` | `boolean` | ❌ | — | — | Enable the workflow after publishing. Defaults to true; pass false to publish without enabling. |
1496
+
1497
+ **Returns:** `Promise<WorkflowVersionItem>`
1498
+
1499
+ | Name | Type | Required | Possible Values | Description |
1500
+ | ---------------------------- | -------- | -------- | --------------- | ------------------------------------------------------------------- |
1501
+ | `data` | `object` | ✅ | — | |
1502
+ | ​ ↳ `id` | `string` | ✅ | — | Workflow version ID (UUID) |
1503
+ | ​ ↳ `workflow_id` | `string` | ✅ | — | Parent workflow ID (UUID) |
1504
+ | ​ ↳ `source_files` | `object` | ✅ | — | Source files keyed by filename → contents |
1505
+ | ​ ↳ `zapier_durable_version` | `string` | ✅ | — | Pinned semver of @zapier/zapier-durable used by this version's runs |
1506
+ | ​ ↳ `dependencies` | `object` | ✅ | — | Additional npm dependencies pinned for this version (or null) |
1507
+ | ​ ↳ `created_by_user_id` | `string` | ✅ | — | ID of the user who published this version |
1508
+ | ​ ↳ `created_at` | `string` | ✅ | — | When the version was published (ISO-8601) |
1509
+
1510
+ **Example:**
1511
+
1512
+ ```typescript
1513
+ const result = await zapier.publishWorkflowVersion({
1514
+ workflow: "example-workflow",
1515
+ source_files: {},
1516
+ });
1517
+ ```
1518
+
1519
+ #### `runDurable` 🧪 _experimental_
1520
+
1521
+ Run a workflow source file as a run-once durable run on sdkdurableapi (no deployed workflow required). Returns the run ID immediately; poll via getDurableRun for terminal status.
1522
+
1523
+ **Parameters:**
1524
+
1525
+ | Name | Type | Required | Default | Possible Values | Description |
1526
+ | ---------------------------- | --------- | -------- | ------- | --------------- | --------------------------------------------------------------------------------------------------------------- |
1527
+ | `options` | `object` | ✅ | — | — | |
1528
+ | ​ ↳ `source_files` | `object` | ✅ | — | — | Source files keyed by filename → contents |
1529
+ | ​ ↳ `input` | `string` | ❌ | — | — | Input data passed to the run |
1530
+ | ​ ↳ `dependencies` | `object` | ❌ | — | — | Optional npm package dependencies |
1531
+ | ​ ↳ `zapier_durable_version` | `string` | ❌ | — | — | Exact semver of @zapier/zapier-durable to use (e.g. "1.2.3"). Defaults to server-configured version if omitted. |
1532
+ | ​ ↳ `connections` | `object` | ❌ | — | — | Named connection aliases. Maps alias names to Zapier connection IDs. |
1533
+ | ​ ↳ `app_versions` | `object` | ❌ | — | — | Pinned app versions. Maps app keys (slugs) to implementation names and versions. |
1534
+ | ​ ↳ `private` | `boolean` | ❌ | — | — | Only the creating user can see the run (default false) |
1535
+
1536
+ **Returns:** `Promise<DurableRunItem>`
1537
+
1538
+ | Name | Type | Required | Possible Values | Description |
1539
+ | ---------------- | --------- | -------- | --------------- | ----------------------------------------------------------------------------------------------------------------------------------------- |
1540
+ | `data` | `object` | ✅ | — | |
1541
+ | ​ ↳ `id` | `string` | ✅ | — | Run ID (UUID) — server-generated, time-sortable |
1542
+ | ​ ↳ `status` | `string` | ✅ | `initialized` | Always `initialized` on creation. Poll via getDurableRun to observe the run advancing to `started` / `finished` / `failed` / `cancelled`. |
1543
+ | ​ ↳ `is_private` | `boolean` | ✅ | — | When true, the run is visible only to the creating user; otherwise visible across the account. |
1544
+ | ​ ↳ `created_at` | `string` | ✅ | — | When the run was created (ISO-8601) |
1545
+
1546
+ **Example:**
1547
+
1548
+ ```typescript
1549
+ const result = await zapier.runDurable({
1550
+ source_files: {},
1551
+ });
1552
+ ```
1553
+
1369
1554
  #### `updateWorkflow` 🧪 _experimental_
1370
1555
 
1371
1556
  Update a durable workflow's name and/or description
@@ -2889,7 +2889,7 @@ async function invalidateCredentialsToken(options) {
2889
2889
  }
2890
2890
 
2891
2891
  // src/sdk-version.ts
2892
- var SDK_VERSION = (typeof process !== "undefined" && process.env ? "0.62.0" : void 0) || "unknown";
2892
+ var SDK_VERSION = (typeof process !== "undefined" && process.env ? "0.64.0" : void 0) || "unknown";
2893
2893
 
2894
2894
  // src/utils/open-url.ts
2895
2895
  var nodePrefix = "node:";
@@ -4301,6 +4301,26 @@ var durableRunIdResolver = {
4301
4301
  })
4302
4302
  };
4303
4303
 
4304
+ // src/resolvers/workflowVersionId.ts
4305
+ var workflowVersionIdResolver = {
4306
+ type: "dynamic",
4307
+ depends: ["workflow"],
4308
+ fetch: async (sdk, params) => toIterable(
4309
+ sdk.listWorkflowVersions({
4310
+ workflow: params.workflow
4311
+ })
4312
+ ),
4313
+ prompt: (versions) => ({
4314
+ type: "list",
4315
+ name: "version",
4316
+ message: "Select a workflow version:",
4317
+ choices: versions.map((v) => ({
4318
+ name: `${v.id} \u2014 ${v.zapier_durable_version}`,
4319
+ value: v.id
4320
+ }))
4321
+ })
4322
+ };
4323
+
4304
4324
  // src/resolvers/triggerMessages.ts
4305
4325
  var triggerMessagesResolver = {
4306
4326
  type: "dynamic",
@@ -11019,6 +11039,293 @@ var getDurableRunPlugin = definePlugin(
11019
11039
  }
11020
11040
  })
11021
11041
  );
11042
+ var ConnectionMapEntrySchema = zod.z.object({
11043
+ connection_id: zod.z.union([
11044
+ zod.z.string().regex(/^[1-9][0-9]*$/, "must be a positive integer string"),
11045
+ zod.z.string().uuid("must be a UUID"),
11046
+ zod.z.number().int().positive()
11047
+ ]).describe(
11048
+ "Zapier connection ID. Accepts a positive integer (legacy) or a UUID string (newer connections)."
11049
+ )
11050
+ });
11051
+ var AppVersionMapEntrySchema = zod.z.object({
11052
+ implementation_name: zod.z.string().min(1).describe("Zapier app implementation name (e.g. `SlackCLIAPI`)"),
11053
+ version: zod.z.string().optional().describe("Pinned app version (e.g. `1.27.1`). Latest if omitted.")
11054
+ });
11055
+ var RunDurableOptionsSchema = zod.z.object({
11056
+ source_files: zod.z.record(zod.z.string(), zod.z.string()).refine((files) => Object.keys(files).length > 0, {
11057
+ message: "source_files must contain at least one file"
11058
+ }).describe("Source files keyed by filename \u2192 contents"),
11059
+ input: zod.z.unknown().optional().describe("Input data passed to the run"),
11060
+ dependencies: zod.z.record(zod.z.string(), zod.z.string()).optional().describe("Optional npm package dependencies"),
11061
+ zapier_durable_version: zod.z.string().optional().describe(
11062
+ 'Exact semver of @zapier/zapier-durable to use (e.g. "1.2.3"). Defaults to server-configured version if omitted.'
11063
+ ),
11064
+ connections: zod.z.record(zod.z.string(), ConnectionMapEntrySchema).optional().describe(
11065
+ "Named connection aliases. Maps alias names to Zapier connection IDs."
11066
+ ),
11067
+ app_versions: zod.z.record(zod.z.string(), AppVersionMapEntrySchema).optional().describe(
11068
+ "Pinned app versions. Maps app keys (slugs) to implementation names and versions."
11069
+ ),
11070
+ private: zod.z.boolean().optional().describe("Only the creating user can see the run (default false)")
11071
+ }).describe(
11072
+ "Run a workflow source file as a run-once durable run on sdkdurableapi (no deployed workflow required). Returns the run ID immediately; poll via getDurableRun for terminal status."
11073
+ );
11074
+ var RunDurableResponseSchema = zod.z.object({
11075
+ id: zod.z.string().describe("Run ID (UUID) \u2014 server-generated, time-sortable"),
11076
+ status: zod.z.literal("initialized").describe(
11077
+ "Always `initialized` on creation. Poll via getDurableRun to observe the run advancing to `started` / `finished` / `failed` / `cancelled`."
11078
+ ),
11079
+ is_private: zod.z.boolean().describe(
11080
+ "When true, the run is visible only to the creating user; otherwise visible across the account."
11081
+ ),
11082
+ created_at: zod.z.string().describe("When the run was created (ISO-8601)")
11083
+ });
11084
+
11085
+ // src/plugins/codeSubstrate/runDurable/index.ts
11086
+ var runDurablePlugin = definePlugin(
11087
+ (sdk) => createPluginMethod(sdk, {
11088
+ ...codeSubstrateDefaults,
11089
+ name: "runDurable",
11090
+ type: "create",
11091
+ itemType: "DurableRun",
11092
+ inputSchema: RunDurableOptionsSchema,
11093
+ outputSchema: RunDurableResponseSchema,
11094
+ handler: async ({ sdk: sdk2, options }) => {
11095
+ const body = {
11096
+ source_files: options.source_files
11097
+ };
11098
+ if (options.input !== void 0) {
11099
+ body.input = options.input;
11100
+ }
11101
+ if (options.dependencies !== void 0) {
11102
+ body.dependencies = options.dependencies;
11103
+ }
11104
+ if (options.zapier_durable_version !== void 0) {
11105
+ body.zapier_durable_version = options.zapier_durable_version;
11106
+ }
11107
+ if (options.connections !== void 0) {
11108
+ body.connections = options.connections;
11109
+ }
11110
+ if (options.app_versions !== void 0) {
11111
+ body.app_versions = options.app_versions;
11112
+ }
11113
+ if (options.private !== void 0) {
11114
+ body.is_private = options.private;
11115
+ }
11116
+ const data = await sdk2.context.api.post(
11117
+ "/sdkdurableapi/api/v0/runs",
11118
+ body,
11119
+ { authRequired: true }
11120
+ );
11121
+ return { data };
11122
+ }
11123
+ })
11124
+ );
11125
+ var CancelDurableRunOptionsSchema = zod.z.object({
11126
+ run: zod.z.string().uuid().describe("Durable run ID")
11127
+ }).describe(
11128
+ "Cancel a run-once durable run in initialized or started status. Returns 409 if the run is already terminal."
11129
+ );
11130
+ zod.z.object({
11131
+ id: zod.z.string().describe("Run ID that was targeted"),
11132
+ status: zod.z.literal("cancelled").describe(
11133
+ "Always `cancelled` on a successful call. Synthesized client-side \u2014 the backend returns 204; callers needing the run's full state should follow up with getDurableRun."
11134
+ )
11135
+ });
11136
+
11137
+ // src/plugins/codeSubstrate/cancelDurableRun/index.ts
11138
+ var cancelDurableRunPlugin = definePlugin(
11139
+ (sdk) => createPluginMethod(sdk, {
11140
+ ...codeSubstrateDefaults,
11141
+ name: "cancelDurableRun",
11142
+ type: "update",
11143
+ itemType: "DurableRun",
11144
+ inputSchema: CancelDurableRunOptionsSchema,
11145
+ resolvers: { run: durableRunIdResolver },
11146
+ handler: async ({ sdk: sdk2, options }) => {
11147
+ await sdk2.context.api.post(
11148
+ `/sdkdurableapi/api/v0/runs/${encodeURIComponent(options.run)}/cancel`,
11149
+ void 0,
11150
+ {
11151
+ authRequired: true,
11152
+ resource: { type: "run", id: options.run }
11153
+ }
11154
+ );
11155
+ return {
11156
+ data: { id: options.run, status: "cancelled" }
11157
+ };
11158
+ }
11159
+ })
11160
+ );
11161
+ var PublishWorkflowVersionOptionsSchema = zod.z.object({
11162
+ workflow: zod.z.string().uuid().describe("Durable workflow ID"),
11163
+ source_files: zod.z.record(zod.z.string(), zod.z.string()).refine((files) => Object.keys(files).length > 0, {
11164
+ message: "source_files must contain at least one file"
11165
+ }).describe("Source files keyed by filename \u2192 contents"),
11166
+ dependencies: zod.z.record(zod.z.string(), zod.z.string()).optional().describe("Optional npm package dependencies"),
11167
+ zapier_durable_version: zod.z.string().optional().describe(
11168
+ 'Exact semver of @zapier/zapier-durable to use (e.g. "1.2.3"). Defaults to server-configured version if omitted.'
11169
+ ),
11170
+ enabled: zod.z.boolean().optional().describe(
11171
+ "Enable the workflow after publishing. Defaults to true; pass false to publish without enabling."
11172
+ )
11173
+ }).describe(
11174
+ "Publish a new version of a durable workflow. Enables the workflow by default."
11175
+ );
11176
+ var PublishWorkflowVersionResponseSchema = zod.z.object({
11177
+ id: zod.z.string().describe("Workflow version ID (UUID)"),
11178
+ workflow_id: zod.z.string().describe("Parent workflow ID (UUID)"),
11179
+ source_files: zod.z.record(zod.z.string(), zod.z.string()).describe("Source files keyed by filename \u2192 contents"),
11180
+ zapier_durable_version: zod.z.string().describe(
11181
+ "Pinned semver of @zapier/zapier-durable used by this version's runs"
11182
+ ),
11183
+ dependencies: zod.z.record(zod.z.string(), zod.z.string()).nullable().describe("Additional npm dependencies pinned for this version (or null)"),
11184
+ created_by_user_id: zod.z.string().describe("ID of the user who published this version"),
11185
+ created_at: zod.z.string().describe("When the version was published (ISO-8601)")
11186
+ });
11187
+
11188
+ // src/plugins/codeSubstrate/publishWorkflowVersion/index.ts
11189
+ var publishWorkflowVersionPlugin = definePlugin(
11190
+ (sdk) => createPluginMethod(sdk, {
11191
+ ...codeSubstrateDefaults,
11192
+ name: "publishWorkflowVersion",
11193
+ type: "create",
11194
+ itemType: "WorkflowVersion",
11195
+ inputSchema: PublishWorkflowVersionOptionsSchema,
11196
+ outputSchema: PublishWorkflowVersionResponseSchema,
11197
+ resolvers: { workflow: workflowIdResolver },
11198
+ handler: async ({ sdk: sdk2, options }) => {
11199
+ const body = {
11200
+ source_files: options.source_files
11201
+ };
11202
+ if (options.dependencies !== void 0) {
11203
+ body.dependencies = options.dependencies;
11204
+ }
11205
+ if (options.zapier_durable_version !== void 0) {
11206
+ body.zapier_durable_version = options.zapier_durable_version;
11207
+ }
11208
+ if (options.enabled !== void 0) {
11209
+ body.enabled = options.enabled;
11210
+ }
11211
+ const raw = await sdk2.context.api.post(
11212
+ `/durableworkflowzaps/api/v0/workflows/${encodeURIComponent(options.workflow)}/versions`,
11213
+ body,
11214
+ {
11215
+ authRequired: true,
11216
+ resource: { type: "workflow", id: options.workflow }
11217
+ }
11218
+ );
11219
+ const data = PublishWorkflowVersionResponseSchema.parse(raw);
11220
+ return { data };
11221
+ }
11222
+ })
11223
+ );
11224
+ var WorkflowVersionListItemSchema = zod.z.object({
11225
+ id: zod.z.string().describe("Workflow version ID (UUID)"),
11226
+ workflow_id: zod.z.string().describe("Parent workflow ID (UUID)"),
11227
+ zapier_durable_version: zod.z.string().describe(
11228
+ "Pinned semver of @zapier/zapier-durable used by this version's runs"
11229
+ ),
11230
+ dependencies: zod.z.record(zod.z.string(), zod.z.string()).nullable().describe("Additional npm dependencies pinned for this version (or null)"),
11231
+ created_by_user_id: zod.z.string().describe("ID of the user who published this version"),
11232
+ created_at: zod.z.string().describe("When the version was published (ISO-8601)")
11233
+ });
11234
+ var ListWorkflowVersionsOptionsSchema = zod.z.object({
11235
+ workflow: zod.z.string().uuid().describe("Durable workflow ID"),
11236
+ pageSize: zod.z.number().int().min(1).max(100).optional().describe("Number of versions per page (max 100)"),
11237
+ cursor: zod.z.string().optional().describe("Pagination cursor"),
11238
+ maxItems: zod.z.number().int().min(1).optional().describe("Maximum total versions to return across all pages")
11239
+ }).describe("List published versions for a workflow, newest first");
11240
+ var ListWorkflowVersionsApiResponseSchema = zod.z.object({
11241
+ results: zod.z.array(WorkflowVersionListItemSchema),
11242
+ meta: zod.z.object({
11243
+ limit: zod.z.number(),
11244
+ cursor: zod.z.string().nullable().optional(),
11245
+ next_cursor: zod.z.string().nullable().optional()
11246
+ }),
11247
+ links: zod.z.object({
11248
+ next: zod.z.string().nullable().optional()
11249
+ }).optional()
11250
+ });
11251
+
11252
+ // src/plugins/codeSubstrate/listWorkflowVersions/index.ts
11253
+ var listWorkflowVersionsPlugin = definePlugin(
11254
+ (sdk) => createPaginatedPluginMethod(sdk, {
11255
+ ...codeSubstrateDefaults,
11256
+ name: "listWorkflowVersions",
11257
+ type: "list",
11258
+ itemType: "WorkflowVersion",
11259
+ inputSchema: ListWorkflowVersionsOptionsSchema,
11260
+ outputSchema: WorkflowVersionListItemSchema,
11261
+ defaultPageSize: DEFAULT_PAGE_SIZE,
11262
+ resolvers: { workflow: workflowIdResolver },
11263
+ handler: async ({ sdk: sdk2, options }) => {
11264
+ const searchParams = {};
11265
+ if (options.pageSize !== void 0) {
11266
+ searchParams.limit = options.pageSize.toString();
11267
+ }
11268
+ if (options.cursor) {
11269
+ searchParams.cursor = options.cursor;
11270
+ }
11271
+ const raw = await sdk2.context.api.get(
11272
+ `/durableworkflowzaps/api/v0/workflows/${encodeURIComponent(options.workflow)}/versions`,
11273
+ {
11274
+ searchParams,
11275
+ authRequired: true,
11276
+ resource: { type: "workflow", id: options.workflow }
11277
+ }
11278
+ );
11279
+ const response = ListWorkflowVersionsApiResponseSchema.parse(raw);
11280
+ return {
11281
+ data: response.results,
11282
+ nextCursor: response.meta.next_cursor ?? void 0
11283
+ };
11284
+ }
11285
+ })
11286
+ );
11287
+ var GetWorkflowVersionOptionsSchema = zod.z.object({
11288
+ workflow: zod.z.string().uuid().describe("Durable workflow ID"),
11289
+ version: zod.z.string().uuid().describe("Workflow version ID")
11290
+ }).describe("Get full details of a workflow version including source files");
11291
+ var GetWorkflowVersionResponseSchema = zod.z.object({
11292
+ id: zod.z.string().describe("Workflow version ID (UUID)"),
11293
+ workflow_id: zod.z.string().describe("Parent workflow ID (UUID)"),
11294
+ source_files: zod.z.record(zod.z.string(), zod.z.string()).describe("Source files keyed by filename \u2192 contents"),
11295
+ zapier_durable_version: zod.z.string().describe(
11296
+ "Pinned semver of @zapier/zapier-durable used by this version's runs"
11297
+ ),
11298
+ dependencies: zod.z.record(zod.z.string(), zod.z.string()).nullable().describe("Additional npm dependencies pinned for this version (or null)"),
11299
+ created_by_user_id: zod.z.string().describe("ID of the user who published this version"),
11300
+ created_at: zod.z.string().describe("When the version was published (ISO-8601)")
11301
+ });
11302
+
11303
+ // src/plugins/codeSubstrate/getWorkflowVersion/index.ts
11304
+ var getWorkflowVersionPlugin = definePlugin(
11305
+ (sdk) => createPluginMethod(sdk, {
11306
+ ...codeSubstrateDefaults,
11307
+ name: "getWorkflowVersion",
11308
+ type: "item",
11309
+ itemType: "WorkflowVersion",
11310
+ inputSchema: GetWorkflowVersionOptionsSchema,
11311
+ outputSchema: GetWorkflowVersionResponseSchema,
11312
+ resolvers: {
11313
+ workflow: workflowIdResolver,
11314
+ version: workflowVersionIdResolver
11315
+ },
11316
+ handler: async ({ sdk: sdk2, options }) => {
11317
+ const raw = await sdk2.context.api.get(
11318
+ `/durableworkflowzaps/api/v0/workflows/${encodeURIComponent(options.workflow)}/versions/${encodeURIComponent(options.version)}`,
11319
+ {
11320
+ authRequired: true,
11321
+ resource: { type: "workflow-version", id: options.version }
11322
+ }
11323
+ );
11324
+ const data = GetWorkflowVersionResponseSchema.parse(raw);
11325
+ return { data };
11326
+ }
11327
+ })
11328
+ );
11022
11329
 
11023
11330
  // src/utils/batch-utils.ts
11024
11331
  var DEFAULT_CONCURRENCY = 10;
@@ -11178,7 +11485,7 @@ var registryPlugin = definePlugin((_sdk) => {
11178
11485
 
11179
11486
  // src/experimental.ts
11180
11487
  function createZapierSdk2(options = {}) {
11181
- return createSdk().addPlugin(createOptionsPlugin(options)).addPlugin(eventEmissionPlugin).addPlugin(apiPlugin).addPlugin(manifestPlugin).addPlugin(capabilitiesPlugin).addPlugin(connectionsPlugin).addPlugin(listAppsPlugin).addPlugin(getAppPlugin).addPlugin(listActionsPlugin).addPlugin(getActionPlugin).addPlugin(listActionInputFieldsPlugin).addPlugin(getActionInputFieldsSchemaPlugin).addPlugin(listActionInputFieldChoicesPlugin).addPlugin(listInputFieldsDeprecatedPlugin).addPlugin(getInputFieldsSchemaDeprecatedPlugin).addPlugin(listInputFieldChoicesDeprecatedPlugin).addPlugin(runActionPlugin).addPlugin(listConnectionsPlugin).addPlugin(getConnectionPlugin).addPlugin(findFirstConnectionPlugin).addPlugin(findUniqueConnectionPlugin).addPlugin(listAuthenticationsPlugin).addPlugin(getAuthenticationPlugin).addPlugin(findFirstAuthenticationPlugin).addPlugin(findUniqueAuthenticationPlugin).addPlugin(listClientCredentialsPlugin).addPlugin(createClientCredentialsPlugin).addPlugin(deleteClientCredentialsPlugin).addPlugin(fetchPlugin).addPlugin(requestPlugin).addPlugin(createTriggerInboxPlugin).addPlugin(ensureTriggerInboxPlugin).addPlugin(listTriggerInboxesPlugin).addPlugin(getTriggerInboxPlugin).addPlugin(updateTriggerInboxPlugin).addPlugin(deleteTriggerInboxPlugin).addPlugin(pauseTriggerInboxPlugin).addPlugin(resumeTriggerInboxPlugin).addPlugin(listTriggerInboxMessagesPlugin).addPlugin(leaseTriggerInboxMessagesPlugin).addPlugin(ackTriggerInboxMessagesPlugin).addPlugin(releaseTriggerInboxMessagesPlugin).addPlugin(drainTriggerInboxPlugin).addPlugin(watchTriggerInboxPlugin).addPlugin(listTriggersPlugin).addPlugin(listTriggerInputFieldsPlugin).addPlugin(listTriggerInputFieldChoicesPlugin).addPlugin(getTriggerInputFieldsSchemaPlugin).addPlugin(listTablesPlugin).addPlugin(getTablePlugin).addPlugin(deleteTablePlugin).addPlugin(createTablePlugin).addPlugin(listTableFieldsPlugin).addPlugin(createTableFieldsPlugin).addPlugin(deleteTableFieldsPlugin).addPlugin(getTableRecordPlugin).addPlugin(listTableRecordsPlugin).addPlugin(createTableRecordsPlugin).addPlugin(deleteTableRecordsPlugin).addPlugin(updateTableRecordsPlugin).addPlugin(listWorkflowsPlugin).addPlugin(getWorkflowPlugin).addPlugin(createWorkflowPlugin).addPlugin(updateWorkflowPlugin).addPlugin(enableWorkflowPlugin).addPlugin(disableWorkflowPlugin).addPlugin(deleteWorkflowPlugin).addPlugin(listDurableRunsPlugin).addPlugin(getDurableRunPlugin).addPlugin(appsPlugin).addPlugin(getProfilePlugin);
11488
+ return createSdk().addPlugin(createOptionsPlugin(options)).addPlugin(eventEmissionPlugin).addPlugin(apiPlugin).addPlugin(manifestPlugin).addPlugin(capabilitiesPlugin).addPlugin(connectionsPlugin).addPlugin(listAppsPlugin).addPlugin(getAppPlugin).addPlugin(listActionsPlugin).addPlugin(getActionPlugin).addPlugin(listActionInputFieldsPlugin).addPlugin(getActionInputFieldsSchemaPlugin).addPlugin(listActionInputFieldChoicesPlugin).addPlugin(listInputFieldsDeprecatedPlugin).addPlugin(getInputFieldsSchemaDeprecatedPlugin).addPlugin(listInputFieldChoicesDeprecatedPlugin).addPlugin(runActionPlugin).addPlugin(listConnectionsPlugin).addPlugin(getConnectionPlugin).addPlugin(findFirstConnectionPlugin).addPlugin(findUniqueConnectionPlugin).addPlugin(listAuthenticationsPlugin).addPlugin(getAuthenticationPlugin).addPlugin(findFirstAuthenticationPlugin).addPlugin(findUniqueAuthenticationPlugin).addPlugin(listClientCredentialsPlugin).addPlugin(createClientCredentialsPlugin).addPlugin(deleteClientCredentialsPlugin).addPlugin(fetchPlugin).addPlugin(requestPlugin).addPlugin(createTriggerInboxPlugin).addPlugin(ensureTriggerInboxPlugin).addPlugin(listTriggerInboxesPlugin).addPlugin(getTriggerInboxPlugin).addPlugin(updateTriggerInboxPlugin).addPlugin(deleteTriggerInboxPlugin).addPlugin(pauseTriggerInboxPlugin).addPlugin(resumeTriggerInboxPlugin).addPlugin(listTriggerInboxMessagesPlugin).addPlugin(leaseTriggerInboxMessagesPlugin).addPlugin(ackTriggerInboxMessagesPlugin).addPlugin(releaseTriggerInboxMessagesPlugin).addPlugin(drainTriggerInboxPlugin).addPlugin(watchTriggerInboxPlugin).addPlugin(listTriggersPlugin).addPlugin(listTriggerInputFieldsPlugin).addPlugin(listTriggerInputFieldChoicesPlugin).addPlugin(getTriggerInputFieldsSchemaPlugin).addPlugin(listTablesPlugin).addPlugin(getTablePlugin).addPlugin(deleteTablePlugin).addPlugin(createTablePlugin).addPlugin(listTableFieldsPlugin).addPlugin(createTableFieldsPlugin).addPlugin(deleteTableFieldsPlugin).addPlugin(getTableRecordPlugin).addPlugin(listTableRecordsPlugin).addPlugin(createTableRecordsPlugin).addPlugin(deleteTableRecordsPlugin).addPlugin(updateTableRecordsPlugin).addPlugin(listWorkflowsPlugin).addPlugin(getWorkflowPlugin).addPlugin(createWorkflowPlugin).addPlugin(updateWorkflowPlugin).addPlugin(enableWorkflowPlugin).addPlugin(disableWorkflowPlugin).addPlugin(deleteWorkflowPlugin).addPlugin(listDurableRunsPlugin).addPlugin(getDurableRunPlugin).addPlugin(runDurablePlugin).addPlugin(cancelDurableRunPlugin).addPlugin(publishWorkflowVersionPlugin).addPlugin(listWorkflowVersionsPlugin).addPlugin(getWorkflowVersionPlugin).addPlugin(appsPlugin).addPlugin(getProfilePlugin);
11182
11489
  }
11183
11490
 
11184
11491
  exports.ActionKeyPropertySchema = ActionKeyPropertySchema;
@@ -11372,3 +11679,4 @@ exports.triggerInboxResolver = triggerInboxResolver;
11372
11679
  exports.triggerMessagesResolver = triggerMessagesResolver;
11373
11680
  exports.updateTableRecordsPlugin = updateTableRecordsPlugin;
11374
11681
  exports.workflowIdResolver = workflowIdResolver;
11682
+ exports.workflowVersionIdResolver = workflowVersionIdResolver;