@zapier/zapier-sdk 0.89.0 → 0.90.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.
@@ -1,5 +1,5 @@
1
- import { defineMethod, DEFAULT_PAGE_SIZE, apiPluginRef, workflowIdResolver, openEnum, durableRunIdResolver, defineResolver, workflowVersionIdResolver, workflowDraftIdResolver, workflowRunIdResolver, ZapierApiError, definePlugin, zapierSdkPlugin, ZapierValidationError, createSdk, zapierCoreOptions, CORE_OPTIONS_ID, SDK_OPTIONS_ID } from './chunk-NOPKQ333.mjs';
2
- export { 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, createBaseEvent, createClientCredentialsPlugin, createController, createCorePlugin, createFunction, createMemoryCache, createPaginatedFunction, createPaginatedPluginMethod, createPluginMethod, createPluginStack, createSdk, createTableFieldsPlugin, createTablePlugin, createTableRecordsPlugin, createZapierApi, createZapierSdkWithoutRegistry, declareMethod, declareOptionalProperty, declarePlugin, declareProperty, defineFormatter, defineLegacyMerge, defineMethod, defineMethodOverride, definePlugin, defineProperty, defineResolver, deleteClientCredentialsPlugin, deleteTableFieldsPlugin, deleteTablePlugin, deleteTableRecordsPlugin, disposeSdk, durableRunIdResolver, eventEmissionHookPlugin, eventEmissionPlugin, eventEmissionPluginRef, fetchPlugin, findFirstConnectionPlugin, findManifestEntry, findUniqueConnectionPlugin, formatErrorMessage, fromFunctionPlugin, generateEventId, getActionInputFieldsSchemaPlugin, getActionPlugin, getAgent, getAppPlugin, getBaseUrlFromCredentials, getCallerContext, getCiPlatform, getClientIdFromCredentials, getConnectionPlugin, getContext, getCoreErrorCause, getCoreErrorCode, getCpuTime, getCurrentTimestamp, getMemoryUsage, getOrCreateApiClient, getOsInfo, getPlatformVersions, getPreferredManifestEntryKey, getProfilePlugin, getRegistryPlugin, getReleaseId, getTablePlugin, getTableRecordPlugin, getTokenFromCliLogin, getTtyContext, getZapierApprovalMode, 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-NOPKQ333.mjs';
1
+ import { defineMethod, DEFAULT_PAGE_SIZE, apiPluginRef, workflowIdResolver, openEnum, durableRunIdResolver, defineResolver, workflowVersionIdResolver, workflowDraftIdResolver, extractErrorDetail, ZapierConflictError, workflowRunIdResolver, ZapierApiError, definePlugin, zapierSdkPlugin, ZapierValidationError, createSdk, zapierCoreOptions, CORE_OPTIONS_ID, SDK_OPTIONS_ID } from './chunk-J7Z7UHXP.mjs';
2
+ export { 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, createBaseEvent, createClientCredentialsPlugin, createController, createCorePlugin, createFunction, createMemoryCache, createPaginatedFunction, createPaginatedPluginMethod, createPluginMethod, createPluginStack, createSdk, createTableFieldsPlugin, createTablePlugin, createTableRecordsPlugin, createZapierApi, createZapierSdkWithoutRegistry, declareMethod, declareOptionalProperty, declarePlugin, declareProperty, defineFormatter, defineLegacyMerge, defineMethod, defineMethodOverride, definePlugin, defineProperty, defineResolver, deleteClientCredentialsPlugin, deleteTableFieldsPlugin, deleteTablePlugin, deleteTableRecordsPlugin, disposeSdk, durableRunIdResolver, eventEmissionHookPlugin, eventEmissionPlugin, eventEmissionPluginRef, fetchPlugin, findFirstConnectionPlugin, findManifestEntry, findUniqueConnectionPlugin, formatErrorMessage, fromFunctionPlugin, generateEventId, getActionInputFieldsSchemaPlugin, getActionPlugin, getAgent, getAppPlugin, getBaseUrlFromCredentials, getCallerContext, getCiPlatform, getClientIdFromCredentials, getConnectionPlugin, getContext, getCoreErrorCause, getCoreErrorCode, getCpuTime, getCurrentTimestamp, getMemoryUsage, getOrCreateApiClient, getOsInfo, getPlatformVersions, getPreferredManifestEntryKey, getProfilePlugin, getRegistryPlugin, getReleaseId, getTablePlugin, getTableRecordPlugin, getTokenFromCliLogin, getTtyContext, getZapierApprovalMode, 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-J7Z7UHXP.mjs';
3
3
  import './chunk-Y6FXYEAI.mjs';
4
4
  import { z } from 'zod';
5
5
 
@@ -57,6 +57,41 @@ function toWireConnections(connections) {
57
57
  }
58
58
  return wire;
59
59
  }
60
+ var TriggerConfigSchema = z.object({
61
+ selectedApi: z.string().optional().describe(
62
+ "Zapier app/API identifier (e.g. 'GoogleSheetsAPI'). Required when a trigger is configured."
63
+ ),
64
+ /** @deprecated Use `selectedApi` instead. */
65
+ selected_api: z.string().optional().meta({ deprecated: true }),
66
+ action: z.string().describe("Trigger action key (e.g. 'new_row')"),
67
+ authenticationId: z.string().nullish().describe(
68
+ "Connection ID for the trigger source. Omit or pass null for no-auth triggers (e.g. Schedule by Zapier)."
69
+ ),
70
+ /** @deprecated Use `authenticationId` instead. */
71
+ authentication_id: z.string().nullish().meta({ deprecated: true }),
72
+ params: z.record(z.string(), z.unknown()).optional().describe("Trigger parameters as a JSON object")
73
+ }).describe(
74
+ "Zapier trigger configuration. When set, the workflow subscribes to trigger events."
75
+ );
76
+ function toWireTrigger(trigger) {
77
+ const selectedApi = trigger.selectedApi ?? trigger.selected_api;
78
+ if (selectedApi === void 0) {
79
+ throw new ZapierValidationError("trigger is missing selectedApi");
80
+ }
81
+ const wire = {
82
+ selected_api: selectedApi,
83
+ action: trigger.action
84
+ };
85
+ if ("authenticationId" in trigger) {
86
+ wire.authentication_id = trigger.authenticationId;
87
+ } else if ("authentication_id" in trigger) {
88
+ wire.authentication_id = trigger.authentication_id;
89
+ }
90
+ if (trigger.params !== void 0) {
91
+ wire.params = trigger.params;
92
+ }
93
+ return wire;
94
+ }
60
95
  function toWireAppVersions(appVersions) {
61
96
  const wire = {};
62
97
  for (const [key, entry] of Object.entries(appVersions)) {
@@ -100,6 +135,34 @@ var WorkflowVersionTriggerConfigSchema = z.object({
100
135
  ),
101
136
  params: z.record(z.string(), z.unknown()).optional().describe("Trigger parameters as a JSON object")
102
137
  }).describe("Trigger configuration persisted on a workflow version.");
138
+ var WorkflowDraftSchema = z.object({
139
+ id: z.string().describe("Workflow draft ID (UUID)"),
140
+ workflow_id: z.string().describe("Parent workflow ID (UUID)"),
141
+ slug: z.string().describe(
142
+ "Human-friendly identifier for URL routing; unique among open drafts per workflow"
143
+ ),
144
+ base_version_id: z.string().nullable().describe(
145
+ "Live version at draft creation or last publish rebase, or null before the workflow's first publish"
146
+ ),
147
+ source_files: z.record(z.string(), z.string()).describe("Source files keyed by filename \u2192 contents"),
148
+ zapier_durable_version: z.string().describe("Pinned semver of @zapier/zapier-durable used by this draft"),
149
+ dependencies: z.record(z.string(), z.string()).nullable().describe("Additional npm dependencies pinned for this draft (or null)"),
150
+ draft_revision: z.number().int().describe(
151
+ "Monotonic revision counter for optimistic concurrency. Echo it back on draft updates to detect concurrent edits."
152
+ ),
153
+ status: WorkflowDraftStatusSchema,
154
+ created_by_user_id: z.string().describe("ID of the user who created (forked) this draft"),
155
+ last_edited_by_user_id: z.string().nullable().describe("ID of the user who last saved this draft (or null)"),
156
+ last_edited_at: z.string().nullable().describe("When the draft was last edited (ISO-8601, or null)"),
157
+ discarded_at: z.string().nullable().describe("When the draft was discarded (ISO-8601), or null while open"),
158
+ created_at: z.string().describe("When the draft was created (ISO-8601)"),
159
+ updated_at: z.string().describe("When the draft row was last updated (ISO-8601)"),
160
+ trigger: WorkflowVersionTriggerConfigSchema.nullable().describe(
161
+ "Trigger configuration held on this draft, or null for webhook-only workflows."
162
+ ),
163
+ connections: z.record(z.string(), ConnectionBindingSchema2).nullable().describe("Connection aliases bound on this draft (or null)."),
164
+ app_versions: z.record(z.string(), AppVersionBindingSchema2).nullable().describe("App-version pins bound on this draft (or null).")
165
+ });
103
166
  var WorkflowTriggerStatusSchema = z.enum([
104
167
  "unclaimed",
105
168
  "pending",
@@ -840,22 +903,6 @@ var cancelDurableRunPlugin = defineMethod({
840
903
  return { data: { id: input.run, status: "cancelled" } };
841
904
  }
842
905
  });
843
- var TriggerConfigSchema = z.object({
844
- selectedApi: z.string().optional().describe(
845
- "Zapier app/API identifier (e.g. 'GoogleSheetsAPI'). Required when a trigger is configured."
846
- ),
847
- /** @deprecated Use `selectedApi` instead. */
848
- selected_api: z.string().optional().meta({ deprecated: true }),
849
- action: z.string().describe("Trigger action key (e.g. 'new_row')"),
850
- authenticationId: z.string().nullish().describe(
851
- "Connection ID for the trigger source. Omit or pass null for no-auth triggers (e.g. Schedule by Zapier)."
852
- ),
853
- /** @deprecated Use `authenticationId` instead. */
854
- authentication_id: z.string().nullish().meta({ deprecated: true }),
855
- params: z.record(z.string(), z.unknown()).optional().describe("Trigger parameters as a JSON object")
856
- }).describe(
857
- "Zapier trigger configuration. When set, the workflow subscribes to trigger events."
858
- );
859
906
  var PublishWorkflowVersionDescription = "Publish a new version of a durable workflow. Enables the workflow by default.";
860
907
  var PublishWorkflowVersionBaseSchema = z.object({
861
908
  dependencies: z.record(z.string(), z.string()).optional().describe("Optional npm package dependencies"),
@@ -913,25 +960,6 @@ var PublishWorkflowVersionResponseSchema = z.object({
913
960
  });
914
961
 
915
962
  // src/plugins/codeSubstrate/publishWorkflowVersion/index.ts
916
- function toWireTrigger(trigger) {
917
- const selectedApi = trigger.selectedApi ?? trigger.selected_api;
918
- if (selectedApi === void 0) {
919
- throw new ZapierValidationError("trigger is missing selectedApi");
920
- }
921
- const wire = {
922
- selected_api: selectedApi,
923
- action: trigger.action
924
- };
925
- if ("authenticationId" in trigger) {
926
- wire.authentication_id = trigger.authenticationId;
927
- } else if ("authentication_id" in trigger) {
928
- wire.authentication_id = trigger.authentication_id;
929
- }
930
- if (trigger.params !== void 0) {
931
- wire.params = trigger.params;
932
- }
933
- return wire;
934
- }
935
963
  var publishWorkflowVersionPlugin = defineMethod({
936
964
  ...codeSubstrateDefaults,
937
965
  name: "publishWorkflowVersion",
@@ -1182,34 +1210,7 @@ var GetWorkflowDraftOptionsSchema = z.object({
1182
1210
  workflow: z.string().uuid().describe("Durable workflow ID"),
1183
1211
  draft: z.string().uuid().describe("Workflow draft ID")
1184
1212
  }).describe("Get full details of a workflow draft including source files");
1185
- var GetWorkflowDraftResponseSchema = z.object({
1186
- id: z.string().describe("Workflow draft ID (UUID)"),
1187
- workflow_id: z.string().describe("Parent workflow ID (UUID)"),
1188
- slug: z.string().describe(
1189
- "Human-friendly identifier for URL routing; unique among open drafts per workflow"
1190
- ),
1191
- base_version_id: z.string().nullable().describe(
1192
- "Live version at draft creation or last publish rebase, or null before the workflow's first publish"
1193
- ),
1194
- source_files: z.record(z.string(), z.string()).describe("Source files keyed by filename \u2192 contents"),
1195
- zapier_durable_version: z.string().describe("Pinned semver of @zapier/zapier-durable used by this draft"),
1196
- dependencies: z.record(z.string(), z.string()).nullable().describe("Additional npm dependencies pinned for this draft (or null)"),
1197
- draft_revision: z.number().int().describe(
1198
- "Monotonic revision counter for optimistic concurrency. Echo it back on draft updates to detect concurrent edits."
1199
- ),
1200
- status: WorkflowDraftStatusSchema,
1201
- created_by_user_id: z.string().describe("ID of the user who created (forked) this draft"),
1202
- last_edited_by_user_id: z.string().nullable().describe("ID of the user who last saved this draft (or null)"),
1203
- last_edited_at: z.string().nullable().describe("When the draft was last edited (ISO-8601, or null)"),
1204
- discarded_at: z.string().nullable().describe("When the draft was discarded (ISO-8601), or null while open"),
1205
- created_at: z.string().describe("When the draft was created (ISO-8601)"),
1206
- updated_at: z.string().describe("When the draft row was last updated (ISO-8601)"),
1207
- trigger: WorkflowVersionTriggerConfigSchema.nullable().describe(
1208
- "Trigger configuration held on this draft, or null for webhook-only workflows."
1209
- ),
1210
- connections: z.record(z.string(), ConnectionBindingSchema2).nullable().describe("Connection aliases bound on this draft (or null)."),
1211
- app_versions: z.record(z.string(), AppVersionBindingSchema2).nullable().describe("App-version pins bound on this draft (or null).")
1212
- });
1213
+ var GetWorkflowDraftResponseSchema = WorkflowDraftSchema;
1213
1214
 
1214
1215
  // src/plugins/codeSubstrate/getWorkflowDraft/index.ts
1215
1216
  var getWorkflowDraftPlugin = defineMethod({
@@ -1236,6 +1237,175 @@ var getWorkflowDraftPlugin = defineMethod({
1236
1237
  return { data: GetWorkflowDraftResponseSchema.parse(raw) };
1237
1238
  }
1238
1239
  });
1240
+ var CreateWorkflowDraftOptionsSchema = z.object({
1241
+ workflow: z.string().uuid().describe("Durable workflow ID"),
1242
+ slug: z.string().min(1).max(128).optional().describe(
1243
+ "Optional slug for URL routing. When omitted, the server generates one."
1244
+ )
1245
+ }).describe(
1246
+ "Fork a new draft from the workflow's current live version (or a blank stub before the first publish)"
1247
+ );
1248
+ var CreateWorkflowDraftResponseSchema = WorkflowDraftSchema;
1249
+
1250
+ // src/plugins/codeSubstrate/createWorkflowDraft/index.ts
1251
+ var createWorkflowDraftPlugin = defineMethod({
1252
+ ...codeSubstrateDefaults,
1253
+ name: "createWorkflowDraft",
1254
+ imports: [apiPluginRef],
1255
+ type: "create",
1256
+ itemType: "WorkflowDraft",
1257
+ inputSchema: CreateWorkflowDraftOptionsSchema,
1258
+ outputSchema: CreateWorkflowDraftResponseSchema,
1259
+ output: "item",
1260
+ resolvers: { workflow: workflowIdResolver },
1261
+ run: async ({ imports, input }) => {
1262
+ const api = imports.api;
1263
+ const body = {};
1264
+ if (input.slug !== void 0) {
1265
+ body.slug = input.slug;
1266
+ }
1267
+ const raw = await api.post(
1268
+ `${CODE_SUBSTRATE_WORKFLOWS_API}/workflows/${encodeURIComponent(input.workflow)}/drafts`,
1269
+ body,
1270
+ {
1271
+ authRequired: true,
1272
+ resource: { type: "workflow", id: input.workflow }
1273
+ }
1274
+ );
1275
+ return { data: CreateWorkflowDraftResponseSchema.parse(raw) };
1276
+ }
1277
+ });
1278
+ var UpdateWorkflowDraftOptionsSchema = z.object({
1279
+ workflow: z.string().uuid().describe("Durable workflow ID"),
1280
+ draft: z.string().uuid().describe("Workflow draft ID"),
1281
+ sourceFiles: SourceFilesSchema,
1282
+ zapierDurableVersion: z.string().optional().describe(
1283
+ 'Exact semver of @zapier/zapier-durable to use (e.g. "1.2.3"). Leaves the stored pin unchanged if omitted.'
1284
+ ),
1285
+ dependencies: z.record(z.string(), z.string()).optional().describe("Optional npm package dependencies"),
1286
+ draftRevision: z.number().int().min(0).optional().describe(
1287
+ "Expected draft revision for optimistic concurrency. Pass the revision from the last read; the server rejects the save with a conflict if the draft has changed since. Omit to skip the check."
1288
+ ),
1289
+ trigger: TriggerConfigSchema.nullish().describe(
1290
+ "Trigger configuration. Omit to leave the stored trigger unchanged, pass null to clear it, or pass an object to replace it."
1291
+ ),
1292
+ connections: z.record(z.string(), ConnectionBindingSchema).nullish().describe(
1293
+ "Map of connection aliases to Zapier connections used by the workflow. Pass `null` to clear an existing binding."
1294
+ ),
1295
+ appVersions: z.record(z.string(), AppVersionBindingSchema).nullish().describe(
1296
+ "Map of app keys to pinned app implementation/version used by the workflow. Pass `null` to clear an existing binding."
1297
+ )
1298
+ }).describe("Update (autosave) an open workflow draft");
1299
+ var UpdateWorkflowDraftResponseSchema = WorkflowDraftSchema;
1300
+
1301
+ // src/plugins/codeSubstrate/updateWorkflowDraft/index.ts
1302
+ var updateWorkflowDraftPlugin = defineMethod({
1303
+ ...codeSubstrateDefaults,
1304
+ name: "updateWorkflowDraft",
1305
+ imports: [apiPluginRef],
1306
+ type: "update",
1307
+ itemType: "WorkflowDraft",
1308
+ inputSchema: UpdateWorkflowDraftOptionsSchema,
1309
+ outputSchema: UpdateWorkflowDraftResponseSchema,
1310
+ output: "item",
1311
+ resolvers: {
1312
+ workflow: workflowIdResolver,
1313
+ draft: workflowDraftIdResolver,
1314
+ sourceFiles: sourceFilesResolver
1315
+ },
1316
+ run: async ({ imports, input }) => {
1317
+ const api = imports.api;
1318
+ const body = { source_files: input.sourceFiles };
1319
+ if (input.zapierDurableVersion !== void 0) {
1320
+ body.zapier_durable_version = input.zapierDurableVersion;
1321
+ }
1322
+ if (input.dependencies !== void 0) {
1323
+ body.dependencies = input.dependencies;
1324
+ }
1325
+ if (input.draftRevision !== void 0) {
1326
+ body.draft_revision = input.draftRevision;
1327
+ }
1328
+ if (input.trigger === null) {
1329
+ body.trigger = null;
1330
+ } else if (input.trigger !== void 0) {
1331
+ body.trigger = toWireTrigger(input.trigger);
1332
+ }
1333
+ if (input.connections === null) {
1334
+ body.connections = null;
1335
+ } else if (input.connections !== void 0) {
1336
+ body.connections = toWireConnections(input.connections);
1337
+ }
1338
+ if (input.appVersions === null) {
1339
+ body.app_versions = null;
1340
+ } else if (input.appVersions !== void 0) {
1341
+ body.app_versions = toWireAppVersions(input.appVersions);
1342
+ }
1343
+ const raw = await api.put(
1344
+ `${CODE_SUBSTRATE_WORKFLOWS_API}/workflows/${encodeURIComponent(input.workflow)}/drafts/${encodeURIComponent(input.draft)}`,
1345
+ body,
1346
+ {
1347
+ authRequired: true,
1348
+ resource: { type: "workflow-draft", id: input.draft },
1349
+ // A 409 is the optimistic-concurrency signal: the draft's revision
1350
+ // moved past the caller's `draftRevision` (someone else saved in
1351
+ // between). Type it so callers can catch ZapierConflictError,
1352
+ // re-read the draft, and retry instead of blind-overwriting.
1353
+ customErrorHandler: ({ status, data }) => {
1354
+ if (status === 409) {
1355
+ const detail = extractErrorDetail(data);
1356
+ return new ZapierConflictError(
1357
+ `${detail ?? "Draft revision conflict"} \u2014 the draft changed since it was last read. Re-read the draft to get the current draft_revision, merge your edits, and retry.`,
1358
+ { statusCode: status, resourceType: "workflow-draft" }
1359
+ );
1360
+ }
1361
+ return void 0;
1362
+ }
1363
+ }
1364
+ );
1365
+ return { data: UpdateWorkflowDraftResponseSchema.parse(raw) };
1366
+ }
1367
+ });
1368
+ var DiscardWorkflowDraftOptionsSchema = z.object({
1369
+ workflow: z.string().uuid().describe("Durable workflow ID"),
1370
+ draft: z.string().uuid().describe("Workflow draft ID")
1371
+ }).describe(
1372
+ "Discard an open workflow draft (soft delete). The draft's unpublished edits stop resolving; the published version is untouched."
1373
+ );
1374
+ var DiscardWorkflowDraftResponseSchema = WorkflowDraftSchema;
1375
+
1376
+ // src/plugins/codeSubstrate/discardWorkflowDraft/index.ts
1377
+ var discardWorkflowDraftPlugin = defineMethod({
1378
+ ...codeSubstrateDefaults,
1379
+ name: "discardWorkflowDraft",
1380
+ imports: [apiPluginRef],
1381
+ type: "delete",
1382
+ itemType: "WorkflowDraft",
1383
+ // Soft delete returns the discarded draft, not the `{ success: boolean }`
1384
+ // shape the docs generator assumes for delete methods.
1385
+ returnType: "WorkflowDraftItem",
1386
+ // Discard throws away the draft's unpublished edits, so it warrants the
1387
+ // same interactive confirmation as deleteWorkflow.
1388
+ confirm: "delete",
1389
+ inputSchema: DiscardWorkflowDraftOptionsSchema,
1390
+ outputSchema: DiscardWorkflowDraftResponseSchema,
1391
+ output: "item",
1392
+ resolvers: {
1393
+ workflow: workflowIdResolver,
1394
+ draft: workflowDraftIdResolver
1395
+ },
1396
+ run: async ({ imports, input }) => {
1397
+ const api = imports.api;
1398
+ const raw = await api.delete(
1399
+ `${CODE_SUBSTRATE_WORKFLOWS_API}/workflows/${encodeURIComponent(input.workflow)}/drafts/${encodeURIComponent(input.draft)}`,
1400
+ void 0,
1401
+ {
1402
+ authRequired: true,
1403
+ resource: { type: "workflow-draft", id: input.draft }
1404
+ }
1405
+ );
1406
+ return { data: DiscardWorkflowDraftResponseSchema.parse(raw) };
1407
+ }
1408
+ });
1239
1409
  var WorkflowRunStatusSchema = z.union([
1240
1410
  z.enum(["initialized", "started", "finished", "failed", "cancelled"]),
1241
1411
  z.string()
@@ -1493,6 +1663,9 @@ var zapierExperimentalSdkPlugin = definePlugin({
1493
1663
  publishWorkflowVersionPlugin,
1494
1664
  listWorkflowDraftsPlugin,
1495
1665
  getWorkflowDraftPlugin,
1666
+ createWorkflowDraftPlugin,
1667
+ updateWorkflowDraftPlugin,
1668
+ discardWorkflowDraftPlugin,
1496
1669
  listWorkflowRunsPlugin,
1497
1670
  getWorkflowRunPlugin,
1498
1671
  listDurableRunsPlugin,