@zapier/zapier-sdk 0.89.0 → 0.91.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.
- package/CHANGELOG.md +20 -0
- package/README.md +238 -33
- package/dist/{chunk-UBI5FOL5.cjs → chunk-RO34ZWKR.cjs} +2 -1
- package/dist/{chunk-NOPKQ333.mjs → chunk-SZBWDVX3.mjs} +2 -2
- package/dist/experimental.cjs +695 -449
- package/dist/experimental.d.mts +379 -1
- package/dist/experimental.d.ts +379 -1
- package/dist/experimental.mjs +346 -100
- package/dist/index.cjs +272 -272
- package/dist/index.mjs +1 -1
- package/package.json +1 -1
package/dist/experimental.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { defineMethod, DEFAULT_PAGE_SIZE, apiPluginRef, workflowIdResolver, openEnum, durableRunIdResolver, defineResolver, workflowVersionIdResolver, workflowDraftIdResolver,
|
|
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-
|
|
1
|
+
import { defineMethod, DEFAULT_PAGE_SIZE, apiPluginRef, workflowIdResolver, openEnum, durableRunIdResolver, defineResolver, workflowVersionIdResolver, workflowDraftIdResolver, extractErrorDetail, ZapierConflictError, ZapierApiError, workflowRunIdResolver, definePlugin, zapierSdkPlugin, ZapierValidationError, createSdk, zapierCoreOptions, CORE_OPTIONS_ID, SDK_OPTIONS_ID } from './chunk-SZBWDVX3.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-SZBWDVX3.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,50 @@ 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
|
+
"The version this draft was forked from (the live version at draft creation), or null when the workflow had no published version yet"
|
|
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
|
+
});
|
|
166
|
+
var WorkflowVersionSchema = z.object({
|
|
167
|
+
id: z.string().describe("Workflow version ID (UUID)"),
|
|
168
|
+
workflow_id: z.string().describe("Parent workflow ID (UUID)"),
|
|
169
|
+
source_files: z.record(z.string(), z.string()).describe("Source files keyed by filename \u2192 contents"),
|
|
170
|
+
zapier_durable_version: z.string().describe(
|
|
171
|
+
"Pinned semver of @zapier/zapier-durable used by this version's runs"
|
|
172
|
+
),
|
|
173
|
+
dependencies: z.record(z.string(), z.string()).nullable().describe("Additional npm dependencies pinned for this version (or null)"),
|
|
174
|
+
created_by_user_id: z.string().describe("ID of the user who published this version"),
|
|
175
|
+
created_at: z.string().describe("When the version was published (ISO-8601)"),
|
|
176
|
+
trigger: WorkflowVersionTriggerConfigSchema.nullable().describe(
|
|
177
|
+
"Trigger configuration persisted on this version, or null for webhook-only workflows."
|
|
178
|
+
),
|
|
179
|
+
connections: z.record(z.string(), ConnectionBindingSchema2).nullable().describe("Connection aliases bound on this version (or null)."),
|
|
180
|
+
app_versions: z.record(z.string(), AppVersionBindingSchema2).nullable().describe("App-version pins bound on this version (or null).")
|
|
181
|
+
});
|
|
103
182
|
var WorkflowTriggerStatusSchema = z.enum([
|
|
104
183
|
"unclaimed",
|
|
105
184
|
"pending",
|
|
@@ -213,7 +292,7 @@ var listWorkflowsPlugin = defineMethod({
|
|
|
213
292
|
};
|
|
214
293
|
}
|
|
215
294
|
});
|
|
216
|
-
var
|
|
295
|
+
var WorkflowVersionSchema2 = z.object({
|
|
217
296
|
id: z.string().describe("Workflow version ID (UUID)"),
|
|
218
297
|
workflow_id: z.string().describe("Parent workflow ID"),
|
|
219
298
|
source_files: z.record(z.string(), z.string()).describe("Source files keyed by filename \u2192 contents"),
|
|
@@ -252,7 +331,7 @@ var GetWorkflowResponseSchema = z.object({
|
|
|
252
331
|
"Whether the workflow is private to the creating user. False means account-visible."
|
|
253
332
|
),
|
|
254
333
|
created_by_user_id: z.string().nullable().describe("User ID of the workflow creator (null in legacy data)"),
|
|
255
|
-
current_version:
|
|
334
|
+
current_version: WorkflowVersionSchema2.optional().describe(
|
|
256
335
|
"The currently published version, if any. Absent for workflows with no version published yet."
|
|
257
336
|
),
|
|
258
337
|
triggers: z.array(WorkflowTriggerSchema).describe(
|
|
@@ -840,22 +919,6 @@ var cancelDurableRunPlugin = defineMethod({
|
|
|
840
919
|
return { data: { id: input.run, status: "cancelled" } };
|
|
841
920
|
}
|
|
842
921
|
});
|
|
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
922
|
var PublishWorkflowVersionDescription = "Publish a new version of a durable workflow. Enables the workflow by default.";
|
|
860
923
|
var PublishWorkflowVersionBaseSchema = z.object({
|
|
861
924
|
dependencies: z.record(z.string(), z.string()).optional().describe("Optional npm package dependencies"),
|
|
@@ -895,43 +958,9 @@ var PublishWorkflowVersionSchemaDeprecated = z.object({
|
|
|
895
958
|
source_files: SourceFilesSchema
|
|
896
959
|
}).merge(PublishWorkflowVersionBaseSchema);
|
|
897
960
|
var PublishWorkflowVersionOptionsSchema = z.union([PublishWorkflowVersionSchema, PublishWorkflowVersionSchemaDeprecated]).describe(PublishWorkflowVersionDescription);
|
|
898
|
-
var PublishWorkflowVersionResponseSchema =
|
|
899
|
-
id: z.string().describe("Workflow version ID (UUID)"),
|
|
900
|
-
workflow_id: z.string().describe("Parent workflow ID (UUID)"),
|
|
901
|
-
source_files: z.record(z.string(), z.string()).describe("Source files keyed by filename \u2192 contents"),
|
|
902
|
-
zapier_durable_version: z.string().describe(
|
|
903
|
-
"Pinned semver of @zapier/zapier-durable used by this version's runs"
|
|
904
|
-
),
|
|
905
|
-
dependencies: z.record(z.string(), z.string()).nullable().describe("Additional npm dependencies pinned for this version (or null)"),
|
|
906
|
-
created_by_user_id: z.string().describe("ID of the user who published this version"),
|
|
907
|
-
created_at: z.string().describe("When the version was published (ISO-8601)"),
|
|
908
|
-
trigger: WorkflowVersionTriggerConfigSchema.nullable().describe(
|
|
909
|
-
"Trigger configuration persisted on this version, or null for webhook-only workflows."
|
|
910
|
-
),
|
|
911
|
-
connections: z.record(z.string(), ConnectionBindingSchema2).nullable().describe("Connection aliases bound on this version (or null)."),
|
|
912
|
-
app_versions: z.record(z.string(), AppVersionBindingSchema2).nullable().describe("App-version pins bound on this version (or null).")
|
|
913
|
-
});
|
|
961
|
+
var PublishWorkflowVersionResponseSchema = WorkflowVersionSchema;
|
|
914
962
|
|
|
915
963
|
// 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
964
|
var publishWorkflowVersionPlugin = defineMethod({
|
|
936
965
|
...codeSubstrateDefaults,
|
|
937
966
|
name: "publishWorkflowVersion",
|
|
@@ -1055,22 +1084,7 @@ var GetWorkflowVersionOptionsSchema = z.object({
|
|
|
1055
1084
|
workflow: z.string().uuid().describe("Durable workflow ID"),
|
|
1056
1085
|
version: z.string().uuid().describe("Workflow version ID")
|
|
1057
1086
|
}).describe("Get full details of a workflow version including source files");
|
|
1058
|
-
var GetWorkflowVersionResponseSchema =
|
|
1059
|
-
id: z.string().describe("Workflow version ID (UUID)"),
|
|
1060
|
-
workflow_id: z.string().describe("Parent workflow ID (UUID)"),
|
|
1061
|
-
source_files: z.record(z.string(), z.string()).describe("Source files keyed by filename \u2192 contents"),
|
|
1062
|
-
zapier_durable_version: z.string().describe(
|
|
1063
|
-
"Pinned semver of @zapier/zapier-durable used by this version's runs"
|
|
1064
|
-
),
|
|
1065
|
-
dependencies: z.record(z.string(), z.string()).nullable().describe("Additional npm dependencies pinned for this version (or null)"),
|
|
1066
|
-
created_by_user_id: z.string().describe("ID of the user who published this version"),
|
|
1067
|
-
created_at: z.string().describe("When the version was published (ISO-8601)"),
|
|
1068
|
-
trigger: WorkflowVersionTriggerConfigSchema.nullable().describe(
|
|
1069
|
-
"Trigger configuration persisted on this version, or null for webhook-only workflows."
|
|
1070
|
-
),
|
|
1071
|
-
connections: z.record(z.string(), ConnectionBindingSchema2).nullable().describe("Connection aliases bound on this version (or null)."),
|
|
1072
|
-
app_versions: z.record(z.string(), AppVersionBindingSchema2).nullable().describe("App-version pins bound on this version (or null).")
|
|
1073
|
-
});
|
|
1087
|
+
var GetWorkflowVersionResponseSchema = WorkflowVersionSchema;
|
|
1074
1088
|
|
|
1075
1089
|
// src/plugins/codeSubstrate/getWorkflowVersion/index.ts
|
|
1076
1090
|
var getWorkflowVersionPlugin = defineMethod({
|
|
@@ -1104,7 +1118,7 @@ var WorkflowDraftSummarySchema = z.object({
|
|
|
1104
1118
|
"Human-friendly identifier for URL routing; unique among open drafts per workflow"
|
|
1105
1119
|
),
|
|
1106
1120
|
base_version_id: z.string().nullable().describe(
|
|
1107
|
-
"
|
|
1121
|
+
"The version this draft was forked from (the live version at draft creation), or null when the workflow had no published version yet"
|
|
1108
1122
|
),
|
|
1109
1123
|
status: WorkflowDraftStatusSchema,
|
|
1110
1124
|
last_edited_by_user_id: z.string().nullable().describe("ID of the user who last saved this draft (or null)"),
|
|
@@ -1182,34 +1196,7 @@ var GetWorkflowDraftOptionsSchema = z.object({
|
|
|
1182
1196
|
workflow: z.string().uuid().describe("Durable workflow ID"),
|
|
1183
1197
|
draft: z.string().uuid().describe("Workflow draft ID")
|
|
1184
1198
|
}).describe("Get full details of a workflow draft including source files");
|
|
1185
|
-
var GetWorkflowDraftResponseSchema =
|
|
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
|
-
});
|
|
1199
|
+
var GetWorkflowDraftResponseSchema = WorkflowDraftSchema;
|
|
1213
1200
|
|
|
1214
1201
|
// src/plugins/codeSubstrate/getWorkflowDraft/index.ts
|
|
1215
1202
|
var getWorkflowDraftPlugin = defineMethod({
|
|
@@ -1236,6 +1223,261 @@ var getWorkflowDraftPlugin = defineMethod({
|
|
|
1236
1223
|
return { data: GetWorkflowDraftResponseSchema.parse(raw) };
|
|
1237
1224
|
}
|
|
1238
1225
|
});
|
|
1226
|
+
var CreateWorkflowDraftOptionsSchema = z.object({
|
|
1227
|
+
workflow: z.string().uuid().describe("Durable workflow ID"),
|
|
1228
|
+
slug: z.string().min(1).max(128).optional().describe(
|
|
1229
|
+
"Optional slug for URL routing. When omitted, the server generates one."
|
|
1230
|
+
)
|
|
1231
|
+
}).describe(
|
|
1232
|
+
"Fork a new draft from the workflow's current live version (or a blank stub before the first publish)"
|
|
1233
|
+
);
|
|
1234
|
+
var CreateWorkflowDraftResponseSchema = WorkflowDraftSchema;
|
|
1235
|
+
|
|
1236
|
+
// src/plugins/codeSubstrate/createWorkflowDraft/index.ts
|
|
1237
|
+
var createWorkflowDraftPlugin = defineMethod({
|
|
1238
|
+
...codeSubstrateDefaults,
|
|
1239
|
+
name: "createWorkflowDraft",
|
|
1240
|
+
imports: [apiPluginRef],
|
|
1241
|
+
type: "create",
|
|
1242
|
+
itemType: "WorkflowDraft",
|
|
1243
|
+
inputSchema: CreateWorkflowDraftOptionsSchema,
|
|
1244
|
+
outputSchema: CreateWorkflowDraftResponseSchema,
|
|
1245
|
+
output: "item",
|
|
1246
|
+
resolvers: { workflow: workflowIdResolver },
|
|
1247
|
+
run: async ({ imports, input }) => {
|
|
1248
|
+
const api = imports.api;
|
|
1249
|
+
const body = {};
|
|
1250
|
+
if (input.slug !== void 0) {
|
|
1251
|
+
body.slug = input.slug;
|
|
1252
|
+
}
|
|
1253
|
+
const raw = await api.post(
|
|
1254
|
+
`${CODE_SUBSTRATE_WORKFLOWS_API}/workflows/${encodeURIComponent(input.workflow)}/drafts`,
|
|
1255
|
+
body,
|
|
1256
|
+
{
|
|
1257
|
+
authRequired: true,
|
|
1258
|
+
resource: { type: "workflow", id: input.workflow }
|
|
1259
|
+
}
|
|
1260
|
+
);
|
|
1261
|
+
return { data: CreateWorkflowDraftResponseSchema.parse(raw) };
|
|
1262
|
+
}
|
|
1263
|
+
});
|
|
1264
|
+
var UpdateWorkflowDraftOptionsSchema = z.object({
|
|
1265
|
+
workflow: z.string().uuid().describe("Durable workflow ID"),
|
|
1266
|
+
draft: z.string().uuid().describe("Workflow draft ID"),
|
|
1267
|
+
sourceFiles: SourceFilesSchema,
|
|
1268
|
+
zapierDurableVersion: z.string().optional().describe(
|
|
1269
|
+
'Exact semver of @zapier/zapier-durable to use (e.g. "1.2.3"). Leaves the stored pin unchanged if omitted.'
|
|
1270
|
+
),
|
|
1271
|
+
dependencies: z.record(z.string(), z.string()).optional().describe("Optional npm package dependencies"),
|
|
1272
|
+
draftRevision: z.number().int().min(0).optional().describe(
|
|
1273
|
+
"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."
|
|
1274
|
+
),
|
|
1275
|
+
trigger: TriggerConfigSchema.nullish().describe(
|
|
1276
|
+
"Trigger configuration. Omit to leave the stored trigger unchanged, pass null to clear it, or pass an object to replace it."
|
|
1277
|
+
),
|
|
1278
|
+
connections: z.record(z.string(), ConnectionBindingSchema).nullish().describe(
|
|
1279
|
+
"Map of connection aliases to Zapier connections used by the workflow. Pass `null` to clear an existing binding."
|
|
1280
|
+
),
|
|
1281
|
+
appVersions: z.record(z.string(), AppVersionBindingSchema).nullish().describe(
|
|
1282
|
+
"Map of app keys to pinned app implementation/version used by the workflow. Pass `null` to clear an existing binding."
|
|
1283
|
+
)
|
|
1284
|
+
}).describe("Update (autosave) an open workflow draft");
|
|
1285
|
+
var UpdateWorkflowDraftResponseSchema = WorkflowDraftSchema;
|
|
1286
|
+
|
|
1287
|
+
// src/plugins/codeSubstrate/updateWorkflowDraft/index.ts
|
|
1288
|
+
var updateWorkflowDraftPlugin = defineMethod({
|
|
1289
|
+
...codeSubstrateDefaults,
|
|
1290
|
+
name: "updateWorkflowDraft",
|
|
1291
|
+
imports: [apiPluginRef],
|
|
1292
|
+
type: "update",
|
|
1293
|
+
itemType: "WorkflowDraft",
|
|
1294
|
+
inputSchema: UpdateWorkflowDraftOptionsSchema,
|
|
1295
|
+
outputSchema: UpdateWorkflowDraftResponseSchema,
|
|
1296
|
+
output: "item",
|
|
1297
|
+
resolvers: {
|
|
1298
|
+
workflow: workflowIdResolver,
|
|
1299
|
+
draft: workflowDraftIdResolver,
|
|
1300
|
+
sourceFiles: sourceFilesResolver
|
|
1301
|
+
},
|
|
1302
|
+
run: async ({ imports, input }) => {
|
|
1303
|
+
const api = imports.api;
|
|
1304
|
+
const body = { source_files: input.sourceFiles };
|
|
1305
|
+
if (input.zapierDurableVersion !== void 0) {
|
|
1306
|
+
body.zapier_durable_version = input.zapierDurableVersion;
|
|
1307
|
+
}
|
|
1308
|
+
if (input.dependencies !== void 0) {
|
|
1309
|
+
body.dependencies = input.dependencies;
|
|
1310
|
+
}
|
|
1311
|
+
if (input.draftRevision !== void 0) {
|
|
1312
|
+
body.draft_revision = input.draftRevision;
|
|
1313
|
+
}
|
|
1314
|
+
if (input.trigger === null) {
|
|
1315
|
+
body.trigger = null;
|
|
1316
|
+
} else if (input.trigger !== void 0) {
|
|
1317
|
+
body.trigger = toWireTrigger(input.trigger);
|
|
1318
|
+
}
|
|
1319
|
+
if (input.connections === null) {
|
|
1320
|
+
body.connections = null;
|
|
1321
|
+
} else if (input.connections !== void 0) {
|
|
1322
|
+
body.connections = toWireConnections(input.connections);
|
|
1323
|
+
}
|
|
1324
|
+
if (input.appVersions === null) {
|
|
1325
|
+
body.app_versions = null;
|
|
1326
|
+
} else if (input.appVersions !== void 0) {
|
|
1327
|
+
body.app_versions = toWireAppVersions(input.appVersions);
|
|
1328
|
+
}
|
|
1329
|
+
const raw = await api.put(
|
|
1330
|
+
`${CODE_SUBSTRATE_WORKFLOWS_API}/workflows/${encodeURIComponent(input.workflow)}/drafts/${encodeURIComponent(input.draft)}`,
|
|
1331
|
+
body,
|
|
1332
|
+
{
|
|
1333
|
+
authRequired: true,
|
|
1334
|
+
resource: { type: "workflow-draft", id: input.draft },
|
|
1335
|
+
// A 409 is the optimistic-concurrency signal: the draft's revision
|
|
1336
|
+
// moved past the caller's `draftRevision` (someone else saved in
|
|
1337
|
+
// between). Type it so callers can catch ZapierConflictError,
|
|
1338
|
+
// re-read the draft, and retry instead of blind-overwriting.
|
|
1339
|
+
customErrorHandler: ({ status, data }) => {
|
|
1340
|
+
if (status === 409) {
|
|
1341
|
+
const detail = extractErrorDetail(data);
|
|
1342
|
+
return new ZapierConflictError(
|
|
1343
|
+
`${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.`,
|
|
1344
|
+
{ statusCode: status, resourceType: "workflow-draft" }
|
|
1345
|
+
);
|
|
1346
|
+
}
|
|
1347
|
+
return void 0;
|
|
1348
|
+
}
|
|
1349
|
+
}
|
|
1350
|
+
);
|
|
1351
|
+
return { data: UpdateWorkflowDraftResponseSchema.parse(raw) };
|
|
1352
|
+
}
|
|
1353
|
+
});
|
|
1354
|
+
var DiscardWorkflowDraftOptionsSchema = z.object({
|
|
1355
|
+
workflow: z.string().uuid().describe("Durable workflow ID"),
|
|
1356
|
+
draft: z.string().uuid().describe("Workflow draft ID")
|
|
1357
|
+
}).describe(
|
|
1358
|
+
"Discard an open workflow draft (soft delete). The draft's unpublished edits stop resolving; the published version is untouched."
|
|
1359
|
+
);
|
|
1360
|
+
var DiscardWorkflowDraftResponseSchema = WorkflowDraftSchema;
|
|
1361
|
+
|
|
1362
|
+
// src/plugins/codeSubstrate/discardWorkflowDraft/index.ts
|
|
1363
|
+
var discardWorkflowDraftPlugin = defineMethod({
|
|
1364
|
+
...codeSubstrateDefaults,
|
|
1365
|
+
name: "discardWorkflowDraft",
|
|
1366
|
+
imports: [apiPluginRef],
|
|
1367
|
+
type: "delete",
|
|
1368
|
+
itemType: "WorkflowDraft",
|
|
1369
|
+
// Soft delete returns the discarded draft, not the `{ success: boolean }`
|
|
1370
|
+
// shape the docs generator assumes for delete methods.
|
|
1371
|
+
returnType: "WorkflowDraftItem",
|
|
1372
|
+
// Discard throws away the draft's unpublished edits, so it warrants the
|
|
1373
|
+
// same interactive confirmation as deleteWorkflow.
|
|
1374
|
+
confirm: "delete",
|
|
1375
|
+
inputSchema: DiscardWorkflowDraftOptionsSchema,
|
|
1376
|
+
outputSchema: DiscardWorkflowDraftResponseSchema,
|
|
1377
|
+
output: "item",
|
|
1378
|
+
resolvers: {
|
|
1379
|
+
workflow: workflowIdResolver,
|
|
1380
|
+
draft: workflowDraftIdResolver
|
|
1381
|
+
},
|
|
1382
|
+
run: async ({ imports, input }) => {
|
|
1383
|
+
const api = imports.api;
|
|
1384
|
+
const raw = await api.delete(
|
|
1385
|
+
`${CODE_SUBSTRATE_WORKFLOWS_API}/workflows/${encodeURIComponent(input.workflow)}/drafts/${encodeURIComponent(input.draft)}`,
|
|
1386
|
+
void 0,
|
|
1387
|
+
{
|
|
1388
|
+
authRequired: true,
|
|
1389
|
+
resource: { type: "workflow-draft", id: input.draft }
|
|
1390
|
+
}
|
|
1391
|
+
);
|
|
1392
|
+
return { data: DiscardWorkflowDraftResponseSchema.parse(raw) };
|
|
1393
|
+
}
|
|
1394
|
+
});
|
|
1395
|
+
var PublishWorkflowDraftOptionsSchema = z.object({
|
|
1396
|
+
workflow: z.string().uuid().describe("Durable workflow ID"),
|
|
1397
|
+
draft: z.string().uuid().describe("Workflow draft ID"),
|
|
1398
|
+
enabled: z.boolean().optional().describe(
|
|
1399
|
+
"Set the workflow's enabled state as part of the publish. If omitted, the current enabled state is preserved."
|
|
1400
|
+
),
|
|
1401
|
+
draftRevision: z.number().int().min(0).optional().describe(
|
|
1402
|
+
"Expected draft revision for optimistic concurrency. Pass the revision from the last read; the server rejects the publish with a conflict if the draft has changed since. Omit to skip the check."
|
|
1403
|
+
)
|
|
1404
|
+
}).describe(
|
|
1405
|
+
"Publish an open draft as a new immutable workflow version. Advances the workflow's live pointer and discards the draft \u2014 publish consumes it, so an open draft always means unpublished work. Continue editing by creating a new draft, which forks from the just-published version."
|
|
1406
|
+
);
|
|
1407
|
+
var PublishWorkflowDraftResponseSchema = z.object({
|
|
1408
|
+
draft: WorkflowDraftSchema.describe(
|
|
1409
|
+
"The consumed draft: status is 'discarded' and discarded_at is set. base_version_id still records the version the draft was forked from."
|
|
1410
|
+
),
|
|
1411
|
+
version: WorkflowVersionSchema.describe(
|
|
1412
|
+
"The newly published immutable workflow version, now live."
|
|
1413
|
+
)
|
|
1414
|
+
});
|
|
1415
|
+
|
|
1416
|
+
// src/plugins/codeSubstrate/publishWorkflowDraft/index.ts
|
|
1417
|
+
var publishWorkflowDraftPlugin = defineMethod({
|
|
1418
|
+
...codeSubstrateDefaults,
|
|
1419
|
+
name: "publishWorkflowDraft",
|
|
1420
|
+
imports: [apiPluginRef],
|
|
1421
|
+
type: "create",
|
|
1422
|
+
itemType: "WorkflowVersion",
|
|
1423
|
+
// The response is the composite `{ draft, version }`, not the bare
|
|
1424
|
+
// `WorkflowVersionItem` the docs generator derives from itemType.
|
|
1425
|
+
returnType: "PublishWorkflowDraftResponse",
|
|
1426
|
+
inputSchema: PublishWorkflowDraftOptionsSchema,
|
|
1427
|
+
outputSchema: PublishWorkflowDraftResponseSchema,
|
|
1428
|
+
output: "item",
|
|
1429
|
+
resolvers: {
|
|
1430
|
+
workflow: workflowIdResolver,
|
|
1431
|
+
draft: workflowDraftIdResolver
|
|
1432
|
+
},
|
|
1433
|
+
run: async ({ imports, input }) => {
|
|
1434
|
+
const api = imports.api;
|
|
1435
|
+
const body = {};
|
|
1436
|
+
if (input.enabled !== void 0) {
|
|
1437
|
+
body.enabled = input.enabled;
|
|
1438
|
+
}
|
|
1439
|
+
if (input.draftRevision !== void 0) {
|
|
1440
|
+
body.draft_revision = input.draftRevision;
|
|
1441
|
+
}
|
|
1442
|
+
const raw = await api.post(
|
|
1443
|
+
`${CODE_SUBSTRATE_WORKFLOWS_API}/workflows/${encodeURIComponent(input.workflow)}/drafts/${encodeURIComponent(input.draft)}/publish`,
|
|
1444
|
+
body,
|
|
1445
|
+
{
|
|
1446
|
+
authRequired: true,
|
|
1447
|
+
resource: { type: "workflow-draft", id: input.draft },
|
|
1448
|
+
// Preserve the endpoint's distinct failure modes instead of letting
|
|
1449
|
+
// them flatten into a generic API error:
|
|
1450
|
+
// 409 — the draft was edited concurrently (draft_revision moved past
|
|
1451
|
+
// the caller's), or a trigger subscription switchover is
|
|
1452
|
+
// already in progress. Retryable after re-reading the draft.
|
|
1453
|
+
// 503 — the trigger config could not be validated against the
|
|
1454
|
+
// platform catalog; validation is fail-closed so the publish
|
|
1455
|
+
// is rejected rather than committing unvalidated config.
|
|
1456
|
+
// Retryable as-is.
|
|
1457
|
+
// 400 (invalid zapier_durable_version / trigger config) already maps
|
|
1458
|
+
// to ZapierValidationError via the client's default handling.
|
|
1459
|
+
customErrorHandler: ({ status, data }) => {
|
|
1460
|
+
if (status === 409) {
|
|
1461
|
+
const detail = extractErrorDetail(data);
|
|
1462
|
+
return new ZapierConflictError(
|
|
1463
|
+
`${detail ?? "Draft publish conflict"} \u2014 the draft changed since it was last read, or a trigger switchover is already in progress. Re-read the draft to get the current draft_revision, then retry the publish.`,
|
|
1464
|
+
{ statusCode: status, resourceType: "workflow-draft" }
|
|
1465
|
+
);
|
|
1466
|
+
}
|
|
1467
|
+
if (status === 503) {
|
|
1468
|
+
const detail = extractErrorDetail(data);
|
|
1469
|
+
return new ZapierApiError(
|
|
1470
|
+
detail !== void 0 ? `${detail} \u2014 the trigger config could not be validated against the platform catalog, so the publish was rejected (fail-closed). This is transient; retry the publish.` : "Draft publish temporarily unavailable \u2014 trigger validation is fail-closed, or the service is briefly unavailable. This is transient; retry the publish.",
|
|
1471
|
+
{ statusCode: status }
|
|
1472
|
+
);
|
|
1473
|
+
}
|
|
1474
|
+
return void 0;
|
|
1475
|
+
}
|
|
1476
|
+
}
|
|
1477
|
+
);
|
|
1478
|
+
return { data: PublishWorkflowDraftResponseSchema.parse(raw) };
|
|
1479
|
+
}
|
|
1480
|
+
});
|
|
1239
1481
|
var WorkflowRunStatusSchema = z.union([
|
|
1240
1482
|
z.enum(["initialized", "started", "finished", "failed", "cancelled"]),
|
|
1241
1483
|
z.string()
|
|
@@ -1493,6 +1735,10 @@ var zapierExperimentalSdkPlugin = definePlugin({
|
|
|
1493
1735
|
publishWorkflowVersionPlugin,
|
|
1494
1736
|
listWorkflowDraftsPlugin,
|
|
1495
1737
|
getWorkflowDraftPlugin,
|
|
1738
|
+
createWorkflowDraftPlugin,
|
|
1739
|
+
updateWorkflowDraftPlugin,
|
|
1740
|
+
discardWorkflowDraftPlugin,
|
|
1741
|
+
publishWorkflowDraftPlugin,
|
|
1496
1742
|
listWorkflowRunsPlugin,
|
|
1497
1743
|
getWorkflowRunPlugin,
|
|
1498
1744
|
listDurableRunsPlugin,
|