@zapier/zapier-sdk 0.61.0 → 0.63.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 (44) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/README.md +140 -0
  3. package/dist/experimental.cjs +317 -2
  4. package/dist/experimental.d.mts +139 -2
  5. package/dist/experimental.d.ts +137 -0
  6. package/dist/experimental.d.ts.map +1 -1
  7. package/dist/experimental.js +8 -0
  8. package/dist/experimental.mjs +317 -3
  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 +17 -1
  12. package/dist/index.d.mts +1 -1
  13. package/dist/index.mjs +17 -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/getDurableRun/index.d.ts +89 -0
  21. package/dist/plugins/codeSubstrate/getDurableRun/index.d.ts.map +1 -0
  22. package/dist/plugins/codeSubstrate/getDurableRun/index.js +20 -0
  23. package/dist/plugins/codeSubstrate/getDurableRun/schemas.d.ts +178 -0
  24. package/dist/plugins/codeSubstrate/getDurableRun/schemas.d.ts.map +1 -0
  25. package/dist/plugins/codeSubstrate/getDurableRun/schemas.js +130 -0
  26. package/dist/plugins/codeSubstrate/listDurableRuns/index.d.ts +55 -0
  27. package/dist/plugins/codeSubstrate/listDurableRuns/index.d.ts.map +1 -0
  28. package/dist/plugins/codeSubstrate/listDurableRuns/index.js +27 -0
  29. package/dist/plugins/codeSubstrate/listDurableRuns/schemas.d.ts +73 -0
  30. package/dist/plugins/codeSubstrate/listDurableRuns/schemas.d.ts.map +1 -0
  31. package/dist/plugins/codeSubstrate/listDurableRuns/schemas.js +59 -0
  32. package/dist/plugins/codeSubstrate/runDurable/index.d.ts +53 -0
  33. package/dist/plugins/codeSubstrate/runDurable/index.d.ts.map +1 -0
  34. package/dist/plugins/codeSubstrate/runDurable/index.js +36 -0
  35. package/dist/plugins/codeSubstrate/runDurable/schemas.d.ts +24 -0
  36. package/dist/plugins/codeSubstrate/runDurable/schemas.d.ts.map +1 -0
  37. package/dist/plugins/codeSubstrate/runDurable/schemas.js +61 -0
  38. package/dist/resolvers/durableRunId.d.ts +4 -0
  39. package/dist/resolvers/durableRunId.d.ts.map +1 -0
  40. package/dist/resolvers/durableRunId.js +14 -0
  41. package/dist/resolvers/index.d.ts +1 -0
  42. package/dist/resolvers/index.d.ts.map +1 -1
  43. package/dist/resolvers/index.js +1 -0
  44. package/package.json +1 -1
package/CHANGELOG.md CHANGED
@@ -1,5 +1,17 @@
1
1
  # @zapier/zapier-sdk
2
2
 
3
+ ## 0.63.0
4
+
5
+ ### Minor Changes
6
+
7
+ - 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.
8
+
9
+ ## 0.62.0
10
+
11
+ ### Minor Changes
12
+
13
+ - 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.
14
+
3
15
  ## 0.61.0
4
16
 
5
17
  ### Minor Changes
package/README.md CHANGED
@@ -27,12 +27,16 @@
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)
35
+ - [`getDurableRun`](#getdurablerun--experimental)
34
36
  - [`getWorkflow`](#getworkflow--experimental)
37
+ - [`listDurableRuns`](#listdurableruns--experimental)
35
38
  - [`listWorkflows`](#listworkflows--experimental)
39
+ - [`runDurable`](#rundurable--experimental)
36
40
  - [`updateWorkflow`](#updateworkflow--experimental)
37
41
  - [Connections](#connections)
38
42
  - [`findFirstConnection`](#findfirstconnection)
@@ -1092,6 +1096,27 @@ for await (const clientCredentials of zapier.listClientCredentials().items()) {
1092
1096
 
1093
1097
  > ℹ️ **Experimental.** Import from `"@zapier/zapier-sdk/experimental"` to use these methods. Methods and behavior may change.
1094
1098
 
1099
+ #### `cancelDurableRun` 🧪 _experimental_
1100
+
1101
+ Cancel a run-once durable run in initialized or started status. Returns 409 if the run is already terminal.
1102
+
1103
+ **Parameters:**
1104
+
1105
+ | Name | Type | Required | Default | Possible Values | Description |
1106
+ | --------- | -------- | -------- | ------- | --------------- | -------------- |
1107
+ | `options` | `object` | ✅ | — | — | |
1108
+ | ​ ↳ `run` | `string` | ✅ | — | — | Durable run ID |
1109
+
1110
+ **Returns:** `Promise<DurableRunItem>`
1111
+
1112
+ **Example:**
1113
+
1114
+ ```typescript
1115
+ const result = await zapier.cancelDurableRun({
1116
+ run: "example-run",
1117
+ });
1118
+ ```
1119
+
1095
1120
  #### `createWorkflow` 🧪 _experimental_
1096
1121
 
1097
1122
  Create a durable workflow container. Starts disabled with no version; publish a version to add code.
@@ -1199,6 +1224,40 @@ const result = await zapier.enableWorkflow({
1199
1224
  });
1200
1225
  ```
1201
1226
 
1227
+ #### `getDurableRun` 🧪 _experimental_
1228
+
1229
+ Get the full state of a run-once durable run, including its operations journal
1230
+
1231
+ **Parameters:**
1232
+
1233
+ | Name | Type | Required | Default | Possible Values | Description |
1234
+ | --------- | -------- | -------- | ------- | --------------- | -------------- |
1235
+ | `options` | `object` | ✅ | — | — | |
1236
+ | ​ ↳ `run` | `string` | ✅ | — | — | Durable run ID |
1237
+
1238
+ **Returns:** `Promise<DurableRunItem>`
1239
+
1240
+ | Name | Type | Required | Possible Values | Description |
1241
+ | ---------------- | --------- | -------- | ----------------------------------------------------------- | ------------------------------------------------------------------------------------------------------- |
1242
+ | `data` | `object` | ✅ | — | |
1243
+ | ​ ↳ `id` | `string` | ✅ | — | Run ID (UUID) |
1244
+ | ​ ↳ `status` | `string` | ✅ | `initialized`, `started`, `finished`, `failed`, `cancelled` | Run lifecycle status. `finished` / `failed` / `cancelled` are terminal. |
1245
+ | ​ ↳ `input` | `string` | ✅ | — | Input data passed to the run |
1246
+ | ​ ↳ `output` | `string` | ✅ | — | Return value, present when status is `finished` |
1247
+ | ​ ↳ `error` | `object` | ✅ | — | Structured error details when the run failed (null otherwise) |
1248
+ | ​ ↳ `execution` | `object` | ✅ | — | Linked execution, including the operations journal. Null while the run is still in `initialized` state. |
1249
+ | ​ ↳ `is_private` | `boolean` | ✅ | — | When true, the run is visible only to the creating user; otherwise visible across the account. |
1250
+ | ​ ↳ `created_at` | `string` | ✅ | — | When the run was created (ISO-8601) |
1251
+ | ​ ↳ `updated_at` | `string` | ✅ | — | When the run was last updated (ISO-8601) |
1252
+
1253
+ **Example:**
1254
+
1255
+ ```typescript
1256
+ const { data: durableRun } = await zapier.getDurableRun({
1257
+ run: "example-run",
1258
+ });
1259
+ ```
1260
+
1202
1261
  #### `getWorkflow` 🧪 _experimental_
1203
1262
 
1204
1263
  Get a durable workflow with its current version details and trigger claim status
@@ -1239,6 +1298,52 @@ const { data: workflow } = await zapier.getWorkflow({
1239
1298
  });
1240
1299
  ```
1241
1300
 
1301
+ #### `listDurableRuns` 🧪 _experimental_
1302
+
1303
+ List run-once durable runs for the authenticated account, newest first
1304
+
1305
+ **Parameters:**
1306
+
1307
+ | Name | Type | Required | Default | Possible Values | Description |
1308
+ | -------------- | -------- | -------- | ------- | --------------- | ---------------------------------------------- |
1309
+ | `options` | `object` | ✅ | — | — | |
1310
+ | ​ ↳ `pageSize` | `number` | ❌ | — | — | Number of runs per page (max 100) |
1311
+ | ​ ↳ `cursor` | `string` | ❌ | — | — | Pagination cursor |
1312
+ | ​ ↳ `maxItems` | `number` | ❌ | — | — | Maximum total items to return across all pages |
1313
+
1314
+ **Returns:** `Promise<PaginatedResult<DurableRunItem>>`
1315
+
1316
+ | Name | Type | Required | Possible Values | Description |
1317
+ | ------------------ | ---------- | -------- | ----------------------------------------------------------- | ---------------------------------------------------------------------------------------------- |
1318
+ | `data[]` | `object[]` | ✅ | — | |
1319
+ | ​ ↳ `id` | `string` | ✅ | — | Run ID (UUID) |
1320
+ | ​ ↳ `status` | `string` | ✅ | `initialized`, `started`, `finished`, `failed`, `cancelled` | Run lifecycle status. `finished` / `failed` / `cancelled` are terminal. |
1321
+ | ​ ↳ `input` | `string` | ✅ | — | Input data passed to the run |
1322
+ | ​ ↳ `output` | `string` | ✅ | — | Return value, present when status is `finished` |
1323
+ | ​ ↳ `error` | `object` | ✅ | — | Structured error details when the run failed (null otherwise) |
1324
+ | ​ ↳ `execution_id` | `string` | ✅ | — | Linked execution ID. Null until the run leaves the `initialized` state. |
1325
+ | ​ ↳ `is_private` | `boolean` | ✅ | — | When true, the run is visible only to the creating user; otherwise visible across the account. |
1326
+ | ​ ↳ `created_at` | `string` | ✅ | — | When the run was created (ISO-8601) |
1327
+ | ​ ↳ `updated_at` | `string` | ✅ | — | When the run was last updated (ISO-8601) |
1328
+ | `nextCursor` | `string` | ❌ | — | Cursor for the next page; omitted when there are no more pages |
1329
+
1330
+ **Example:**
1331
+
1332
+ ```typescript
1333
+ // Get first page and a cursor for the second page
1334
+ const { data: durableRuns, nextCursor } = await zapier.listDurableRuns();
1335
+
1336
+ // Or iterate over all pages
1337
+ for await (const page of zapier.listDurableRuns()) {
1338
+ // Do something with each page
1339
+ }
1340
+
1341
+ // Or iterate over individual items across all pages
1342
+ for await (const durableRun of zapier.listDurableRuns().items()) {
1343
+ // Do something with each durableRun
1344
+ }
1345
+ ```
1346
+
1242
1347
  #### `listWorkflows` 🧪 _experimental_
1243
1348
 
1244
1349
  List all active durable workflows for the authenticated account
@@ -1284,6 +1389,41 @@ for await (const workflow of zapier.listWorkflows().items()) {
1284
1389
  }
1285
1390
  ```
1286
1391
 
1392
+ #### `runDurable` 🧪 _experimental_
1393
+
1394
+ 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.
1395
+
1396
+ **Parameters:**
1397
+
1398
+ | Name | Type | Required | Default | Possible Values | Description |
1399
+ | ---------------------------- | --------- | -------- | ------- | --------------- | --------------------------------------------------------------------------------------------------------------- |
1400
+ | `options` | `object` | ✅ | — | — | |
1401
+ | ​ ↳ `source_files` | `object` | ✅ | — | — | Source files keyed by filename → contents |
1402
+ | ​ ↳ `input` | `string` | ❌ | — | — | Input data passed to the run |
1403
+ | ​ ↳ `dependencies` | `object` | ❌ | — | — | Optional npm package dependencies |
1404
+ | ​ ↳ `zapier_durable_version` | `string` | ❌ | — | — | Exact semver of @zapier/zapier-durable to use (e.g. "1.2.3"). Defaults to server-configured version if omitted. |
1405
+ | ​ ↳ `connections` | `object` | ❌ | — | — | Named connection aliases. Maps alias names to Zapier connection IDs. |
1406
+ | ​ ↳ `app_versions` | `object` | ❌ | — | — | Pinned app versions. Maps app keys (slugs) to implementation names and versions. |
1407
+ | ​ ↳ `private` | `boolean` | ❌ | — | — | Only the creating user can see the run (default false) |
1408
+
1409
+ **Returns:** `Promise<DurableRunItem>`
1410
+
1411
+ | Name | Type | Required | Possible Values | Description |
1412
+ | ---------------- | --------- | -------- | --------------- | ----------------------------------------------------------------------------------------------------------------------------------------- |
1413
+ | `data` | `object` | ✅ | — | |
1414
+ | ​ ↳ `id` | `string` | ✅ | — | Run ID (UUID) — server-generated, time-sortable |
1415
+ | ​ ↳ `status` | `string` | ✅ | `initialized` | Always `initialized` on creation. Poll via getDurableRun to observe the run advancing to `started` / `finished` / `failed` / `cancelled`. |
1416
+ | ​ ↳ `is_private` | `boolean` | ✅ | — | When true, the run is visible only to the creating user; otherwise visible across the account. |
1417
+ | ​ ↳ `created_at` | `string` | ✅ | — | When the run was created (ISO-8601) |
1418
+
1419
+ **Example:**
1420
+
1421
+ ```typescript
1422
+ const result = await zapier.runDurable({
1423
+ source_files: {},
1424
+ });
1425
+ ```
1426
+
1287
1427
  #### `updateWorkflow` 🧪 _experimental_
1288
1428
 
1289
1429
  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.61.0" : void 0) || "unknown";
2892
+ var SDK_VERSION = (typeof process !== "undefined" && process.env ? "0.63.0" : void 0) || "unknown";
2893
2893
 
2894
2894
  // src/utils/open-url.ts
2895
2895
  var nodePrefix = "node:";
@@ -4286,6 +4286,21 @@ var workflowIdResolver = {
4286
4286
  })
4287
4287
  };
4288
4288
 
4289
+ // src/resolvers/durableRunId.ts
4290
+ var durableRunIdResolver = {
4291
+ type: "dynamic",
4292
+ fetch: async (sdk) => toIterable(sdk.listDurableRuns()),
4293
+ prompt: (runs) => ({
4294
+ type: "list",
4295
+ name: "run",
4296
+ message: "Select a run:",
4297
+ choices: runs.map((run) => ({
4298
+ name: `${run.id} \u2014 ${run.status}`,
4299
+ value: run.id
4300
+ }))
4301
+ })
4302
+ };
4303
+
4289
4304
  // src/resolvers/triggerMessages.ts
4290
4305
  var triggerMessagesResolver = {
4291
4306
  type: "dynamic",
@@ -10824,6 +10839,305 @@ var deleteWorkflowPlugin = definePlugin(
10824
10839
  }
10825
10840
  })
10826
10841
  );
10842
+ var RunStatusSchema = zod.z.enum(["initialized", "started", "finished", "failed", "cancelled"]).describe(
10843
+ "Run lifecycle status. `finished` / `failed` / `cancelled` are terminal."
10844
+ );
10845
+ var RunErrorSchema = zod.z.object({
10846
+ code: zod.z.string().describe("Machine-readable error category"),
10847
+ message: zod.z.string().describe("Human-readable error summary")
10848
+ }).passthrough().describe(
10849
+ "Structured run error. Always carries `code` and `message`; additional keys may appear depending on the error type."
10850
+ );
10851
+ var RunItemSchema = zod.z.object({
10852
+ id: zod.z.string().describe("Run ID (UUID)"),
10853
+ status: RunStatusSchema,
10854
+ input: zod.z.unknown().describe("Input data passed to the run"),
10855
+ output: zod.z.unknown().nullable().describe("Return value, present when status is `finished`"),
10856
+ error: RunErrorSchema.nullable().describe(
10857
+ "Structured error details when the run failed (null otherwise)"
10858
+ ),
10859
+ execution_id: zod.z.string().nullable().describe(
10860
+ "Linked execution ID. Null until the run leaves the `initialized` state."
10861
+ ),
10862
+ is_private: zod.z.boolean().describe(
10863
+ "When true, the run is visible only to the creating user; otherwise visible across the account."
10864
+ ),
10865
+ created_at: zod.z.string().describe("When the run was created (ISO-8601)"),
10866
+ updated_at: zod.z.string().describe("When the run was last updated (ISO-8601)")
10867
+ });
10868
+ var ListDurableRunsOptionsSchema = zod.z.object({
10869
+ pageSize: zod.z.number().min(1).max(100).optional().describe("Number of runs per page (max 100)"),
10870
+ cursor: zod.z.string().optional().describe("Pagination cursor"),
10871
+ maxItems: zod.z.number().min(1).optional().describe("Maximum total items to return across all pages")
10872
+ }).describe(
10873
+ "List run-once durable runs for the authenticated account, newest first"
10874
+ );
10875
+ zod.z.object({
10876
+ results: zod.z.array(RunItemSchema),
10877
+ meta: zod.z.object({
10878
+ limit: zod.z.number(),
10879
+ cursor: zod.z.string().nullable().optional(),
10880
+ next_cursor: zod.z.string().nullable().optional()
10881
+ }),
10882
+ links: zod.z.object({
10883
+ next: zod.z.string().nullable().optional()
10884
+ }).optional()
10885
+ });
10886
+
10887
+ // src/plugins/codeSubstrate/listDurableRuns/index.ts
10888
+ var listDurableRunsPlugin = definePlugin(
10889
+ (sdk) => createPaginatedPluginMethod(sdk, {
10890
+ ...codeSubstrateDefaults,
10891
+ name: "listDurableRuns",
10892
+ type: "list",
10893
+ itemType: "DurableRun",
10894
+ inputSchema: ListDurableRunsOptionsSchema,
10895
+ outputSchema: RunItemSchema,
10896
+ defaultPageSize: DEFAULT_PAGE_SIZE,
10897
+ handler: async ({ sdk: sdk2, options }) => {
10898
+ const searchParams = {};
10899
+ if (options.pageSize !== void 0) {
10900
+ searchParams.limit = options.pageSize.toString();
10901
+ }
10902
+ if (options.cursor) {
10903
+ searchParams.cursor = options.cursor;
10904
+ }
10905
+ const response = await sdk2.context.api.get(
10906
+ "/sdkdurableapi/api/v0/runs",
10907
+ { searchParams, authRequired: true }
10908
+ );
10909
+ return {
10910
+ data: response.results,
10911
+ nextCursor: response.meta.next_cursor ?? void 0
10912
+ };
10913
+ }
10914
+ })
10915
+ );
10916
+ var OperationTypeSchema = zod.z.enum(["step", "wait", "callback"]).describe(
10917
+ "Operation kind: `step` is a journaled function call; `wait` is a time-based suspension; `callback` is a wait on an external callback."
10918
+ );
10919
+ var OperationStatusSchema = zod.z.enum(["pending", "completed", "failed", "exhausted"]).describe(
10920
+ "Operation lifecycle status. `exhausted` means retries were exceeded."
10921
+ );
10922
+ var OperationSchema = zod.z.object({
10923
+ id: zod.z.string().describe("Operation ID (UUID)"),
10924
+ execution_id: zod.z.string().describe("Parent execution ID"),
10925
+ name: zod.z.string().describe("Operation name as declared by the workflow author"),
10926
+ type: OperationTypeSchema,
10927
+ status: OperationStatusSchema,
10928
+ result: zod.z.unknown().optional().describe("Result value when the operation completed"),
10929
+ error: zod.z.unknown().optional().describe("Error payload when the operation failed"),
10930
+ retry_count: zod.z.number().describe("Number of retry attempts so far"),
10931
+ max_attempts: zod.z.number().optional().describe(
10932
+ "Cap on total attempts for this operation. Absent if no cap applies."
10933
+ ),
10934
+ next_retry_at: zod.z.string().optional().describe("When the next retry will be attempted (ISO-8601)"),
10935
+ resume_at: zod.z.string().optional().describe(
10936
+ "When a `wait` operation resumes (ISO-8601). Set only for type=wait."
10937
+ ),
10938
+ callback_token: zod.z.string().nullable().optional().describe(
10939
+ "Token for delivering a callback. Set only for type=callback; null until the callback URL is materialized."
10940
+ ),
10941
+ payload_schema: zod.z.unknown().optional().describe("JSON Schema describing the expected callback payload"),
10942
+ payload: zod.z.unknown().optional().describe("Payload delivered to a callback operation, when received"),
10943
+ expires_at: zod.z.string().optional().describe("When a callback or wait operation expires (ISO-8601)"),
10944
+ completed_at: zod.z.string().optional().describe("When the operation reached a terminal state (ISO-8601)"),
10945
+ created_at: zod.z.string().describe("When the operation was created (ISO-8601)")
10946
+ });
10947
+ var ExecutionStatusSchema = zod.z.enum(["running", "waiting", "completed", "failed"]).describe(
10948
+ "Execution lifecycle status. `waiting` means blocked on a wait or callback operation."
10949
+ );
10950
+ var ExecutionSummarySchema = zod.z.object({
10951
+ id: zod.z.string().describe("Execution ID (UUID)"),
10952
+ name: zod.z.string().describe("Durable function name"),
10953
+ status: ExecutionStatusSchema,
10954
+ input: zod.z.unknown().describe("Input passed when the execution was created"),
10955
+ output: zod.z.unknown().optional().describe("Return value when status is `completed`"),
10956
+ error: zod.z.unknown().optional().describe("Error details when status is `failed`"),
10957
+ metadata: zod.z.record(zod.z.string(), zod.z.unknown()).optional().describe(
10958
+ "Caller-supplied tags (Zap ID, Step ID, Agent ID, etc.) carried alongside the execution"
10959
+ ),
10960
+ created_at: zod.z.string().describe("When the execution was created (ISO-8601)"),
10961
+ summary: zod.z.object({
10962
+ total_attempts: zod.z.number().describe(
10963
+ "Total ticks attempted against this execution across all retries"
10964
+ ),
10965
+ last_error: zod.z.object({
10966
+ code: zod.z.string().describe("Machine-readable error category"),
10967
+ title: zod.z.string().describe("Short error label"),
10968
+ detail: zod.z.string().nullable().optional().describe("Longer-form error detail, when provided")
10969
+ }).passthrough().optional().describe("The most recent error, if the execution has failed once")
10970
+ }).passthrough().nullable().optional().describe(
10971
+ "Aggregate health summary. Null when no attempts have been recorded yet."
10972
+ ),
10973
+ operations: zod.z.array(OperationSchema).optional().describe(
10974
+ "Operations journal \u2014 append-only record of every step/wait/callback the execution made"
10975
+ )
10976
+ });
10977
+ var GetDurableRunOptionsSchema = zod.z.object({
10978
+ run: zod.z.string().uuid().describe("Durable run ID")
10979
+ }).describe(
10980
+ "Get the full state of a run-once durable run, including its operations journal"
10981
+ );
10982
+ var GetDurableRunResponseSchema = zod.z.object({
10983
+ id: zod.z.string().describe("Run ID (UUID)"),
10984
+ status: RunStatusSchema,
10985
+ input: zod.z.unknown().describe("Input data passed to the run"),
10986
+ output: zod.z.unknown().nullable().describe("Return value, present when status is `finished`"),
10987
+ error: RunErrorSchema.nullable().describe(
10988
+ "Structured error details when the run failed (null otherwise)"
10989
+ ),
10990
+ execution: ExecutionSummarySchema.nullable().describe(
10991
+ "Linked execution, including the operations journal. Null while the run is still in `initialized` state."
10992
+ ),
10993
+ is_private: zod.z.boolean().describe(
10994
+ "When true, the run is visible only to the creating user; otherwise visible across the account."
10995
+ ),
10996
+ created_at: zod.z.string().describe("When the run was created (ISO-8601)"),
10997
+ updated_at: zod.z.string().describe("When the run was last updated (ISO-8601)")
10998
+ });
10999
+
11000
+ // src/plugins/codeSubstrate/getDurableRun/index.ts
11001
+ var getDurableRunPlugin = definePlugin(
11002
+ (sdk) => createPluginMethod(sdk, {
11003
+ ...codeSubstrateDefaults,
11004
+ name: "getDurableRun",
11005
+ type: "item",
11006
+ itemType: "DurableRun",
11007
+ inputSchema: GetDurableRunOptionsSchema,
11008
+ outputSchema: GetDurableRunResponseSchema,
11009
+ resolvers: { run: durableRunIdResolver },
11010
+ handler: async ({ sdk: sdk2, options }) => {
11011
+ const data = await sdk2.context.api.get(
11012
+ `/sdkdurableapi/api/v0/runs/${encodeURIComponent(options.run)}`,
11013
+ {
11014
+ authRequired: true,
11015
+ resource: { type: "run", id: options.run }
11016
+ }
11017
+ );
11018
+ return { data };
11019
+ }
11020
+ })
11021
+ );
11022
+ var ConnectionMapEntrySchema = zod.z.object({
11023
+ connection_id: zod.z.union([
11024
+ zod.z.string().regex(/^[1-9][0-9]*$/, "must be a positive integer string"),
11025
+ zod.z.string().uuid("must be a UUID"),
11026
+ zod.z.number().int().positive()
11027
+ ]).describe(
11028
+ "Zapier connection ID. Accepts a positive integer (legacy) or a UUID string (newer connections)."
11029
+ )
11030
+ });
11031
+ var AppVersionMapEntrySchema = zod.z.object({
11032
+ implementation_name: zod.z.string().min(1).describe("Zapier app implementation name (e.g. `SlackCLIAPI`)"),
11033
+ version: zod.z.string().optional().describe("Pinned app version (e.g. `1.27.1`). Latest if omitted.")
11034
+ });
11035
+ var RunDurableOptionsSchema = zod.z.object({
11036
+ source_files: zod.z.record(zod.z.string(), zod.z.string()).refine((files) => Object.keys(files).length > 0, {
11037
+ message: "source_files must contain at least one file"
11038
+ }).describe("Source files keyed by filename \u2192 contents"),
11039
+ input: zod.z.unknown().optional().describe("Input data passed to the run"),
11040
+ dependencies: zod.z.record(zod.z.string(), zod.z.string()).optional().describe("Optional npm package dependencies"),
11041
+ zapier_durable_version: zod.z.string().optional().describe(
11042
+ 'Exact semver of @zapier/zapier-durable to use (e.g. "1.2.3"). Defaults to server-configured version if omitted.'
11043
+ ),
11044
+ connections: zod.z.record(zod.z.string(), ConnectionMapEntrySchema).optional().describe(
11045
+ "Named connection aliases. Maps alias names to Zapier connection IDs."
11046
+ ),
11047
+ app_versions: zod.z.record(zod.z.string(), AppVersionMapEntrySchema).optional().describe(
11048
+ "Pinned app versions. Maps app keys (slugs) to implementation names and versions."
11049
+ ),
11050
+ private: zod.z.boolean().optional().describe("Only the creating user can see the run (default false)")
11051
+ }).describe(
11052
+ "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."
11053
+ );
11054
+ var RunDurableResponseSchema = zod.z.object({
11055
+ id: zod.z.string().describe("Run ID (UUID) \u2014 server-generated, time-sortable"),
11056
+ status: zod.z.literal("initialized").describe(
11057
+ "Always `initialized` on creation. Poll via getDurableRun to observe the run advancing to `started` / `finished` / `failed` / `cancelled`."
11058
+ ),
11059
+ is_private: zod.z.boolean().describe(
11060
+ "When true, the run is visible only to the creating user; otherwise visible across the account."
11061
+ ),
11062
+ created_at: zod.z.string().describe("When the run was created (ISO-8601)")
11063
+ });
11064
+
11065
+ // src/plugins/codeSubstrate/runDurable/index.ts
11066
+ var runDurablePlugin = definePlugin(
11067
+ (sdk) => createPluginMethod(sdk, {
11068
+ ...codeSubstrateDefaults,
11069
+ name: "runDurable",
11070
+ type: "create",
11071
+ itemType: "DurableRun",
11072
+ inputSchema: RunDurableOptionsSchema,
11073
+ outputSchema: RunDurableResponseSchema,
11074
+ handler: async ({ sdk: sdk2, options }) => {
11075
+ const body = {
11076
+ source_files: options.source_files
11077
+ };
11078
+ if (options.input !== void 0) {
11079
+ body.input = options.input;
11080
+ }
11081
+ if (options.dependencies !== void 0) {
11082
+ body.dependencies = options.dependencies;
11083
+ }
11084
+ if (options.zapier_durable_version !== void 0) {
11085
+ body.zapier_durable_version = options.zapier_durable_version;
11086
+ }
11087
+ if (options.connections !== void 0) {
11088
+ body.connections = options.connections;
11089
+ }
11090
+ if (options.app_versions !== void 0) {
11091
+ body.app_versions = options.app_versions;
11092
+ }
11093
+ if (options.private !== void 0) {
11094
+ body.is_private = options.private;
11095
+ }
11096
+ const data = await sdk2.context.api.post(
11097
+ "/sdkdurableapi/api/v0/runs",
11098
+ body,
11099
+ { authRequired: true }
11100
+ );
11101
+ return { data };
11102
+ }
11103
+ })
11104
+ );
11105
+ var CancelDurableRunOptionsSchema = zod.z.object({
11106
+ run: zod.z.string().uuid().describe("Durable run ID")
11107
+ }).describe(
11108
+ "Cancel a run-once durable run in initialized or started status. Returns 409 if the run is already terminal."
11109
+ );
11110
+ zod.z.object({
11111
+ id: zod.z.string().describe("Run ID that was targeted"),
11112
+ status: zod.z.literal("cancelled").describe(
11113
+ "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."
11114
+ )
11115
+ });
11116
+
11117
+ // src/plugins/codeSubstrate/cancelDurableRun/index.ts
11118
+ var cancelDurableRunPlugin = definePlugin(
11119
+ (sdk) => createPluginMethod(sdk, {
11120
+ ...codeSubstrateDefaults,
11121
+ name: "cancelDurableRun",
11122
+ type: "update",
11123
+ itemType: "DurableRun",
11124
+ inputSchema: CancelDurableRunOptionsSchema,
11125
+ resolvers: { run: durableRunIdResolver },
11126
+ handler: async ({ sdk: sdk2, options }) => {
11127
+ await sdk2.context.api.post(
11128
+ `/sdkdurableapi/api/v0/runs/${encodeURIComponent(options.run)}/cancel`,
11129
+ void 0,
11130
+ {
11131
+ authRequired: true,
11132
+ resource: { type: "run", id: options.run }
11133
+ }
11134
+ );
11135
+ return {
11136
+ data: { id: options.run, status: "cancelled" }
11137
+ };
11138
+ }
11139
+ })
11140
+ );
10827
11141
 
10828
11142
  // src/utils/batch-utils.ts
10829
11143
  var DEFAULT_CONCURRENCY = 10;
@@ -10983,7 +11297,7 @@ var registryPlugin = definePlugin((_sdk) => {
10983
11297
 
10984
11298
  // src/experimental.ts
10985
11299
  function createZapierSdk2(options = {}) {
10986
- 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(appsPlugin).addPlugin(getProfilePlugin);
11300
+ 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(appsPlugin).addPlugin(getProfilePlugin);
10987
11301
  }
10988
11302
 
10989
11303
  exports.ActionKeyPropertySchema = ActionKeyPropertySchema;
@@ -11097,6 +11411,7 @@ exports.deleteClientCredentialsPlugin = deleteClientCredentialsPlugin;
11097
11411
  exports.deleteTableFieldsPlugin = deleteTableFieldsPlugin;
11098
11412
  exports.deleteTablePlugin = deleteTablePlugin;
11099
11413
  exports.deleteTableRecordsPlugin = deleteTableRecordsPlugin;
11414
+ exports.durableRunIdResolver = durableRunIdResolver;
11100
11415
  exports.eventEmissionPlugin = eventEmissionPlugin;
11101
11416
  exports.fetchPlugin = fetchPlugin;
11102
11417
  exports.findFirstConnectionPlugin = findFirstConnectionPlugin;