@zapier/zapier-sdk 0.109.1 → 0.110.1

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.
@@ -1,5 +1,5 @@
1
- import { DEFAULT_PAGE_SIZE, apiPluginRef, workflowIdResolver, extractErrorDetail, ZapierApiError, durableRunIdResolver, ZapierConflictError, workflowVersionIdResolver, workflowDraftIdResolver, workflowRunIdResolver, zapierSdkPlugin, ZapierValidationError, ZapierConfigurationError, zapierCoreOptions, SDK_OPTIONS_ID } from './chunk-6TOSNLPZ.mjs';
2
- export { ACTION_RUNS_PATH, API_ID, ActionKeyPropertySchema, ActionPropertySchema, ActionTimeoutMillisecondsPropertySchema, ActionTimeoutSecondsPropertySchema, ActionTypePropertySchema, AppKeyPropertySchema, AppPropertySchema, AppsPropertySchema, AuthMechanism, AuthenticationIdPropertySchema, BaseSdkOptionsSchema, CONNECTIONS_ID, CONTEXT, CONTEXT_CACHE_MAX_SIZE, CONTEXT_CACHE_TTL_MILLISECONDS, CORE_ERROR_SYMBOL, CORE_OPTIONS_ID, CORE_SIGNAL_SYMBOL, ClientCredentialsObjectSchema, ConnectionEntrySchema, ConnectionIdPropertySchema, ConnectionPropertySchema, ConnectionsMapSchema, ConnectionsPropertySchema, CoreCancelledSignal, CoreDisposeError, CoreErrorCode, CoreSignal, CredentialsFunctionSchema, CredentialsObjectSchema, CredentialsSchema, DEFAULT_ACTION_TIMEOUT_MILLISECONDS, DEFAULT_APPROVAL_TIMEOUT_MILLISECONDS, DEFAULT_CONFIG_PATH, DEFAULT_MAX_APPROVAL_RETRIES, DEFAULT_PAGE_SIZE, DEPRECATION_NOTICE_EVENT, DebugPropertySchema, DrainTriggerInboxSchema, EVENT_EMISSION_ID, FieldsPropertySchema, InputFieldPropertySchema, InputsPropertySchema, LeaseLimitPropertySchema, LeasePropertySchema, LeaseSecondsPropertySchema, LimitPropertySchema, MANIFEST_ID, MAX_CONCURRENCY_LIMIT, MAX_PAGE_LIMIT, OffsetPropertySchema, OutputPropertySchema, ParamsPropertySchema, PkceCredentialsObjectSchema, RESOLVE_CREDENTIALS_ID, RecordPropertySchema, RecordsPropertySchema, RelayFetchSchema, RelayRequestSchema, ResolvedCredentialsSchema, SDK_OPTIONS_ID, TablePropertySchema, TablesPropertySchema, TriggerInboxKeyPropertySchema, TriggerInboxNamePropertySchema, TriggerInboxPropertySchema, WatchTriggerInboxSchema, ZAPIER_BASE_URL, ZAPIER_MAX_CONCURRENT_REQUESTS, ZAPIER_MAX_NETWORK_RETRIES, ZAPIER_MAX_NETWORK_RETRY_DELAY_MILLISECONDS, ZapierAbortDrainSignal, ZapierActionError, ZapierApiError, ZapierAppNotFoundError, ZapierApprovalError, ZapierAuthenticationError, ZapierBundleError, ZapierConfigurationError, ZapierConflictError, ZapierError, ZapierNotFoundError, ZapierRateLimitError, ZapierRelayError, ZapierReleaseTriggerMessageSignal, ZapierResourceNotFoundError, ZapierSignal, ZapierTimeoutError, ZapierUnknownError, ZapierValidationError, actionKeyResolver, actionTypeResolver, addPlugin, apiPlugin, apiPluginRef, appKeyResolver, appsPlugin, batch, buildApplicationLifecycleEvent, buildCapabilityMessage, buildErrorEvent, buildErrorEventWithContext, buildMethodCalledEvent, cleanupEventListeners, clearTokenCache, clientCredentialsNameResolver, clientIdResolver, composePlugins, connectionIdGenericResolver, connectionIdResolver, connectionsPlugin, connectionsPluginRef, createActionRunPlugin, createBaseEvent, createClientCredentialsPlugin, createController, createCorePlugin, createFunction, createMemoryCache, createPaginatedFunction, createPaginatedPluginMethod, createPluginMethod, createPluginStack, createSdk, createTableFieldsPlugin, createTablePlugin, createTableRecordsPlugin, createZapierApi, createZapierSdkWithoutRegistry, declareMethod, declareOptionalProperty, declarePlugin, declareProperty, defineFormatter, defineLegacyMerge, defineMethod, defineMethodOverride, defineOverride, definePlugin, defineProperty, defineResolver, deleteClientCredentialsPlugin, deleteTableFieldsPlugin, deleteTablePlugin, deleteTableRecordsPlugin, disposeSdk, durableRunIdResolver, eventEmissionHookPlugin, eventEmissionPlugin, eventEmissionPluginRef, fetchPlugin, findFirstConnectionPlugin, findManifestEntry, findUniqueConnectionPlugin, formatErrorMessage, fromFunctionPlugin, generateEventId, getActionInputFieldsSchemaPlugin, getActionPlugin, getActionRunPlugin, getAgent, getAppPlugin, getBaseUrlFromCredentials, getCallerContext, getCiPlatform, getClientIdFromCredentials, getConnectionPlugin, getContext, getCoreErrorCause, getCoreErrorCode, getCpuTime, getCurrentTimestamp, getMemoryUsage, getNegatable, getOrCreateApiClient, getOsInfo, getPlatformVersions, getPreferredManifestEntryKey, getProfilePlugin, getRegistryPlugin, getReleaseId, getTablePlugin, getTableRecordPlugin, getTokenFromCliLogin, getTtyContext, getZapierApprovalMode, getZapierCausationId, getZapierCorrelationId, getZapierDefaultApprovalMode, getZapierOpenAutoModeApprovalsInBrowser, getZapierSdkService, injectCliLogin, inputFieldKeyResolver, inputsAllOptionalResolver, inputsResolver, invalidateCachedToken, invalidateCredentialsToken, isCi, isCliLoginAvailable, isClientCredentials, isCoreCancelledSignal, isCoreError, isCoreSignal, isCredentialsFunction, isCredentialsObject, isPermanentHttpError, isPkceCredentials, isPositional, isZapierAbortDrainSignal, isZapierActionError, isZapierAppNotFoundError, isZapierApprovalError, isZapierAuthenticationError, isZapierBundleError, isZapierConflictError, isZapierError, isZapierNotFoundError, isZapierRateLimitError, isZapierReleaseTriggerMessageSignal, isZapierResourceNotFoundError, isZapierSignal, isZapierTimeoutError, isZapierValidationError, listActionInputFieldChoicesPlugin, listActionInputFieldsPlugin, listActionsPlugin, listAppsPlugin, listClientCredentialsPlugin, listConnectionsPlugin, listTableFieldsPlugin, listTableRecordsPlugin, listTablesPlugin, logDeprecation, manifestPlugin, manifestPluginRef, omitExports, operationAnnotatorPlugin, parseConcurrencyEnvVar, readManifestFromFile, registryPlugin, requestPlugin, resetDeprecationWarnings, resolveAuth, resolveAuthToken, resolveCredentials, resolveCredentialsFromEnv, resolveCredentialsPlugin, resolveCredentialsPluginRef, resolvePlugin, runActionPlugin, runInMethodScope, runWithCallerContext, runWithTelemetryContext, sdkOptionsPluginRef, selectExports, tableFieldIdsResolver, tableFieldsResolver, tableFiltersResolver, tableIdResolver, tableNameResolver, tableRecordIdResolver, tableRecordIdsResolver, tableRecordsResolver, tableSortResolver, tableUpdateRecordsResolver, toSnakeCase, toTitleCase, triggerInboxResolver, triggerMessagesResolver, updateTableRecordsPlugin, workflowDraftIdResolver, workflowIdResolver, workflowRunIdResolver, workflowVersionIdResolver, zapierAdaptError, zapierCoreOptions, zapierSdkPlugin } from './chunk-6TOSNLPZ.mjs';
1
+ import { DEFAULT_PAGE_SIZE, apiPluginRef, workflowIdResolver, extractErrorDetail, ZapierApiError, durableRunIdResolver, ZapierConflictError, workflowVersionIdResolver, workflowDraftIdResolver, workflowDraftRevisionResolver, workflowRunIdResolver, zapierSdkPlugin, ZapierValidationError, ZapierConfigurationError, zapierCoreOptions, SDK_OPTIONS_ID } from './chunk-IRHF55YK.mjs';
2
+ export { ACTION_RUNS_PATH, API_ID, ActionKeyPropertySchema, ActionPropertySchema, ActionTimeoutMillisecondsPropertySchema, ActionTimeoutSecondsPropertySchema, ActionTypePropertySchema, AppKeyPropertySchema, AppPropertySchema, AppsPropertySchema, AuthMechanism, AuthenticationIdPropertySchema, BaseSdkOptionsSchema, CONNECTIONS_ID, CONTEXT, CONTEXT_CACHE_MAX_SIZE, CONTEXT_CACHE_TTL_MILLISECONDS, CORE_ERROR_SYMBOL, CORE_OPTIONS_ID, CORE_SIGNAL_SYMBOL, ClientCredentialsObjectSchema, ConnectionEntrySchema, ConnectionIdPropertySchema, ConnectionPropertySchema, ConnectionsMapSchema, ConnectionsPropertySchema, CoreCancelledSignal, CoreDisposeError, CoreErrorCode, CoreSignal, CredentialsFunctionSchema, CredentialsObjectSchema, CredentialsSchema, DEFAULT_ACTION_TIMEOUT_MILLISECONDS, DEFAULT_APPROVAL_TIMEOUT_MILLISECONDS, DEFAULT_CONFIG_PATH, DEFAULT_MAX_APPROVAL_RETRIES, DEFAULT_PAGE_SIZE, DEPRECATION_NOTICE_EVENT, DebugPropertySchema, DrainTriggerInboxSchema, EVENT_EMISSION_ID, FieldsPropertySchema, InputFieldPropertySchema, InputsPropertySchema, LeaseLimitPropertySchema, LeasePropertySchema, LeaseSecondsPropertySchema, LimitPropertySchema, MANIFEST_ID, MAX_CONCURRENCY_LIMIT, MAX_PAGE_LIMIT, OffsetPropertySchema, OutputPropertySchema, ParamsPropertySchema, PkceCredentialsObjectSchema, RESOLVE_CREDENTIALS_ID, RecordPropertySchema, RecordsPropertySchema, RelayFetchSchema, RelayRequestSchema, ResolvedCredentialsSchema, SDK_OPTIONS_ID, TablePropertySchema, TablesPropertySchema, TriggerInboxKeyPropertySchema, TriggerInboxNamePropertySchema, TriggerInboxPropertySchema, WatchTriggerInboxSchema, ZAPIER_BASE_URL, ZAPIER_MAX_CONCURRENT_REQUESTS, ZAPIER_MAX_NETWORK_RETRIES, ZAPIER_MAX_NETWORK_RETRY_DELAY_MILLISECONDS, ZapierAbortDrainSignal, ZapierActionError, ZapierApiError, ZapierAppNotFoundError, ZapierApprovalError, ZapierAuthenticationError, ZapierBundleError, ZapierConfigurationError, ZapierConflictError, ZapierError, ZapierNotFoundError, ZapierRateLimitError, ZapierRelayError, ZapierReleaseTriggerMessageSignal, ZapierResourceNotFoundError, ZapierSignal, ZapierTimeoutError, ZapierUnknownError, ZapierValidationError, actionKeyResolver, actionTypeResolver, addPlugin, apiPlugin, apiPluginRef, appKeyResolver, appsPlugin, batch, buildApplicationLifecycleEvent, buildCapabilityMessage, buildErrorEvent, buildErrorEventWithContext, buildMethodCalledEvent, cleanupEventListeners, clearTokenCache, clientCredentialsNameResolver, clientIdResolver, composePlugins, connectionIdGenericResolver, connectionIdResolver, connectionsPlugin, connectionsPluginRef, createActionRunPlugin, createBaseEvent, createClientCredentialsPlugin, createController, createCorePlugin, createFunction, createMemoryCache, createPaginatedFunction, createPaginatedPluginMethod, createPluginMethod, createPluginStack, createSdk, createTableFieldsPlugin, createTablePlugin, createTableRecordsPlugin, createZapierApi, createZapierSdkWithoutRegistry, declareMethod, declareOptionalProperty, declarePlugin, declareProperty, defineFormatter, defineLegacyMerge, defineMethod, defineMethodOverride, defineOverride, definePlugin, defineProperty, defineResolver, deleteClientCredentialsPlugin, deleteTableFieldsPlugin, deleteTablePlugin, deleteTableRecordsPlugin, disposeSdk, durableRunIdResolver, eventEmissionHookPlugin, eventEmissionPlugin, eventEmissionPluginRef, fetchPlugin, findFirstConnectionPlugin, findManifestEntry, findUniqueConnectionPlugin, formatErrorMessage, fromFunctionPlugin, generateEventId, getActionInputFieldsSchemaPlugin, getActionPlugin, getActionRunPlugin, getAgent, getAppPlugin, getBaseUrlFromCredentials, getCallerContext, getCiPlatform, getClientIdFromCredentials, getConnectionPlugin, getContext, getCoreErrorCause, getCoreErrorCode, getCpuTime, getCurrentTimestamp, getMemoryUsage, getNegatable, getOrCreateApiClient, getOsInfo, getPlatformVersions, getPreferredManifestEntryKey, getProfilePlugin, getRegistryPlugin, getReleaseId, getTablePlugin, getTableRecordPlugin, getTokenFromCliLogin, getTtyContext, getZapierApprovalMode, getZapierCausationId, getZapierCorrelationId, getZapierDefaultApprovalMode, getZapierOpenAutoModeApprovalsInBrowser, getZapierSdkService, injectCliLogin, inputFieldKeyResolver, inputsAllOptionalResolver, inputsResolver, invalidateCachedToken, invalidateCredentialsToken, isCi, isCliLoginAvailable, isClientCredentials, isCoreCancelledSignal, isCoreError, isCoreSignal, isCredentialsFunction, isCredentialsObject, isPermanentHttpError, isPkceCredentials, isPositional, isZapierAbortDrainSignal, isZapierActionError, isZapierAppNotFoundError, isZapierApprovalError, isZapierAuthenticationError, isZapierBundleError, isZapierConflictError, isZapierError, isZapierNotFoundError, isZapierRateLimitError, isZapierReleaseTriggerMessageSignal, isZapierResourceNotFoundError, isZapierSignal, isZapierTimeoutError, isZapierValidationError, listActionInputFieldChoicesPlugin, listActionInputFieldsPlugin, listActionsPlugin, listAppsPlugin, listClientCredentialsPlugin, listConnectionsPlugin, listTableFieldsPlugin, listTableRecordsPlugin, listTablesPlugin, logDeprecation, manifestPlugin, manifestPluginRef, omitExports, operationAnnotatorPlugin, parseConcurrencyEnvVar, readManifestFromFile, registryPlugin, requestPlugin, resetDeprecationWarnings, resolveAuth, resolveAuthToken, resolveCredentials, resolveCredentialsFromEnv, resolveCredentialsPlugin, resolveCredentialsPluginRef, resolvePlugin, runActionPlugin, runInMethodScope, runWithCallerContext, runWithTelemetryContext, sdkOptionsPluginRef, selectExports, tableFieldIdsResolver, tableFieldsResolver, tableFiltersResolver, tableIdResolver, tableNameResolver, tableRecordIdResolver, tableRecordIdsResolver, tableRecordsResolver, tableSortResolver, tableUpdateRecordsResolver, toSnakeCase, toTitleCase, triggerInboxResolver, triggerMessagesResolver, updateTableRecordsPlugin, workflowDraftIdResolver, workflowDraftRevisionResolver, workflowIdResolver, workflowRunIdResolver, workflowVersionIdResolver, zapierAdaptError, zapierCoreOptions, zapierSdkPlugin } from './chunk-IRHF55YK.mjs';
3
3
  import './chunk-Y6FXYEAI.mjs';
4
4
  import { defineMethod, openEnum, defineResolver, defineFormatter, definePlugin, createSdk, CORE_OPTIONS_ID } from '@zapier/kitcore';
5
5
  import { z } from 'zod';
@@ -1730,32 +1730,45 @@ var WorkflowRunStatusSchema = z.union([
1730
1730
  ]).describe(
1731
1731
  "Workflow run lifecycle status. `finished` / `failed` / `cancelled` are terminal."
1732
1732
  );
1733
- var WorkflowRunListItemSchema = z.object({
1734
- id: z.string().describe("Workflow run ID (UUID)"),
1735
- trigger_id: z.string().nullable().describe(
1736
- "ID of the trigger that fired this run, if any. Null for runs created without a trigger."
1737
- ),
1733
+ var workflowRunListItemBase = z.object({
1734
+ id: z.string().describe("Workflow run ID (UUIDv7). Unique across live and draft runs."),
1738
1735
  durable_run_id: z.string().nullable().describe(
1739
1736
  "Linked code-substrate-runner run ID. Null until the durable run is created."
1740
1737
  ),
1741
- workflow_version_id: z.string().nullable().describe("Workflow version the run is bound to. Null in rare edge cases."),
1742
1738
  status: WorkflowRunStatusSchema,
1743
1739
  input: z.unknown().describe("Input passed to the run"),
1744
- // `output` is intentionally omitted from list items: workflow-run lists no
1745
- // longer carry the (potentially large/externalized) output payload. Fetch a
1746
- // single run's output via `getWorkflowRun`. Use `status` to know when it's
1747
- // available (`finished`/`failed`).
1748
1740
  error: z.unknown().nullable().describe("Error payload when status is `failed` (null otherwise)"),
1749
1741
  created_at: z.string().describe("When the run was created (ISO-8601)"),
1750
1742
  updated_at: z.string().describe("When the run was last updated (ISO-8601)")
1751
1743
  });
1744
+ var LiveWorkflowRunListItemSchema = workflowRunListItemBase.extend({
1745
+ kind: z.literal("live").describe("A run of a published workflow version."),
1746
+ trigger_id: z.string().nullable().describe(
1747
+ "ID of the trigger that fired this run. Null for runs created without a trigger."
1748
+ ),
1749
+ workflow_version_id: z.string().nullable().describe("Workflow version the run is bound to. Null in rare edge cases.")
1750
+ });
1751
+ var DraftWorkflowRunListItemSchema = workflowRunListItemBase.extend({
1752
+ kind: z.literal("draft").describe("A run launched from a workflow draft via `runWorkflowDraft`."),
1753
+ workflow_draft_id: z.string().nullable().describe(
1754
+ "The draft this run was launched from. Null once that draft has been deleted (the run outlives its draft)."
1755
+ ),
1756
+ draft_revision: z.number().int().describe("The draft's revision at the moment this run was created.")
1757
+ });
1758
+ var WorkflowRunListItemSchema = z.discriminatedUnion("kind", [
1759
+ LiveWorkflowRunListItemSchema,
1760
+ DraftWorkflowRunListItemSchema
1761
+ ]);
1752
1762
  var ListWorkflowRunsOptionsSchema = z.object({
1753
1763
  workflow: z.string().uuid().describe("Durable workflow ID"),
1754
1764
  pageSize: z.number().int().min(1).max(100).optional().describe("Number of runs per page (max 100)"),
1765
+ kind: z.enum(["live", "draft"]).optional().describe(
1766
+ "Return only runs of this kind. Omit for both, interleaved by recency."
1767
+ ),
1755
1768
  cursor: z.string().optional().describe("Pagination cursor"),
1756
1769
  maxItems: z.number().int().min(1).optional().describe("Maximum total runs to return across all pages")
1757
1770
  }).describe(
1758
- "List workflow runs (triggered executions) for a specific deployed workflow, newest first"
1771
+ "List workflow runs for a specific workflow, newest first. Live runs (of published versions) and draft runs share the one list; pass `kind` to narrow it to one."
1759
1772
  );
1760
1773
  var ListWorkflowRunsApiResponseSchema = z.object({
1761
1774
  results: z.array(WorkflowRunListItemSchema),
@@ -1769,7 +1782,91 @@ var ListWorkflowRunsApiResponseSchema = z.object({
1769
1782
  }).optional()
1770
1783
  });
1771
1784
 
1772
- // src/plugins/codeSubstrate/listWorkflowRuns/index.ts
1785
+ // src/plugins/codeSubstrate/runWorkflowDraft/schemas.ts
1786
+ var RunWorkflowDraftOptionsSchema = z.object({
1787
+ workflow: z.string().uuid().describe("Durable workflow ID"),
1788
+ draft: z.string().uuid().describe("Workflow draft ID"),
1789
+ draftRevision: z.number().int().min(0).describe(
1790
+ "The draft revision you intend to run, from the last read of the draft. The server rejects the run with a conflict if the draft has changed since. The upstream API treats this check as optional; the SDK requires it so a test run can never silently execute source the caller has already replaced."
1791
+ ),
1792
+ input: JsonPayloadSchema.optional().describe(
1793
+ "Input data passed to the workflow. Accepts any JSON value, or its JSON-string encoding. Omit for a workflow that takes no input."
1794
+ )
1795
+ }).describe(
1796
+ "Launch a draft test run: execute the draft's current source without publishing it. The draft's payload is snapshotted onto the run at creation, so later edits (or discarding the draft) never change what the run executed. Draft runs are free (not task-charged) and rate limited per user. The run is accepted asynchronously \u2014 it comes back `initialized`; follow it with `getWorkflowRun`, or list it via `listWorkflowRuns` with `kind: \"draft\"`."
1797
+ );
1798
+ var RunWorkflowDraftResponseSchema = z.object({
1799
+ id: z.string().describe("Workflow run ID (UUIDv7). Unique across live and draft runs."),
1800
+ kind: z.literal("draft").describe("A run launched from a workflow draft."),
1801
+ workflow_id: z.string().describe("The workflow this run belongs to"),
1802
+ durable_run_id: z.string().nullable().describe(
1803
+ "Linked code-substrate-runner run ID. Usually still null in this response \u2014 the run is accepted and launched in the background."
1804
+ ),
1805
+ workflow_draft_id: z.string().nullable().describe(
1806
+ "The draft this run was launched from. Becomes null once that draft is deleted \u2014 the run outlives its draft."
1807
+ ),
1808
+ draft_revision: z.number().int().describe("The draft's revision at the moment this run was created."),
1809
+ status: WorkflowRunStatusSchema,
1810
+ input: z.unknown().describe("Input passed to the run"),
1811
+ output: z.unknown().nullable().describe("Return value, present when status is `finished`"),
1812
+ error: z.unknown().nullable().describe("Error payload when status is `failed` (null otherwise)"),
1813
+ created_at: z.string().describe("When the run was created (ISO-8601)"),
1814
+ updated_at: z.string().describe("When the run was last updated (ISO-8601)")
1815
+ });
1816
+
1817
+ // src/plugins/codeSubstrate/runWorkflowDraft/index.ts
1818
+ var runWorkflowDraftPlugin = defineMethod({
1819
+ ...codeSubstrateDefaults,
1820
+ name: "runWorkflowDraft",
1821
+ imports: [apiPluginRef],
1822
+ type: "create",
1823
+ itemType: "WorkflowRun",
1824
+ // The response is the draft variant of the run resource (`kind: "draft"`,
1825
+ // required `workflow_draft_id` / `draft_revision`), not the mixed-kind
1826
+ // `WorkflowRun` item the docs generator derives from itemType.
1827
+ returnType: "RunWorkflowDraftResponse",
1828
+ inputSchema: RunWorkflowDraftOptionsSchema,
1829
+ outputSchema: RunWorkflowDraftResponseSchema,
1830
+ skipOutputValidation: true,
1831
+ output: "item",
1832
+ resolvers: {
1833
+ workflow: workflowIdResolver,
1834
+ draft: workflowDraftIdResolver,
1835
+ draftRevision: workflowDraftRevisionResolver
1836
+ },
1837
+ run: async ({ imports, input }) => {
1838
+ const api = imports.api;
1839
+ const body = {
1840
+ draft_revision: input.draftRevision
1841
+ };
1842
+ if (input.input !== void 0) {
1843
+ body.input = input.input;
1844
+ }
1845
+ const raw = await api.post(
1846
+ `${CODE_SUBSTRATE_WORKFLOWS_API}/workflows/${encodeURIComponent(input.workflow)}/drafts/${encodeURIComponent(input.draft)}/runs`,
1847
+ body,
1848
+ {
1849
+ authRequired: true,
1850
+ resource: { type: "workflow-draft", id: input.draft },
1851
+ // 409 — the draft was edited concurrently (its draft_revision moved
1852
+ // past the caller's). Retryable after re-reading the draft. 429 (the
1853
+ // per-user draft-run rate limit) needs no handling here: the client
1854
+ // retries with backoff and then throws ZapierRateLimitError.
1855
+ customErrorHandler: ({ status, data }) => {
1856
+ if (status === 409) {
1857
+ const detail = extractErrorDetail(data);
1858
+ return new ZapierConflictError(
1859
+ `${detail ?? "Draft run conflict"} \u2014 the draft changed since it was last read. Re-read the draft to get the current draft_revision, then retry the run.`,
1860
+ { statusCode: status, resourceType: "workflow-draft" }
1861
+ );
1862
+ }
1863
+ return void 0;
1864
+ }
1865
+ }
1866
+ );
1867
+ return { data: RunWorkflowDraftResponseSchema.parse(raw) };
1868
+ }
1869
+ });
1773
1870
  var listWorkflowRunsPlugin = defineMethod({
1774
1871
  ...codeSubstrateDefaults,
1775
1872
  name: "listWorkflowRuns",
@@ -1789,6 +1886,9 @@ var listWorkflowRunsPlugin = defineMethod({
1789
1886
  if (input.pageSize !== void 0) {
1790
1887
  searchParams.limit = input.pageSize.toString();
1791
1888
  }
1889
+ if (input.kind !== void 0) {
1890
+ searchParams.kind = input.kind;
1891
+ }
1792
1892
  if (input.cursor) {
1793
1893
  searchParams.cursor = input.cursor;
1794
1894
  }
@@ -1817,15 +1917,14 @@ var GetWorkflowRunOptionsSchema = z.object({
1817
1917
  ),
1818
1918
  run: z.string().uuid().describe("Workflow run ID")
1819
1919
  }).describe(
1820
- "Get the current state of a workflow run (a triggered execution of a deployed workflow)"
1920
+ "Get the current state of a workflow run \u2014 a live run of a published workflow version, or a draft run launched via `runWorkflowDraft` (the `kind` field says which)"
1821
1921
  );
1822
- var GetWorkflowRunResponseSchema = z.object({
1823
- id: z.string().describe("Workflow run ID (UUID)"),
1824
- trigger_id: z.string().nullable().describe("ID of the trigger that fired this run, if any"),
1922
+ var workflowRunBase = z.object({
1923
+ id: z.string().describe("Workflow run ID (UUIDv7). Unique across live and draft runs."),
1924
+ workflow_id: z.string().describe("The workflow this run belongs to"),
1825
1925
  durable_run_id: z.string().nullable().describe(
1826
1926
  "Linked code-substrate-runner run ID. Null until the durable run is created."
1827
1927
  ),
1828
- workflow_version_id: z.string().nullable().describe("Workflow version the run is bound to"),
1829
1928
  status: WorkflowRunStatusSchema,
1830
1929
  input: z.unknown().describe("Input passed to the run"),
1831
1930
  output: z.unknown().nullable().describe("Return value, present when status is `finished`"),
@@ -1833,6 +1932,26 @@ var GetWorkflowRunResponseSchema = z.object({
1833
1932
  created_at: z.string().describe("When the run was created (ISO-8601)"),
1834
1933
  updated_at: z.string().describe("When the run was last updated (ISO-8601)")
1835
1934
  });
1935
+ var LiveWorkflowRunSchema = workflowRunBase.extend({
1936
+ kind: z.literal("live").describe("A run of a published workflow version."),
1937
+ trigger_id: z.string().nullable().describe(
1938
+ "ID of the trigger that fired this run. Null for runs created without a trigger."
1939
+ ),
1940
+ workflow_version_id: z.string().nullable().describe("Workflow version the run is bound to. Null in rare edge cases.")
1941
+ });
1942
+ var DraftWorkflowRunSchema = workflowRunBase.extend({
1943
+ kind: z.literal("draft").describe("A run launched from a workflow draft via `runWorkflowDraft`."),
1944
+ workflow_draft_id: z.string().nullable().describe(
1945
+ "The draft this run was launched from. Null once that draft has been deleted (the run outlives its draft)."
1946
+ ),
1947
+ draft_revision: z.number().int().describe(
1948
+ "The draft's revision at the moment this run was created. Compare against the draft's current `draft_revision` to tell whether the run still reflects the draft as it now stands."
1949
+ )
1950
+ });
1951
+ var GetWorkflowRunResponseSchema = z.discriminatedUnion("kind", [
1952
+ LiveWorkflowRunSchema,
1953
+ DraftWorkflowRunSchema
1954
+ ]);
1836
1955
 
1837
1956
  // src/plugins/codeSubstrate/getWorkflowRun/index.ts
1838
1957
  var getWorkflowRunPlugin = defineMethod({
@@ -3186,6 +3305,7 @@ var zapierExperimentalSdkPlugin = definePlugin({
3186
3305
  updateWorkflowDraftPlugin,
3187
3306
  discardWorkflowDraftPlugin,
3188
3307
  publishWorkflowDraftPlugin,
3308
+ runWorkflowDraftPlugin,
3189
3309
  listWorkflowRunsPlugin,
3190
3310
  getWorkflowRunPlugin,
3191
3311
  listDurableRunsPlugin,