@zapier/zapier-sdk 0.117.0 → 0.119.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 +15 -0
- package/README.md +327 -276
- package/dist/beta.cjs +301 -281
- package/dist/beta.d.mts +7017 -2084
- package/dist/beta.d.ts +7017 -2084
- package/dist/beta.mjs +2 -2
- package/dist/{chunk-Z2SAHSI3.mjs → chunk-6FKWG6WZ.mjs} +55 -20
- package/dist/chunk-JBEQF7XE.mjs +2412 -0
- package/dist/chunk-QTG5EPTI.cjs +2419 -0
- package/dist/{chunk-FDR2QEZI.cjs → chunk-TJXDMXEE.cjs} +56 -19
- package/dist/experimental.cjs +344 -2597
- package/dist/experimental.d.mts +1080 -966
- package/dist/experimental.d.ts +1080 -966
- package/dist/experimental.mjs +15 -2287
- package/dist/{index-DWS1MdAd.d.mts → index-DIWpTc5e.d.mts} +54 -1
- package/dist/{index-DWS1MdAd.d.ts → index-DIWpTc5e.d.ts} +54 -1
- package/dist/index.cjs +283 -279
- package/dist/index.d.mts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.mjs +1 -1
- package/package.json +3 -3
- package/dist/chunk-AYRG6FET.mjs +0 -18
- package/dist/chunk-VGYBFMBG.cjs +0 -21
|
@@ -0,0 +1,2419 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var chunkTJXDMXEE_cjs = require('./chunk-TJXDMXEE.cjs');
|
|
4
|
+
var kitcore = require('@zapier/kitcore');
|
|
5
|
+
var zod = require('zod');
|
|
6
|
+
|
|
7
|
+
var codeSubstrateDefaults = {
|
|
8
|
+
categories: [chunkTJXDMXEE_cjs.taxonomy.categories["code-workflow"]],
|
|
9
|
+
stability: "beta"
|
|
10
|
+
};
|
|
11
|
+
var CODE_SUBSTRATE_ANALYZER_API = "/code-substrate-analyzer";
|
|
12
|
+
var CODE_SUBSTRATE_RUNNER_API = "/code-substrate-runner/api/v0";
|
|
13
|
+
var CODE_SUBSTRATE_WORKFLOWS_API = "/code-substrate-workflows/api/v0";
|
|
14
|
+
function toWireWorkflowClientAttribution({
|
|
15
|
+
creationHarness,
|
|
16
|
+
creationAccessMethod
|
|
17
|
+
}) {
|
|
18
|
+
if (creationAccessMethod === void 0) return void 0;
|
|
19
|
+
return {
|
|
20
|
+
...creationHarness === void 0 ? {} : { harness: creationHarness },
|
|
21
|
+
access_method: creationAccessMethod,
|
|
22
|
+
sdk_version: chunkTJXDMXEE_cjs.SDK_VERSION
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
var JsonPayloadSchema = zod.z.preprocess((val) => {
|
|
26
|
+
if (typeof val === "string") {
|
|
27
|
+
const trimmed = val.trim();
|
|
28
|
+
if (trimmed.startsWith("{") || trimmed.startsWith("[")) {
|
|
29
|
+
try {
|
|
30
|
+
return JSON.parse(trimmed);
|
|
31
|
+
} catch {
|
|
32
|
+
return val;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
return val;
|
|
37
|
+
}, zod.z.unknown());
|
|
38
|
+
var SourceFilesSchema = zod.z.record(zod.z.string(), zod.z.string()).refine((files) => Object.keys(files).length > 0, {
|
|
39
|
+
message: "sourceFiles must contain at least one file"
|
|
40
|
+
}).describe("Source files keyed by filename \u2192 contents");
|
|
41
|
+
var UUID_PATTERN = /^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$/;
|
|
42
|
+
var ConnectionIdValueSchema = zod.z.union([
|
|
43
|
+
zod.z.string().regex(/^[1-9][0-9]*$/, "must be a positive integer string"),
|
|
44
|
+
zod.z.string().regex(UUID_PATTERN, "must be a UUID"),
|
|
45
|
+
zod.z.number().int().positive()
|
|
46
|
+
]).describe(
|
|
47
|
+
"Zapier connection ID. Accepts a positive integer (legacy) or a UUID string (newer connections)."
|
|
48
|
+
);
|
|
49
|
+
var ConnectionBindingSchema = zod.z.object({
|
|
50
|
+
connectionId: ConnectionIdValueSchema.optional(),
|
|
51
|
+
/** @deprecated Use `connectionId` instead. */
|
|
52
|
+
connection_id: ConnectionIdValueSchema.optional().meta({ deprecated: true })
|
|
53
|
+
});
|
|
54
|
+
var AppVersionBindingSchema = zod.z.object({
|
|
55
|
+
implementationName: zod.z.string().min(1).optional().describe("Zapier app implementation name (e.g. `SlackCLIAPI`)"),
|
|
56
|
+
/** @deprecated Use `implementationName` instead. */
|
|
57
|
+
implementation_name: zod.z.string().min(1).optional().meta({ deprecated: true }),
|
|
58
|
+
version: zod.z.string().optional().describe("Pinned app version (e.g. `1.27.1`). Latest if omitted.")
|
|
59
|
+
});
|
|
60
|
+
function toWireConnections(connections) {
|
|
61
|
+
const wire = {};
|
|
62
|
+
for (const [alias, entry] of Object.entries(connections)) {
|
|
63
|
+
const connectionId = entry.connectionId ?? entry.connection_id;
|
|
64
|
+
if (connectionId === void 0) {
|
|
65
|
+
throw new chunkTJXDMXEE_cjs.ZapierValidationError(
|
|
66
|
+
`connections["${alias}"] is missing connectionId`
|
|
67
|
+
);
|
|
68
|
+
}
|
|
69
|
+
wire[alias] = { connection_id: connectionId };
|
|
70
|
+
}
|
|
71
|
+
return wire;
|
|
72
|
+
}
|
|
73
|
+
var TriggerConfigSchema = zod.z.object({
|
|
74
|
+
selectedApi: zod.z.string().optional().describe(
|
|
75
|
+
"Zapier app/API identifier (e.g. 'GoogleSheetsAPI'). Required when a trigger is configured."
|
|
76
|
+
),
|
|
77
|
+
/** @deprecated Use `selectedApi` instead. */
|
|
78
|
+
selected_api: zod.z.string().optional().meta({ deprecated: true }),
|
|
79
|
+
action: zod.z.string().describe("Trigger action key (e.g. 'new_row')"),
|
|
80
|
+
authenticationId: zod.z.string().nullish().describe(
|
|
81
|
+
"Connection ID for the trigger source. Omit or pass null for no-auth triggers (e.g. Schedule by Zapier)."
|
|
82
|
+
),
|
|
83
|
+
/** @deprecated Use `authenticationId` instead. */
|
|
84
|
+
authentication_id: zod.z.string().nullish().meta({ deprecated: true }),
|
|
85
|
+
params: zod.z.record(zod.z.string(), zod.z.unknown()).optional().describe("Trigger parameters as a JSON object")
|
|
86
|
+
}).describe(
|
|
87
|
+
"Zapier trigger configuration. When set, the workflow subscribes to trigger events."
|
|
88
|
+
);
|
|
89
|
+
function toWireTrigger(trigger) {
|
|
90
|
+
const selectedApi = trigger.selectedApi ?? trigger.selected_api;
|
|
91
|
+
if (selectedApi === void 0) {
|
|
92
|
+
throw new chunkTJXDMXEE_cjs.ZapierValidationError("trigger is missing selectedApi");
|
|
93
|
+
}
|
|
94
|
+
const wire = {
|
|
95
|
+
selected_api: selectedApi,
|
|
96
|
+
action: trigger.action
|
|
97
|
+
};
|
|
98
|
+
if ("authenticationId" in trigger) {
|
|
99
|
+
wire.authentication_id = trigger.authenticationId;
|
|
100
|
+
} else if ("authentication_id" in trigger) {
|
|
101
|
+
wire.authentication_id = trigger.authentication_id;
|
|
102
|
+
}
|
|
103
|
+
if (trigger.params !== void 0) {
|
|
104
|
+
wire.params = trigger.params;
|
|
105
|
+
}
|
|
106
|
+
return wire;
|
|
107
|
+
}
|
|
108
|
+
function toWireAppVersions(appVersions) {
|
|
109
|
+
const wire = {};
|
|
110
|
+
for (const [key, entry] of Object.entries(appVersions)) {
|
|
111
|
+
const implementationName = entry.implementationName ?? entry.implementation_name;
|
|
112
|
+
if (implementationName === void 0) {
|
|
113
|
+
throw new chunkTJXDMXEE_cjs.ZapierValidationError(
|
|
114
|
+
`appVersions["${key}"] is missing implementationName`
|
|
115
|
+
);
|
|
116
|
+
}
|
|
117
|
+
wire[key] = {
|
|
118
|
+
implementation_name: implementationName,
|
|
119
|
+
...entry.version !== void 0 ? { version: entry.version } : {}
|
|
120
|
+
};
|
|
121
|
+
}
|
|
122
|
+
return wire;
|
|
123
|
+
}
|
|
124
|
+
var WorkflowTriggerUrlSchema = zod.z.string().describe(
|
|
125
|
+
"Public URL that fires this workflow when POSTed to. Embeds a trigger token in the path \u2014 treat as sensitive. Requests must also be authenticated as the account."
|
|
126
|
+
);
|
|
127
|
+
var WorkflowEditorUrlSchema = zod.z.string().url().describe("URL to the Zapier workflow editor for this workflow");
|
|
128
|
+
var ConnectionBindingSchema2 = zod.z.object({
|
|
129
|
+
connection_id: zod.z.union([
|
|
130
|
+
zod.z.number().int().positive(),
|
|
131
|
+
zod.z.string().regex(/^[1-9][0-9]*$/, "must be a positive integer string"),
|
|
132
|
+
zod.z.string().uuid("must be a UUID")
|
|
133
|
+
]).describe(
|
|
134
|
+
"Zapier connection ID. Positive integer (legacy) or UUID string (newer)."
|
|
135
|
+
)
|
|
136
|
+
}).describe(
|
|
137
|
+
"Connection binding: maps a single alias to a concrete connection."
|
|
138
|
+
);
|
|
139
|
+
var AppVersionBindingSchema2 = zod.z.object({
|
|
140
|
+
implementation_name: zod.z.string().describe("App implementation identifier (e.g. 'SlackCLIAPI')"),
|
|
141
|
+
version: zod.z.string().optional().describe("App implementation version (e.g. '1.27.1')")
|
|
142
|
+
}).describe("App-version binding: maps a single alias to an app version.");
|
|
143
|
+
var WorkflowDraftStatusSchema = zod.z.enum(["open", "discarded"]).describe("Lifecycle status of a workflow draft.");
|
|
144
|
+
var WorkflowClientAccessMethodSchema = zod.z.enum(["sdk_cli", "sdk_mcp", "zapier_mcp", "editor", "api", "unknown"]).describe(
|
|
145
|
+
"Client access method making this request. `sdk_cli` and `sdk_mcp` are derived by the server from the calling package; `zapier_mcp` is caller-declared."
|
|
146
|
+
);
|
|
147
|
+
var WORKFLOW_CLIENT_ATTRIBUTION_HARNESS_MAX_LENGTH = 64;
|
|
148
|
+
var WORKFLOW_CLIENT_ATTRIBUTION_SDK_VERSION_MAX_LENGTH = 64;
|
|
149
|
+
var WorkflowClientAttributionSchema = zod.z.object({
|
|
150
|
+
harness: zod.z.string().max(WORKFLOW_CLIENT_ATTRIBUTION_HARNESS_MAX_LENGTH).nullable().optional().describe("Client harness that made the request"),
|
|
151
|
+
access_method: zod.z.string().describe("Client access method that made the request (SDK, MCP, etc)"),
|
|
152
|
+
sdk_version: zod.z.string().max(WORKFLOW_CLIENT_ATTRIBUTION_SDK_VERSION_MAX_LENGTH).nullable().optional().describe("Version of the client package or SDK that made the request")
|
|
153
|
+
}).describe("Client identity recorded for a workflow, draft or version write");
|
|
154
|
+
var WorkflowClientAttributionFieldSchema = WorkflowClientAttributionSchema.nullable().optional().describe("Client that made the request").meta({ internal: true });
|
|
155
|
+
var WorkflowClientAttributionInputSchema = zod.z.object({
|
|
156
|
+
creationHarness: WorkflowClientAttributionSchema.shape.harness.describe(
|
|
157
|
+
"Optional client harness making this request; null means the client did not report a harness"
|
|
158
|
+
).meta({ internal: true }),
|
|
159
|
+
creationAccessMethod: WorkflowClientAccessMethodSchema.optional().describe(
|
|
160
|
+
WorkflowClientAccessMethodSchema.description ?? "Client access method making this request"
|
|
161
|
+
).meta({ internal: true })
|
|
162
|
+
});
|
|
163
|
+
function hasAccessMethodForHarness({
|
|
164
|
+
creationHarness,
|
|
165
|
+
creationAccessMethod
|
|
166
|
+
}) {
|
|
167
|
+
return creationHarness === void 0 || creationAccessMethod !== void 0;
|
|
168
|
+
}
|
|
169
|
+
var HARNESS_WITHOUT_ACCESS_METHOD_ISSUE = {
|
|
170
|
+
message: "creationAccessMethod is required when creationHarness is provided",
|
|
171
|
+
path: ["creationAccessMethod"]
|
|
172
|
+
};
|
|
173
|
+
var WorkflowVersionTriggerConfigSchema = zod.z.object({
|
|
174
|
+
selected_api: zod.z.string().describe("Zapier app/API identifier (e.g. 'GoogleSheetsAPI')"),
|
|
175
|
+
action: zod.z.string().describe("Trigger action key (e.g. 'new_row')"),
|
|
176
|
+
authentication_id: zod.z.string().nullish().describe(
|
|
177
|
+
"Connection ID for the trigger source. Omit or pass null for no-auth triggers (e.g. Schedule by Zapier)."
|
|
178
|
+
),
|
|
179
|
+
params: zod.z.record(zod.z.string(), zod.z.unknown()).optional().describe("Trigger parameters as a JSON object")
|
|
180
|
+
}).describe("Trigger configuration persisted on a workflow version.");
|
|
181
|
+
var WorkflowDraftSchema = zod.z.object({
|
|
182
|
+
id: zod.z.string().describe("Workflow draft ID (UUID)"),
|
|
183
|
+
workflow_id: zod.z.string().describe("Parent workflow ID (UUID)"),
|
|
184
|
+
slug: zod.z.string().describe(
|
|
185
|
+
"Human-friendly display name, not an identifier: two open drafts of a workflow may share one"
|
|
186
|
+
),
|
|
187
|
+
base_version_id: zod.z.string().nullable().describe(
|
|
188
|
+
"The version this draft was forked from (the live version at draft creation), or null when the workflow had no published version yet"
|
|
189
|
+
),
|
|
190
|
+
source_files: zod.z.record(zod.z.string(), zod.z.string()).describe("Source files keyed by filename \u2192 contents"),
|
|
191
|
+
zapier_durable_version: zod.z.string().describe("Pinned semver of @zapier/zapier-durable used by this draft"),
|
|
192
|
+
dependencies: zod.z.record(zod.z.string(), zod.z.string()).nullable().describe("Additional npm dependencies pinned for this draft (or null)"),
|
|
193
|
+
draft_revision: zod.z.number().int().describe(
|
|
194
|
+
"Monotonic revision counter for optimistic concurrency. Echo it back on draft updates to detect concurrent edits."
|
|
195
|
+
),
|
|
196
|
+
status: WorkflowDraftStatusSchema,
|
|
197
|
+
created_by_user_id: zod.z.string().describe("ID of the user who created (forked) this draft"),
|
|
198
|
+
last_edited_by_user_id: zod.z.string().nullable().describe("ID of the user who last saved this draft (or null)"),
|
|
199
|
+
last_edited_at: zod.z.string().nullable().describe("When the draft was last edited (ISO-8601, or null)"),
|
|
200
|
+
discarded_at: zod.z.string().nullable().describe("When the draft was discarded (ISO-8601), or null while open"),
|
|
201
|
+
created_at: zod.z.string().describe("When the draft was created (ISO-8601)"),
|
|
202
|
+
updated_at: zod.z.string().describe("When the draft row was last updated (ISO-8601)"),
|
|
203
|
+
trigger: WorkflowVersionTriggerConfigSchema.nullable().describe(
|
|
204
|
+
"Trigger configuration held on this draft, or null for webhook-only workflows."
|
|
205
|
+
),
|
|
206
|
+
connections: zod.z.record(zod.z.string(), ConnectionBindingSchema2).nullable().describe("Connection aliases bound on this draft (or null)."),
|
|
207
|
+
app_versions: zod.z.record(zod.z.string(), AppVersionBindingSchema2).nullable().describe("App-version pins bound on this draft (or null)."),
|
|
208
|
+
creation_client: WorkflowClientAttributionFieldSchema,
|
|
209
|
+
last_edited_client: WorkflowClientAttributionFieldSchema
|
|
210
|
+
});
|
|
211
|
+
var WorkflowVersionSchema = zod.z.object({
|
|
212
|
+
id: zod.z.string().describe("Workflow version ID (UUID)"),
|
|
213
|
+
workflow_id: zod.z.string().describe("Parent workflow ID (UUID)"),
|
|
214
|
+
source_files: zod.z.record(zod.z.string(), zod.z.string()).describe("Source files keyed by filename \u2192 contents"),
|
|
215
|
+
zapier_durable_version: zod.z.string().describe(
|
|
216
|
+
"Pinned semver of @zapier/zapier-durable used by this version's runs"
|
|
217
|
+
),
|
|
218
|
+
dependencies: zod.z.record(zod.z.string(), zod.z.string()).nullable().describe("Additional npm dependencies pinned for this version (or null)"),
|
|
219
|
+
created_by_user_id: zod.z.string().describe("ID of the user who published this version"),
|
|
220
|
+
created_at: zod.z.string().describe("When the version was published (ISO-8601)"),
|
|
221
|
+
trigger: WorkflowVersionTriggerConfigSchema.nullable().describe(
|
|
222
|
+
"Trigger configuration persisted on this version, or null for webhook-only workflows."
|
|
223
|
+
),
|
|
224
|
+
connections: zod.z.record(zod.z.string(), ConnectionBindingSchema2).nullable().describe("Connection aliases bound on this version (or null)."),
|
|
225
|
+
app_versions: zod.z.record(zod.z.string(), AppVersionBindingSchema2).nullable().describe("App-version pins bound on this version (or null)."),
|
|
226
|
+
creation_client: WorkflowClientAttributionFieldSchema
|
|
227
|
+
});
|
|
228
|
+
var WorkflowTriggerStatusSchema = zod.z.enum([
|
|
229
|
+
"unclaimed",
|
|
230
|
+
"pending",
|
|
231
|
+
"active",
|
|
232
|
+
"releasing",
|
|
233
|
+
"released",
|
|
234
|
+
"failed"
|
|
235
|
+
]);
|
|
236
|
+
var WorkflowDisabledReasonSchema = zod.z.enum(["trigger_claim_failed"]);
|
|
237
|
+
var WorkflowTriggerDetailsSchema = zod.z.object({
|
|
238
|
+
webhook_url: zod.z.string().optional().describe(
|
|
239
|
+
"Public catch URL for this trigger. Present on catch-hook triggers (e.g. Webhooks by Zapier)."
|
|
240
|
+
)
|
|
241
|
+
}).describe("Trigger-type-specific metadata. Shape varies by trigger type.");
|
|
242
|
+
var WorkflowTriggerSchema = zod.z.object({
|
|
243
|
+
selected_api: zod.z.string().describe("Zapier app/API identifier (e.g. 'GoogleSheetsAPI')"),
|
|
244
|
+
action: zod.z.string().describe("Trigger action key (e.g. 'new_row')"),
|
|
245
|
+
authentication_id: zod.z.string().nullish().describe(
|
|
246
|
+
"Connection ID for the trigger source. Null for no-auth triggers."
|
|
247
|
+
),
|
|
248
|
+
params: zod.z.record(zod.z.string(), zod.z.unknown()).optional().describe("Trigger parameters as a JSON object"),
|
|
249
|
+
status: WorkflowTriggerStatusSchema.describe(
|
|
250
|
+
"Live trigger claim status \u2014 whether the trigger is currently subscribed to its source."
|
|
251
|
+
),
|
|
252
|
+
// Optional until COSUB-630 ships the field server-side; afterwards the API
|
|
253
|
+
// always sends it (null unless status=failed). Already sanitized at write
|
|
254
|
+
// time — surface verbatim.
|
|
255
|
+
error: zod.z.string().nullable().optional().describe(
|
|
256
|
+
"Failure reason for the latest claim. Present (non-null) only when status is 'failed'."
|
|
257
|
+
),
|
|
258
|
+
// webhook_url is named in this prose because the generated README doesn't
|
|
259
|
+
// expand fields nested this deep.
|
|
260
|
+
details: WorkflowTriggerDetailsSchema.nullable().optional().describe(
|
|
261
|
+
"Trigger-type-specific metadata; shape varies by trigger type (e.g. `webhook_url` on catch-hook triggers). Null or absent when none applies."
|
|
262
|
+
)
|
|
263
|
+
}).describe(
|
|
264
|
+
"Trigger from a workflow's current version, combined with the live claim status."
|
|
265
|
+
);
|
|
266
|
+
|
|
267
|
+
// src/plugins/codeSubstrate/listWorkflows/schemas.ts
|
|
268
|
+
var WorkflowItemSchema = zod.z.object({
|
|
269
|
+
id: zod.z.string().describe("Workflow ID (UUID)"),
|
|
270
|
+
name: zod.z.string().describe("Workflow name"),
|
|
271
|
+
description: zod.z.string().nullable().describe("Optional workflow description (null if unset)"),
|
|
272
|
+
trigger_url: WorkflowTriggerUrlSchema,
|
|
273
|
+
editor_url: WorkflowEditorUrlSchema,
|
|
274
|
+
enabled: zod.z.boolean().describe("Whether the workflow currently accepts triggers"),
|
|
275
|
+
// Optional until COSUB-630 ships the field server-side; afterwards the API
|
|
276
|
+
// always sends it (null unless the workflow was system-disabled).
|
|
277
|
+
disabled_reason: WorkflowDisabledReasonSchema.nullable().optional().describe(
|
|
278
|
+
"Why the workflow is off, when system-disabled. Null when not system-disabled."
|
|
279
|
+
),
|
|
280
|
+
is_private: zod.z.boolean().describe(
|
|
281
|
+
"Whether the workflow is private to the creating user. False means account-visible."
|
|
282
|
+
),
|
|
283
|
+
created_by_user_id: zod.z.string().nullable().describe("User ID of the workflow creator (null in legacy data)"),
|
|
284
|
+
current_version_id: zod.z.string().nullable().describe(
|
|
285
|
+
"ID of the workflow version that runs handle. Null until a version is published."
|
|
286
|
+
),
|
|
287
|
+
triggers: zod.z.array(WorkflowTriggerSchema).describe(
|
|
288
|
+
"Trigger configurations from the current version, with live claim status. Empty array when the workflow has no triggers."
|
|
289
|
+
),
|
|
290
|
+
created_at: zod.z.string().describe("When the workflow was created (ISO-8601)"),
|
|
291
|
+
updated_at: zod.z.string().describe("When the workflow was last modified (ISO-8601)"),
|
|
292
|
+
creation_client: WorkflowClientAttributionFieldSchema
|
|
293
|
+
});
|
|
294
|
+
var ListWorkflowsOptionsSchema = zod.z.object({
|
|
295
|
+
pageSize: zod.z.number().int().min(1).max(100).optional().describe("Number of workflows per page (max 100)"),
|
|
296
|
+
maxItems: zod.z.number().int().min(1).optional().describe("Maximum total workflows to return across all pages"),
|
|
297
|
+
cursor: zod.z.string().optional().describe("Cursor to start from for pagination")
|
|
298
|
+
}).describe("List all active durable workflows for the authenticated account");
|
|
299
|
+
var ListWorkflowsApiResponseSchema = zod.z.object({
|
|
300
|
+
results: zod.z.array(WorkflowItemSchema),
|
|
301
|
+
meta: zod.z.object({
|
|
302
|
+
limit: zod.z.number(),
|
|
303
|
+
cursor: zod.z.string().nullable().optional(),
|
|
304
|
+
next_cursor: zod.z.string().nullable().optional()
|
|
305
|
+
}),
|
|
306
|
+
links: zod.z.object({
|
|
307
|
+
next: zod.z.string().nullable().optional()
|
|
308
|
+
}).optional()
|
|
309
|
+
});
|
|
310
|
+
|
|
311
|
+
// src/plugins/codeSubstrate/listWorkflows/index.ts
|
|
312
|
+
var listWorkflowsPlugin = kitcore.defineMethod({
|
|
313
|
+
...codeSubstrateDefaults,
|
|
314
|
+
name: "listWorkflows",
|
|
315
|
+
imports: [chunkTJXDMXEE_cjs.apiPluginRef],
|
|
316
|
+
type: "list",
|
|
317
|
+
itemType: "Workflow",
|
|
318
|
+
inputSchema: ListWorkflowsOptionsSchema,
|
|
319
|
+
outputSchema: WorkflowItemSchema,
|
|
320
|
+
skipOutputValidation: true,
|
|
321
|
+
// The handler already returns a clean `{ data, nextCursor }` page, so the
|
|
322
|
+
// standard list output (no `adaptPage`) applies.
|
|
323
|
+
output: { type: "list", defaultPageSize: chunkTJXDMXEE_cjs.DEFAULT_PAGE_SIZE },
|
|
324
|
+
run: async ({ imports, input }) => {
|
|
325
|
+
const api = imports.api;
|
|
326
|
+
const searchParams = {};
|
|
327
|
+
if (input.pageSize !== void 0) {
|
|
328
|
+
searchParams.limit = input.pageSize.toString();
|
|
329
|
+
}
|
|
330
|
+
if (input.cursor) {
|
|
331
|
+
searchParams.cursor = input.cursor;
|
|
332
|
+
}
|
|
333
|
+
const raw = await api.get(`${CODE_SUBSTRATE_WORKFLOWS_API}/workflows`, {
|
|
334
|
+
searchParams,
|
|
335
|
+
authRequired: true
|
|
336
|
+
});
|
|
337
|
+
const response = ListWorkflowsApiResponseSchema.parse(raw);
|
|
338
|
+
return {
|
|
339
|
+
data: response.results,
|
|
340
|
+
nextCursor: response.meta.next_cursor ?? void 0
|
|
341
|
+
};
|
|
342
|
+
}
|
|
343
|
+
});
|
|
344
|
+
var WorkflowVersionSchema2 = zod.z.object({
|
|
345
|
+
id: zod.z.string().describe("Workflow version ID (UUID)"),
|
|
346
|
+
workflow_id: zod.z.string().describe("Parent workflow ID"),
|
|
347
|
+
source_files: zod.z.record(zod.z.string(), zod.z.string()).describe("Source files keyed by filename \u2192 contents"),
|
|
348
|
+
zapier_durable_version: zod.z.string().describe(
|
|
349
|
+
"Pinned semver of @zapier/zapier-durable used by this version's runs"
|
|
350
|
+
),
|
|
351
|
+
dependencies: zod.z.record(zod.z.string(), zod.z.string()).nullable().describe("Additional npm dependencies pinned for this version (or null)"),
|
|
352
|
+
// Backend column is NOT NULL (see code-substrate-workflows prisma schema:
|
|
353
|
+
// workflow_versions.created_by_user_id), so this is always emitted.
|
|
354
|
+
created_by_user_id: zod.z.string().describe("ID of the user who published this version"),
|
|
355
|
+
created_at: zod.z.string().describe("When the version was published (ISO-8601)"),
|
|
356
|
+
trigger: WorkflowVersionTriggerConfigSchema.nullable().describe(
|
|
357
|
+
"Trigger configuration persisted on this version, or null for webhook-only workflows."
|
|
358
|
+
),
|
|
359
|
+
connections: zod.z.record(zod.z.string(), ConnectionBindingSchema2).nullable().describe("Connection aliases bound on this version (or null)."),
|
|
360
|
+
app_versions: zod.z.record(zod.z.string(), AppVersionBindingSchema2).nullable().describe("App-version pins bound on this version (or null)."),
|
|
361
|
+
creation_client: WorkflowClientAttributionFieldSchema
|
|
362
|
+
});
|
|
363
|
+
var GetWorkflowOptionsSchema = zod.z.object({
|
|
364
|
+
workflow: zod.z.string().uuid().describe("Durable workflow ID")
|
|
365
|
+
}).describe(
|
|
366
|
+
"Get a durable workflow with its current version details and trigger claim status"
|
|
367
|
+
);
|
|
368
|
+
var GetWorkflowResponseSchema = zod.z.object({
|
|
369
|
+
id: zod.z.string().describe("Workflow ID (UUID)"),
|
|
370
|
+
name: zod.z.string().describe("Workflow name"),
|
|
371
|
+
description: zod.z.string().nullable().describe("Optional workflow description (null if unset)"),
|
|
372
|
+
trigger_url: WorkflowTriggerUrlSchema,
|
|
373
|
+
editor_url: WorkflowEditorUrlSchema,
|
|
374
|
+
enabled: zod.z.boolean().describe("Whether the workflow currently accepts triggers"),
|
|
375
|
+
// Optional until COSUB-630 ships the field server-side; afterwards the API
|
|
376
|
+
// always sends it (null unless the workflow was system-disabled). Kept
|
|
377
|
+
// independent of per-trigger status+error — see WorkflowDisabledReasonSchema.
|
|
378
|
+
disabled_reason: WorkflowDisabledReasonSchema.nullable().optional().describe(
|
|
379
|
+
"Why the workflow is off, when system-disabled. Null when not system-disabled. Independent of per-trigger claim status: an enabled workflow can still have a failed trigger."
|
|
380
|
+
),
|
|
381
|
+
is_private: zod.z.boolean().describe(
|
|
382
|
+
"Whether the workflow is private to the creating user. False means account-visible."
|
|
383
|
+
),
|
|
384
|
+
created_by_user_id: zod.z.string().nullable().describe("User ID of the workflow creator (null in legacy data)"),
|
|
385
|
+
current_version: WorkflowVersionSchema2.optional().describe(
|
|
386
|
+
"The currently published version, if any. Absent for workflows with no version published yet."
|
|
387
|
+
),
|
|
388
|
+
triggers: zod.z.array(WorkflowTriggerSchema).describe(
|
|
389
|
+
"Trigger configurations from the current version, with live claim status. Empty array when the workflow has no triggers."
|
|
390
|
+
),
|
|
391
|
+
created_at: zod.z.string().describe("When the workflow was created (ISO-8601)"),
|
|
392
|
+
updated_at: zod.z.string().describe("When the workflow was last modified (ISO-8601)"),
|
|
393
|
+
creation_client: WorkflowClientAttributionFieldSchema
|
|
394
|
+
});
|
|
395
|
+
|
|
396
|
+
// src/plugins/codeSubstrate/getWorkflow/index.ts
|
|
397
|
+
var getWorkflowPlugin = kitcore.defineMethod({
|
|
398
|
+
...codeSubstrateDefaults,
|
|
399
|
+
name: "getWorkflow",
|
|
400
|
+
imports: [chunkTJXDMXEE_cjs.apiPluginRef],
|
|
401
|
+
itemType: "Workflow",
|
|
402
|
+
inputSchema: GetWorkflowOptionsSchema,
|
|
403
|
+
outputSchema: GetWorkflowResponseSchema,
|
|
404
|
+
skipOutputValidation: true,
|
|
405
|
+
output: "item",
|
|
406
|
+
resolvers: { workflow: chunkTJXDMXEE_cjs.workflowIdResolver },
|
|
407
|
+
run: async ({ imports, input }) => {
|
|
408
|
+
const api = imports.api;
|
|
409
|
+
const raw = await api.get(
|
|
410
|
+
`${CODE_SUBSTRATE_WORKFLOWS_API}/workflows/${encodeURIComponent(input.workflow)}`,
|
|
411
|
+
{
|
|
412
|
+
authRequired: true,
|
|
413
|
+
resource: { type: "workflow", id: input.workflow }
|
|
414
|
+
}
|
|
415
|
+
);
|
|
416
|
+
return { data: GetWorkflowResponseSchema.parse(raw) };
|
|
417
|
+
}
|
|
418
|
+
});
|
|
419
|
+
var CreateWorkflowOptionsSchema = zod.z.object({
|
|
420
|
+
name: zod.z.string().min(1).describe("Workflow name"),
|
|
421
|
+
description: zod.z.string().optional().describe("Optional description for the workflow"),
|
|
422
|
+
private: zod.z.boolean().optional().describe(
|
|
423
|
+
"If true, only the creating user can see or manage this workflow. Defaults to false (account-visible)."
|
|
424
|
+
),
|
|
425
|
+
...WorkflowClientAttributionInputSchema.shape,
|
|
426
|
+
/** @deprecated Use `private` instead. */
|
|
427
|
+
is_private: zod.z.boolean().optional().describe(
|
|
428
|
+
"If true, only the creating user can see or manage this workflow. Defaults to false (account-visible)."
|
|
429
|
+
).meta({ deprecated: true })
|
|
430
|
+
}).refine(hasAccessMethodForHarness, HARNESS_WITHOUT_ACCESS_METHOD_ISSUE).describe(
|
|
431
|
+
"Create a durable workflow container. Starts disabled with no version; publish a version to add code."
|
|
432
|
+
);
|
|
433
|
+
var CreateWorkflowResponseSchema = zod.z.object({
|
|
434
|
+
id: zod.z.string().describe("Workflow ID (UUID)"),
|
|
435
|
+
name: zod.z.string().describe("Workflow name"),
|
|
436
|
+
description: zod.z.string().nullable().describe("Workflow description (null if unset)"),
|
|
437
|
+
trigger_url: WorkflowTriggerUrlSchema,
|
|
438
|
+
editor_url: WorkflowEditorUrlSchema,
|
|
439
|
+
enabled: zod.z.boolean().describe(
|
|
440
|
+
"Whether the workflow currently accepts triggers. Always false on a new workflow until enabled."
|
|
441
|
+
),
|
|
442
|
+
is_private: zod.z.boolean().describe(
|
|
443
|
+
"Whether the workflow is private to the creating user. False means account-visible."
|
|
444
|
+
),
|
|
445
|
+
created_by_user_id: zod.z.string().nullable().describe("User ID of the workflow creator (null in legacy data)"),
|
|
446
|
+
created_at: zod.z.string().describe("When the workflow was created (ISO-8601)"),
|
|
447
|
+
creation_client: WorkflowClientAttributionFieldSchema
|
|
448
|
+
});
|
|
449
|
+
|
|
450
|
+
// src/plugins/codeSubstrate/createWorkflow/index.ts
|
|
451
|
+
var createWorkflowPlugin = kitcore.defineMethod({
|
|
452
|
+
...codeSubstrateDefaults,
|
|
453
|
+
name: "createWorkflow",
|
|
454
|
+
imports: [chunkTJXDMXEE_cjs.apiPluginRef],
|
|
455
|
+
type: "create",
|
|
456
|
+
itemType: "Workflow",
|
|
457
|
+
inputSchema: CreateWorkflowOptionsSchema,
|
|
458
|
+
outputSchema: CreateWorkflowResponseSchema,
|
|
459
|
+
skipOutputValidation: true,
|
|
460
|
+
output: "item",
|
|
461
|
+
run: async ({ imports, input }) => {
|
|
462
|
+
const api = imports.api;
|
|
463
|
+
const body = { name: input.name };
|
|
464
|
+
if (input.description !== void 0) {
|
|
465
|
+
body.description = input.description;
|
|
466
|
+
}
|
|
467
|
+
const isPrivate = input.private ?? input.is_private;
|
|
468
|
+
if (isPrivate !== void 0) {
|
|
469
|
+
body.is_private = isPrivate;
|
|
470
|
+
}
|
|
471
|
+
const creationClient = toWireWorkflowClientAttribution(input);
|
|
472
|
+
if (creationClient !== void 0) {
|
|
473
|
+
body.creation_client = creationClient;
|
|
474
|
+
}
|
|
475
|
+
const raw = await api.post(
|
|
476
|
+
`${CODE_SUBSTRATE_WORKFLOWS_API}/workflows`,
|
|
477
|
+
body,
|
|
478
|
+
{
|
|
479
|
+
authRequired: true
|
|
480
|
+
}
|
|
481
|
+
);
|
|
482
|
+
return { data: CreateWorkflowResponseSchema.parse(raw) };
|
|
483
|
+
}
|
|
484
|
+
});
|
|
485
|
+
var ImportWorkflowOptionsSchema = zod.z.object({
|
|
486
|
+
zap: zod.z.string().min(1).max(128).describe(
|
|
487
|
+
"ID of the Zap to import. Must be owned by the requesting user. Recorded on the created workflow as source_zap_id."
|
|
488
|
+
),
|
|
489
|
+
name: zod.z.string().optional().describe(
|
|
490
|
+
`Name for the created workflow. Defaults to a kebab-cased form of the Zap's title, or "imported-workflow" when the Zap has no title.`
|
|
491
|
+
),
|
|
492
|
+
private: zod.z.boolean().optional().describe(
|
|
493
|
+
"Restrict the created workflow to the creating user. Defaults to false, which makes it account-visible."
|
|
494
|
+
),
|
|
495
|
+
...WorkflowClientAttributionInputSchema.shape
|
|
496
|
+
}).refine(hasAccessMethodForHarness, HARNESS_WITHOUT_ACCESS_METHOD_ISSUE).describe(
|
|
497
|
+
"Convert an existing Zap into a durable workflow. Transforms the Zap's latest published version (falling back to its draft only when the Zap has never been published) and puts the resulting source in an open draft. The workflow is created disabled with no published version, so publish the draft to make it live. The original Zap is untouched and keeps running."
|
|
498
|
+
);
|
|
499
|
+
var TranslationIssueSchema = zod.z.object({
|
|
500
|
+
line: zod.z.number().int().describe(
|
|
501
|
+
"1-based line in the generated source the issue relates to, or 0 when not line-specific."
|
|
502
|
+
),
|
|
503
|
+
column: zod.z.number().int().describe("1-based column, or 0 when not column-specific."),
|
|
504
|
+
node_kind: zod.z.string().describe(
|
|
505
|
+
'Category of the issue, used to group and message them, e.g. "invalid-connection-id", "DelayStep", "app-version-conflict".'
|
|
506
|
+
),
|
|
507
|
+
step_name: zod.z.string().optional().describe("ZDL step id or name the issue originated from, when known."),
|
|
508
|
+
message: zod.z.string().describe("Human-readable description of the issue."),
|
|
509
|
+
blocking: zod.z.boolean().describe(
|
|
510
|
+
"Whether the issue must be resolved before the draft can be published. Computed server-side, so callers do not re-derive it. A blocking issue does not prevent the draft being created."
|
|
511
|
+
)
|
|
512
|
+
});
|
|
513
|
+
var ImportedWorkflowSchema = zod.z.object({
|
|
514
|
+
id: zod.z.string().describe("Workflow ID (UUID)"),
|
|
515
|
+
name: zod.z.string().describe("Workflow name"),
|
|
516
|
+
description: zod.z.string().nullable().optional().describe("Optional workflow description (null if unset)"),
|
|
517
|
+
trigger_url: WorkflowTriggerUrlSchema,
|
|
518
|
+
editor_url: WorkflowEditorUrlSchema,
|
|
519
|
+
enabled: zod.z.boolean().describe(
|
|
520
|
+
"Whether the workflow accepts triggers. An import always lands disabled."
|
|
521
|
+
),
|
|
522
|
+
disabled_reason: WorkflowDisabledReasonSchema.nullable().optional().describe("Why the workflow is off, when system-disabled."),
|
|
523
|
+
is_private: zod.z.boolean().describe(
|
|
524
|
+
"Whether the workflow is private to the creating user. False means account-visible."
|
|
525
|
+
),
|
|
526
|
+
source_zap_id: zod.z.string().nullable().optional().describe("The Zap this workflow was imported from."),
|
|
527
|
+
created_by_user_id: zod.z.string(),
|
|
528
|
+
updated_by_user_id: zod.z.string().nullable().optional(),
|
|
529
|
+
current_version_id: zod.z.string().nullable().optional().describe("Null on a fresh import, which has no published version yet."),
|
|
530
|
+
triggers: zod.z.array(WorkflowTriggerSchema).describe("Empty on a fresh import, which has no published version yet."),
|
|
531
|
+
created_at: zod.z.string(),
|
|
532
|
+
updated_at: zod.z.string().optional()
|
|
533
|
+
});
|
|
534
|
+
var ImportWorkflowResponseSchema = zod.z.object({
|
|
535
|
+
workflow: ImportedWorkflowSchema.describe(
|
|
536
|
+
"The created workflow. Disabled, with no published version, and source_zap_id set to the imported Zap."
|
|
537
|
+
),
|
|
538
|
+
draft: WorkflowDraftSchema.describe(
|
|
539
|
+
"The open draft holding the transformed source."
|
|
540
|
+
),
|
|
541
|
+
issues: zod.z.array(TranslationIssueSchema).describe(
|
|
542
|
+
"Blocking and non-blocking translation issues from the transform, passed through unchanged. Blocking issues do not prevent draft creation; they must be resolved before the draft will publish."
|
|
543
|
+
)
|
|
544
|
+
});
|
|
545
|
+
|
|
546
|
+
// src/plugins/codeSubstrate/importWorkflow/index.ts
|
|
547
|
+
var importWorkflowPlugin = kitcore.defineMethod({
|
|
548
|
+
...codeSubstrateDefaults,
|
|
549
|
+
name: "importWorkflow",
|
|
550
|
+
imports: [chunkTJXDMXEE_cjs.apiPluginRef],
|
|
551
|
+
type: "create",
|
|
552
|
+
itemType: "Workflow",
|
|
553
|
+
// The response is the composite `{ workflow, draft, issues }`, not the bare
|
|
554
|
+
// `WorkflowItem` the docs generator derives from itemType.
|
|
555
|
+
returnType: "ImportWorkflowResponse",
|
|
556
|
+
inputSchema: ImportWorkflowOptionsSchema,
|
|
557
|
+
outputSchema: ImportWorkflowResponseSchema,
|
|
558
|
+
skipOutputValidation: true,
|
|
559
|
+
output: "item",
|
|
560
|
+
run: async ({ imports, input }) => {
|
|
561
|
+
const api = imports.api;
|
|
562
|
+
const body = { zap_id: input.zap };
|
|
563
|
+
if (input.name !== void 0) {
|
|
564
|
+
body.name = input.name;
|
|
565
|
+
}
|
|
566
|
+
if (input.private !== void 0) {
|
|
567
|
+
body.is_private = input.private;
|
|
568
|
+
}
|
|
569
|
+
const creationClient = toWireWorkflowClientAttribution(input);
|
|
570
|
+
if (creationClient !== void 0) {
|
|
571
|
+
body.creation_client = creationClient;
|
|
572
|
+
}
|
|
573
|
+
const raw = await api.post(
|
|
574
|
+
`${CODE_SUBSTRATE_WORKFLOWS_API}/workflows/import`,
|
|
575
|
+
body,
|
|
576
|
+
{
|
|
577
|
+
authRequired: true,
|
|
578
|
+
// Import is owner-gated upstream: the endpoint refuses a Zap the
|
|
579
|
+
// requesting user does not own. A bare 403 tells the caller nothing
|
|
580
|
+
// about which gate they hit or what to do, so name both.
|
|
581
|
+
customErrorHandler: ({ status, data }) => {
|
|
582
|
+
if (status === 403) {
|
|
583
|
+
const detail = chunkTJXDMXEE_cjs.extractErrorDetail(data);
|
|
584
|
+
return new chunkTJXDMXEE_cjs.ZapierApiError(
|
|
585
|
+
`${detail ?? "Zap import forbidden"} \u2014 only Zaps owned by the requesting user can be imported. Check the Zap ID belongs to this user, or ask its owner to run the import. Retrying will not help.`,
|
|
586
|
+
{ statusCode: status }
|
|
587
|
+
);
|
|
588
|
+
}
|
|
589
|
+
return void 0;
|
|
590
|
+
}
|
|
591
|
+
}
|
|
592
|
+
);
|
|
593
|
+
return { data: ImportWorkflowResponseSchema.parse(raw) };
|
|
594
|
+
}
|
|
595
|
+
});
|
|
596
|
+
var UpdateWorkflowOptionsSchema = zod.z.object({
|
|
597
|
+
workflow: zod.z.string().uuid().describe("Durable workflow ID"),
|
|
598
|
+
name: zod.z.string().min(1).optional().describe("New name for the workflow"),
|
|
599
|
+
description: zod.z.string().nullish().describe("New description for the workflow (pass null to clear)")
|
|
600
|
+
}).refine((data) => data.name !== void 0 || data.description !== void 0, {
|
|
601
|
+
message: "Provide name or description (at least one is required)"
|
|
602
|
+
}).describe("Update a durable workflow's name and/or description");
|
|
603
|
+
var UpdateWorkflowResponseSchema = zod.z.object({
|
|
604
|
+
id: zod.z.string().describe("Workflow ID (UUID)"),
|
|
605
|
+
name: zod.z.string().describe("Workflow name (post-update)"),
|
|
606
|
+
description: zod.z.string().nullable().describe("Workflow description, post-update (null if unset)"),
|
|
607
|
+
trigger_url: WorkflowTriggerUrlSchema,
|
|
608
|
+
editor_url: WorkflowEditorUrlSchema,
|
|
609
|
+
enabled: zod.z.boolean().describe("Whether the workflow currently accepts triggers"),
|
|
610
|
+
is_private: zod.z.boolean().describe(
|
|
611
|
+
"Whether the workflow is private to the creating user. False means account-visible."
|
|
612
|
+
),
|
|
613
|
+
created_by_user_id: zod.z.string().nullable().describe("User ID of the workflow creator (null in legacy data)"),
|
|
614
|
+
created_at: zod.z.string().describe("When the workflow was created (ISO-8601)"),
|
|
615
|
+
updated_at: zod.z.string().describe("When this update was applied (ISO-8601)")
|
|
616
|
+
});
|
|
617
|
+
|
|
618
|
+
// src/plugins/codeSubstrate/updateWorkflow/index.ts
|
|
619
|
+
var updateWorkflowPlugin = kitcore.defineMethod({
|
|
620
|
+
...codeSubstrateDefaults,
|
|
621
|
+
name: "updateWorkflow",
|
|
622
|
+
imports: [chunkTJXDMXEE_cjs.apiPluginRef],
|
|
623
|
+
type: "update",
|
|
624
|
+
itemType: "Workflow",
|
|
625
|
+
inputSchema: UpdateWorkflowOptionsSchema,
|
|
626
|
+
outputSchema: UpdateWorkflowResponseSchema,
|
|
627
|
+
skipOutputValidation: true,
|
|
628
|
+
output: "item",
|
|
629
|
+
resolvers: { workflow: chunkTJXDMXEE_cjs.workflowIdResolver },
|
|
630
|
+
run: async ({ imports, input }) => {
|
|
631
|
+
const api = imports.api;
|
|
632
|
+
const body = {};
|
|
633
|
+
if (input.name !== void 0) {
|
|
634
|
+
body.name = input.name;
|
|
635
|
+
}
|
|
636
|
+
if (input.description !== void 0) {
|
|
637
|
+
body.description = input.description;
|
|
638
|
+
}
|
|
639
|
+
const raw = await api.patch(
|
|
640
|
+
`${CODE_SUBSTRATE_WORKFLOWS_API}/workflows/${encodeURIComponent(input.workflow)}`,
|
|
641
|
+
body,
|
|
642
|
+
{
|
|
643
|
+
authRequired: true,
|
|
644
|
+
resource: { type: "workflow", id: input.workflow }
|
|
645
|
+
}
|
|
646
|
+
);
|
|
647
|
+
return { data: UpdateWorkflowResponseSchema.parse(raw) };
|
|
648
|
+
}
|
|
649
|
+
});
|
|
650
|
+
var EnableWorkflowOptionsSchema = zod.z.object({
|
|
651
|
+
workflow: zod.z.string().uuid().describe("Durable workflow ID")
|
|
652
|
+
}).describe("Enable a durable workflow so it accepts triggers");
|
|
653
|
+
var EnableWorkflowResponseSchema = zod.z.object({
|
|
654
|
+
id: zod.z.string().describe("Workflow ID (UUID)"),
|
|
655
|
+
enabled: zod.z.boolean().describe("Workflow's enabled state after the operation (always true)")
|
|
656
|
+
});
|
|
657
|
+
|
|
658
|
+
// src/plugins/codeSubstrate/enableWorkflow/index.ts
|
|
659
|
+
var enableWorkflowPlugin = kitcore.defineMethod({
|
|
660
|
+
...codeSubstrateDefaults,
|
|
661
|
+
name: "enableWorkflow",
|
|
662
|
+
imports: [chunkTJXDMXEE_cjs.apiPluginRef],
|
|
663
|
+
type: "update",
|
|
664
|
+
itemType: "Workflow",
|
|
665
|
+
inputSchema: EnableWorkflowOptionsSchema,
|
|
666
|
+
outputSchema: EnableWorkflowResponseSchema,
|
|
667
|
+
skipOutputValidation: true,
|
|
668
|
+
output: "item",
|
|
669
|
+
resolvers: { workflow: chunkTJXDMXEE_cjs.workflowIdResolver },
|
|
670
|
+
run: async ({ imports, input }) => {
|
|
671
|
+
const api = imports.api;
|
|
672
|
+
const raw = await api.post(
|
|
673
|
+
`${CODE_SUBSTRATE_WORKFLOWS_API}/workflows/${encodeURIComponent(input.workflow)}/enable`,
|
|
674
|
+
void 0,
|
|
675
|
+
{
|
|
676
|
+
authRequired: true,
|
|
677
|
+
resource: { type: "workflow", id: input.workflow }
|
|
678
|
+
}
|
|
679
|
+
);
|
|
680
|
+
return { data: EnableWorkflowResponseSchema.parse(raw) };
|
|
681
|
+
}
|
|
682
|
+
});
|
|
683
|
+
var DisableWorkflowOptionsSchema = zod.z.object({
|
|
684
|
+
workflow: zod.z.string().uuid().describe("Durable workflow ID")
|
|
685
|
+
}).describe("Disable a durable workflow so it stops accepting triggers");
|
|
686
|
+
var DisableWorkflowResponseSchema = zod.z.object({
|
|
687
|
+
id: zod.z.string().describe("Workflow ID (UUID)"),
|
|
688
|
+
enabled: zod.z.boolean().describe(
|
|
689
|
+
"Workflow's enabled state after the operation. Typically false; mirrors the row's true state in case a concurrent enable raced with this call."
|
|
690
|
+
)
|
|
691
|
+
});
|
|
692
|
+
|
|
693
|
+
// src/plugins/codeSubstrate/disableWorkflow/index.ts
|
|
694
|
+
var disableWorkflowPlugin = kitcore.defineMethod({
|
|
695
|
+
...codeSubstrateDefaults,
|
|
696
|
+
name: "disableWorkflow",
|
|
697
|
+
imports: [chunkTJXDMXEE_cjs.apiPluginRef],
|
|
698
|
+
type: "update",
|
|
699
|
+
itemType: "Workflow",
|
|
700
|
+
inputSchema: DisableWorkflowOptionsSchema,
|
|
701
|
+
outputSchema: DisableWorkflowResponseSchema,
|
|
702
|
+
skipOutputValidation: true,
|
|
703
|
+
output: "item",
|
|
704
|
+
resolvers: { workflow: chunkTJXDMXEE_cjs.workflowIdResolver },
|
|
705
|
+
run: async ({ imports, input }) => {
|
|
706
|
+
const api = imports.api;
|
|
707
|
+
const raw = await api.post(
|
|
708
|
+
`${CODE_SUBSTRATE_WORKFLOWS_API}/workflows/${encodeURIComponent(input.workflow)}/disable`,
|
|
709
|
+
void 0,
|
|
710
|
+
{
|
|
711
|
+
authRequired: true,
|
|
712
|
+
resource: { type: "workflow", id: input.workflow }
|
|
713
|
+
}
|
|
714
|
+
);
|
|
715
|
+
return { data: DisableWorkflowResponseSchema.parse(raw) };
|
|
716
|
+
}
|
|
717
|
+
});
|
|
718
|
+
var DeleteWorkflowOptionsSchema = zod.z.object({
|
|
719
|
+
workflow: zod.z.string().uuid().describe("Durable workflow ID")
|
|
720
|
+
}).describe(
|
|
721
|
+
"Delete a durable workflow. Throws `ZapierNotFoundError` if the workflow doesn't exist; callers wanting idempotency should catch that themselves."
|
|
722
|
+
);
|
|
723
|
+
var DeleteWorkflowResponseSchema = zod.z.object({
|
|
724
|
+
id: zod.z.string().describe("Workflow ID that was targeted for deletion")
|
|
725
|
+
});
|
|
726
|
+
|
|
727
|
+
// src/plugins/codeSubstrate/deleteWorkflow/index.ts
|
|
728
|
+
var deleteWorkflowPlugin = kitcore.defineMethod({
|
|
729
|
+
...codeSubstrateDefaults,
|
|
730
|
+
name: "deleteWorkflow",
|
|
731
|
+
imports: [chunkTJXDMXEE_cjs.apiPluginRef],
|
|
732
|
+
type: "delete",
|
|
733
|
+
itemType: "Workflow",
|
|
734
|
+
confirm: "delete",
|
|
735
|
+
inputSchema: DeleteWorkflowOptionsSchema,
|
|
736
|
+
outputSchema: DeleteWorkflowResponseSchema,
|
|
737
|
+
skipOutputValidation: true,
|
|
738
|
+
output: "raw",
|
|
739
|
+
resolvers: { workflow: chunkTJXDMXEE_cjs.workflowIdResolver },
|
|
740
|
+
run: async ({ imports, input }) => {
|
|
741
|
+
const api = imports.api;
|
|
742
|
+
await api.delete(
|
|
743
|
+
`${CODE_SUBSTRATE_WORKFLOWS_API}/workflows/${encodeURIComponent(input.workflow)}`,
|
|
744
|
+
void 0,
|
|
745
|
+
{
|
|
746
|
+
authRequired: true,
|
|
747
|
+
resource: { type: "workflow", id: input.workflow }
|
|
748
|
+
}
|
|
749
|
+
);
|
|
750
|
+
return { data: { id: input.workflow } };
|
|
751
|
+
}
|
|
752
|
+
});
|
|
753
|
+
var RunStatusSchema = kitcore.openEnum(
|
|
754
|
+
["initialized", "started", "finished", "failed", "cancelled"],
|
|
755
|
+
"Run lifecycle status. `finished` / `failed` / `cancelled` are terminal."
|
|
756
|
+
);
|
|
757
|
+
var RunErrorSchema = zod.z.object({
|
|
758
|
+
code: zod.z.string().describe("Machine-readable error category"),
|
|
759
|
+
message: zod.z.string().describe("Human-readable error summary")
|
|
760
|
+
}).passthrough().describe(
|
|
761
|
+
"Structured run error. Always carries `code` and `message`; additional keys may appear depending on the error type."
|
|
762
|
+
);
|
|
763
|
+
var RunItemSchema = zod.z.object({
|
|
764
|
+
id: zod.z.string().describe("Run ID (UUID)"),
|
|
765
|
+
status: RunStatusSchema,
|
|
766
|
+
input: zod.z.unknown().describe("Input data passed to the run"),
|
|
767
|
+
output: zod.z.unknown().nullable().describe("Return value, present when status is `finished`"),
|
|
768
|
+
error: RunErrorSchema.nullable().describe(
|
|
769
|
+
"Structured error details when the run failed (null otherwise)"
|
|
770
|
+
),
|
|
771
|
+
execution_id: zod.z.string().nullable().describe(
|
|
772
|
+
"Linked execution ID. Null until the run leaves the `initialized` state."
|
|
773
|
+
),
|
|
774
|
+
is_private: zod.z.boolean().describe(
|
|
775
|
+
"When true, the run is visible only to the creating user; otherwise visible across the account."
|
|
776
|
+
),
|
|
777
|
+
created_at: zod.z.string().describe("When the run was created (ISO-8601)"),
|
|
778
|
+
updated_at: zod.z.string().describe("When the run was last updated (ISO-8601)")
|
|
779
|
+
});
|
|
780
|
+
var ListDurableRunsOptionsSchema = zod.z.object({
|
|
781
|
+
pageSize: zod.z.number().min(1).max(100).optional().describe("Number of runs per page (max 100)"),
|
|
782
|
+
cursor: zod.z.string().optional().describe("Pagination cursor"),
|
|
783
|
+
maxItems: zod.z.number().min(1).optional().describe("Maximum total items to return across all pages")
|
|
784
|
+
}).describe(
|
|
785
|
+
"List run-once durable runs for the authenticated account, newest first"
|
|
786
|
+
);
|
|
787
|
+
var ListDurableRunsApiResponseSchema = zod.z.object({
|
|
788
|
+
results: zod.z.array(RunItemSchema),
|
|
789
|
+
meta: zod.z.object({
|
|
790
|
+
limit: zod.z.number(),
|
|
791
|
+
cursor: zod.z.string().nullable().optional(),
|
|
792
|
+
next_cursor: zod.z.string().nullable().optional()
|
|
793
|
+
}),
|
|
794
|
+
links: zod.z.object({
|
|
795
|
+
next: zod.z.string().nullable().optional()
|
|
796
|
+
}).optional()
|
|
797
|
+
});
|
|
798
|
+
|
|
799
|
+
// src/plugins/codeSubstrate/listDurableRuns/index.ts
|
|
800
|
+
var listDurableRunsPlugin = kitcore.defineMethod({
|
|
801
|
+
...codeSubstrateDefaults,
|
|
802
|
+
name: "listDurableRuns",
|
|
803
|
+
imports: [chunkTJXDMXEE_cjs.apiPluginRef],
|
|
804
|
+
type: "list",
|
|
805
|
+
itemType: "DurableRun",
|
|
806
|
+
inputSchema: ListDurableRunsOptionsSchema,
|
|
807
|
+
outputSchema: RunItemSchema,
|
|
808
|
+
skipOutputValidation: true,
|
|
809
|
+
// The handler already returns a clean `{ data, nextCursor }` page, so the
|
|
810
|
+
// standard list output (no `adaptPage`) applies.
|
|
811
|
+
output: { type: "list", defaultPageSize: chunkTJXDMXEE_cjs.DEFAULT_PAGE_SIZE },
|
|
812
|
+
run: async ({ imports, input }) => {
|
|
813
|
+
const api = imports.api;
|
|
814
|
+
const searchParams = {};
|
|
815
|
+
if (input.pageSize !== void 0) {
|
|
816
|
+
searchParams.limit = input.pageSize.toString();
|
|
817
|
+
}
|
|
818
|
+
if (input.cursor) {
|
|
819
|
+
searchParams.cursor = input.cursor;
|
|
820
|
+
}
|
|
821
|
+
const raw = await api.get(`${CODE_SUBSTRATE_RUNNER_API}/runs`, {
|
|
822
|
+
searchParams,
|
|
823
|
+
authRequired: true
|
|
824
|
+
});
|
|
825
|
+
const response = ListDurableRunsApiResponseSchema.parse(raw);
|
|
826
|
+
return {
|
|
827
|
+
data: response.results,
|
|
828
|
+
nextCursor: response.meta.next_cursor ?? void 0
|
|
829
|
+
};
|
|
830
|
+
}
|
|
831
|
+
});
|
|
832
|
+
var OperationTypeSchema = kitcore.openEnum(
|
|
833
|
+
["step", "wait", "callback"],
|
|
834
|
+
"Operation kind: `step` is a journaled function call; `wait` is a time-based suspension; `callback` is a wait on an external callback."
|
|
835
|
+
);
|
|
836
|
+
var OperationStatusSchema = kitcore.openEnum(
|
|
837
|
+
["pending", "completed", "failed", "exhausted", "expired"],
|
|
838
|
+
"Operation lifecycle status. `exhausted` means retries were exceeded; `expired` means a callback's deadline passed without delivery."
|
|
839
|
+
);
|
|
840
|
+
var OperationSchema = zod.z.object({
|
|
841
|
+
id: zod.z.string().describe("Operation ID (UUID)"),
|
|
842
|
+
execution_id: zod.z.string().describe("Parent execution ID"),
|
|
843
|
+
name: zod.z.string().describe("Operation name as declared by the workflow author"),
|
|
844
|
+
type: OperationTypeSchema,
|
|
845
|
+
status: OperationStatusSchema,
|
|
846
|
+
result: zod.z.unknown().optional().describe("Result value when the operation completed"),
|
|
847
|
+
error: zod.z.unknown().optional().describe("Error payload when the operation failed"),
|
|
848
|
+
retry_count: zod.z.number().describe("Number of retry attempts so far"),
|
|
849
|
+
max_attempts: zod.z.number().optional().describe(
|
|
850
|
+
"Cap on total attempts for this operation. Absent if no cap applies."
|
|
851
|
+
),
|
|
852
|
+
next_retry_at: zod.z.string().nullable().optional().describe("When the next retry will be attempted (ISO-8601)"),
|
|
853
|
+
resume_at: zod.z.string().nullable().optional().describe(
|
|
854
|
+
"When a `wait` operation resumes (ISO-8601). Set only for type=wait."
|
|
855
|
+
),
|
|
856
|
+
callback_token: zod.z.string().nullable().optional().describe(
|
|
857
|
+
"Token for delivering a callback. Set only for type=callback; null until the callback URL is materialized."
|
|
858
|
+
),
|
|
859
|
+
payload_schema: zod.z.unknown().optional().describe("JSON Schema describing the expected callback payload"),
|
|
860
|
+
payload: zod.z.unknown().optional().describe("Payload delivered to a callback operation, when received"),
|
|
861
|
+
expires_at: zod.z.string().nullable().optional().describe("When a callback or wait operation expires (ISO-8601)"),
|
|
862
|
+
timeout_seconds: zod.z.number().nullable().optional().describe(
|
|
863
|
+
"Requested callback timeout in seconds, used to set `expires_at`. Absent or null for non-callback operations and callbacks without a timeout."
|
|
864
|
+
),
|
|
865
|
+
completed_at: zod.z.string().nullable().optional().describe("When the operation reached a terminal state (ISO-8601)"),
|
|
866
|
+
created_at: zod.z.string().describe("When the operation was created (ISO-8601)")
|
|
867
|
+
});
|
|
868
|
+
var ExecutionStatusSchema = kitcore.openEnum(
|
|
869
|
+
["running", "waiting", "completed", "failed"],
|
|
870
|
+
"Execution lifecycle status. `waiting` means blocked on a wait or callback operation."
|
|
871
|
+
);
|
|
872
|
+
var ExecutionSummarySchema = zod.z.object({
|
|
873
|
+
id: zod.z.string().describe("Execution ID (UUID)"),
|
|
874
|
+
name: zod.z.string().describe("Durable function name"),
|
|
875
|
+
status: ExecutionStatusSchema,
|
|
876
|
+
input: zod.z.unknown().describe("Input passed when the execution was created"),
|
|
877
|
+
output: zod.z.unknown().optional().describe("Return value when status is `completed`"),
|
|
878
|
+
error: zod.z.unknown().optional().describe("Error details when status is `failed`"),
|
|
879
|
+
metadata: zod.z.record(zod.z.string(), zod.z.unknown()).optional().describe(
|
|
880
|
+
"Caller-supplied tags (Zap ID, Step ID, Agent ID, etc.) carried alongside the execution"
|
|
881
|
+
),
|
|
882
|
+
created_at: zod.z.string().describe("When the execution was created (ISO-8601)"),
|
|
883
|
+
summary: zod.z.object({
|
|
884
|
+
total_attempts: zod.z.number().describe(
|
|
885
|
+
"Total ticks attempted against this execution across all retries"
|
|
886
|
+
),
|
|
887
|
+
last_error: zod.z.object({
|
|
888
|
+
code: zod.z.string().describe("Machine-readable error category"),
|
|
889
|
+
title: zod.z.string().describe("Short error label"),
|
|
890
|
+
detail: zod.z.string().nullable().optional().describe("Longer-form error detail, when provided")
|
|
891
|
+
}).passthrough().nullable().optional().describe(
|
|
892
|
+
"The most recent error; null when the execution has not errored."
|
|
893
|
+
)
|
|
894
|
+
}).passthrough().nullable().optional().describe(
|
|
895
|
+
"Aggregate health summary. Null when no attempts have been recorded yet."
|
|
896
|
+
),
|
|
897
|
+
operations: zod.z.array(OperationSchema).optional().describe(
|
|
898
|
+
"Operations journal \u2014 append-only record of every step/wait/callback the execution made"
|
|
899
|
+
)
|
|
900
|
+
});
|
|
901
|
+
var GetDurableRunOptionsSchema = zod.z.object({
|
|
902
|
+
run: zod.z.string().uuid().describe("Durable run ID")
|
|
903
|
+
}).describe(
|
|
904
|
+
"Get the full state of a run-once durable run, including its operations journal"
|
|
905
|
+
);
|
|
906
|
+
var GetDurableRunResponseSchema = zod.z.object({
|
|
907
|
+
id: zod.z.string().describe("Run ID (UUID)"),
|
|
908
|
+
status: RunStatusSchema,
|
|
909
|
+
input: zod.z.unknown().describe("Input data passed to the run"),
|
|
910
|
+
output: zod.z.unknown().nullable().describe("Return value, present when status is `finished`"),
|
|
911
|
+
error: RunErrorSchema.nullable().describe(
|
|
912
|
+
"Structured error details when the run failed (null otherwise)"
|
|
913
|
+
),
|
|
914
|
+
execution: ExecutionSummarySchema.nullable().describe(
|
|
915
|
+
"Linked execution, including the operations journal. Null while the run is still in `initialized` state."
|
|
916
|
+
),
|
|
917
|
+
is_private: zod.z.boolean().describe(
|
|
918
|
+
"When true, the run is visible only to the creating user; otherwise visible across the account."
|
|
919
|
+
),
|
|
920
|
+
created_at: zod.z.string().describe("When the run was created (ISO-8601)"),
|
|
921
|
+
updated_at: zod.z.string().describe("When the run was last updated (ISO-8601)")
|
|
922
|
+
});
|
|
923
|
+
|
|
924
|
+
// src/plugins/codeSubstrate/getDurableRun/index.ts
|
|
925
|
+
var getDurableRunPlugin = kitcore.defineMethod({
|
|
926
|
+
...codeSubstrateDefaults,
|
|
927
|
+
name: "getDurableRun",
|
|
928
|
+
imports: [chunkTJXDMXEE_cjs.apiPluginRef],
|
|
929
|
+
itemType: "DurableRun",
|
|
930
|
+
inputSchema: GetDurableRunOptionsSchema,
|
|
931
|
+
outputSchema: GetDurableRunResponseSchema,
|
|
932
|
+
skipOutputValidation: true,
|
|
933
|
+
output: "item",
|
|
934
|
+
resolvers: { run: chunkTJXDMXEE_cjs.durableRunIdResolver },
|
|
935
|
+
run: async ({ imports, input }) => {
|
|
936
|
+
const api = imports.api;
|
|
937
|
+
const raw = await api.get(
|
|
938
|
+
`${CODE_SUBSTRATE_RUNNER_API}/runs/${encodeURIComponent(input.run)}`,
|
|
939
|
+
{
|
|
940
|
+
authRequired: true,
|
|
941
|
+
resource: { type: "run", id: input.run }
|
|
942
|
+
}
|
|
943
|
+
);
|
|
944
|
+
return { data: GetDurableRunResponseSchema.parse(raw) };
|
|
945
|
+
}
|
|
946
|
+
});
|
|
947
|
+
var RunNotificationEventSchema = zod.z.enum(["started", "progress", "completed", "error", "cancelled"]).describe("Run lifecycle event this notification subscribes to");
|
|
948
|
+
var RunNotificationSchema = zod.z.object({
|
|
949
|
+
type: zod.z.literal("webhook").optional().describe("Notification transport. Webhook is the only supported type."),
|
|
950
|
+
url: zod.z.string().url().describe(
|
|
951
|
+
"URL to POST event notifications to. Payload is `{run_id, event}`."
|
|
952
|
+
),
|
|
953
|
+
max_retries: zod.z.number().int().min(0).max(10).optional().describe(
|
|
954
|
+
"Max delivery attempts with exponential backoff. Defaults to 3 server-side."
|
|
955
|
+
),
|
|
956
|
+
events: zod.z.array(RunNotificationEventSchema).min(1).describe("One or more lifecycle events to subscribe this URL to.")
|
|
957
|
+
}).describe(
|
|
958
|
+
"Webhook subscriber for run lifecycle events. Server POSTs `{run_id, event}` on each subscribed transition."
|
|
959
|
+
);
|
|
960
|
+
var RunDurableBaseSchema = zod.z.object({
|
|
961
|
+
input: JsonPayloadSchema.optional().describe(
|
|
962
|
+
"Input data passed to the run. Accepts any JSON value, or its JSON-string encoding."
|
|
963
|
+
),
|
|
964
|
+
dependencies: zod.z.record(zod.z.string(), zod.z.string()).optional().describe(
|
|
965
|
+
'Optional npm package dependencies. A version of "latest" is resolved by the server for @zapier/zapier-durable and @zapier/zapier-sdk only; every other value, including a "latest" on any other package, is passed to the install as written.'
|
|
966
|
+
),
|
|
967
|
+
zapierDurableVersion: zod.z.string().optional().describe(
|
|
968
|
+
`Exact semver of @zapier/zapier-durable to use (e.g. "1.2.3"), or "latest". Defaults to the server-configured version if omitted. "latest" is resolved by the server to the newest release old enough to clear the sandbox install age gate (24h) -- this is not npm's "latest" tag, which can point at a release too new to install. Ranges (^1.2.3, ~1.2) are rejected.`
|
|
969
|
+
),
|
|
970
|
+
/** @deprecated Use `zapierDurableVersion` instead. */
|
|
971
|
+
zapier_durable_version: zod.z.string().optional().meta({ deprecated: true }),
|
|
972
|
+
connections: zod.z.record(zod.z.string(), ConnectionBindingSchema).optional().describe(
|
|
973
|
+
'Named connection aliases. Maps each alias to an object holding its Zapier connection ID, e.g. `{ "slack": { "connectionId": "123" } }`.'
|
|
974
|
+
),
|
|
975
|
+
appVersions: zod.z.record(zod.z.string(), AppVersionBindingSchema).optional().describe(
|
|
976
|
+
"Pinned app versions. Maps app keys (slugs) to implementation names and versions."
|
|
977
|
+
),
|
|
978
|
+
/** @deprecated Use `appVersions` instead. */
|
|
979
|
+
app_versions: zod.z.record(zod.z.string(), AppVersionBindingSchema).optional().meta({ deprecated: true }),
|
|
980
|
+
private: zod.z.boolean().optional().describe("Only the creating user can see the run (default false)"),
|
|
981
|
+
notifications: zod.z.array(RunNotificationSchema).optional().describe(
|
|
982
|
+
"Webhook subscribers for run lifecycle events. Each entry specifies a URL and the events it subscribes to."
|
|
983
|
+
)
|
|
984
|
+
});
|
|
985
|
+
var RunDurableDescription = "Run a workflow's complete source-files map as a run-once durable run on code-substrate-runner (no deployed workflow required). Send every file the workflow needs, not only its entry point. Returns the run ID immediately; poll via getDurableRun for terminal status.";
|
|
986
|
+
var RunDurableSchema = zod.z.object({ sourceFiles: SourceFilesSchema }).merge(RunDurableBaseSchema).describe(RunDurableDescription).meta({
|
|
987
|
+
aliases: {
|
|
988
|
+
source_files: "sourceFiles",
|
|
989
|
+
zapier_durable_version: "zapierDurableVersion",
|
|
990
|
+
app_versions: "appVersions"
|
|
991
|
+
}
|
|
992
|
+
});
|
|
993
|
+
var RunDurableSchemaDeprecated = zod.z.object({ source_files: SourceFilesSchema }).merge(RunDurableBaseSchema);
|
|
994
|
+
var RunDurableOptionsSchema = zod.z.union([RunDurableSchema, RunDurableSchemaDeprecated]).describe(RunDurableDescription);
|
|
995
|
+
var RunDurableResponseSchema = zod.z.object({
|
|
996
|
+
id: zod.z.string().describe("Run ID (UUID) \u2014 server-generated, time-sortable"),
|
|
997
|
+
status: zod.z.literal("initialized").describe(
|
|
998
|
+
"Always `initialized` on creation. Poll via getDurableRun to observe the run advancing to `started` / `finished` / `failed` / `cancelled`."
|
|
999
|
+
),
|
|
1000
|
+
is_private: zod.z.boolean().describe(
|
|
1001
|
+
"When true, the run is visible only to the creating user; otherwise visible across the account."
|
|
1002
|
+
),
|
|
1003
|
+
created_at: zod.z.string().describe("When the run was created (ISO-8601)")
|
|
1004
|
+
});
|
|
1005
|
+
var sourceFilesResolver = kitcore.defineResolver({
|
|
1006
|
+
type: "object",
|
|
1007
|
+
additionalKeys: {
|
|
1008
|
+
minEntries: 1,
|
|
1009
|
+
keys: kitcore.defineResolver({
|
|
1010
|
+
type: "static",
|
|
1011
|
+
inputType: "text",
|
|
1012
|
+
placeholder: "filename (e.g. index.ts)"
|
|
1013
|
+
}),
|
|
1014
|
+
values: kitcore.defineResolver({
|
|
1015
|
+
type: "static",
|
|
1016
|
+
inputType: "text",
|
|
1017
|
+
placeholder: "file contents"
|
|
1018
|
+
}),
|
|
1019
|
+
keyValueType: "string",
|
|
1020
|
+
valueValueType: "string"
|
|
1021
|
+
}
|
|
1022
|
+
});
|
|
1023
|
+
|
|
1024
|
+
// src/plugins/codeSubstrate/runDurable/index.ts
|
|
1025
|
+
var runDurablePlugin = kitcore.defineMethod({
|
|
1026
|
+
...codeSubstrateDefaults,
|
|
1027
|
+
name: "runDurable",
|
|
1028
|
+
imports: [chunkTJXDMXEE_cjs.apiPluginRef],
|
|
1029
|
+
type: "create",
|
|
1030
|
+
itemType: "DurableRun",
|
|
1031
|
+
inputSchema: RunDurableOptionsSchema,
|
|
1032
|
+
outputSchema: RunDurableResponseSchema,
|
|
1033
|
+
skipOutputValidation: true,
|
|
1034
|
+
output: "item",
|
|
1035
|
+
resolvers: { sourceFiles: sourceFilesResolver },
|
|
1036
|
+
run: async ({ imports, input }) => {
|
|
1037
|
+
const api = imports.api;
|
|
1038
|
+
const sourceFiles = "sourceFiles" in input ? input.sourceFiles : input.source_files;
|
|
1039
|
+
const zapierDurableVersion = input.zapierDurableVersion ?? input.zapier_durable_version;
|
|
1040
|
+
const appVersions = input.appVersions ?? input.app_versions;
|
|
1041
|
+
const body = { source_files: sourceFiles };
|
|
1042
|
+
if (input.input !== void 0) {
|
|
1043
|
+
body.input = input.input;
|
|
1044
|
+
}
|
|
1045
|
+
if (input.dependencies !== void 0) {
|
|
1046
|
+
body.dependencies = input.dependencies;
|
|
1047
|
+
}
|
|
1048
|
+
if (zapierDurableVersion !== void 0) {
|
|
1049
|
+
body.zapier_durable_version = zapierDurableVersion;
|
|
1050
|
+
}
|
|
1051
|
+
if (input.connections !== void 0) {
|
|
1052
|
+
body.connections = toWireConnections(input.connections);
|
|
1053
|
+
}
|
|
1054
|
+
if (appVersions !== void 0) {
|
|
1055
|
+
body.app_versions = toWireAppVersions(appVersions);
|
|
1056
|
+
}
|
|
1057
|
+
if (input.private !== void 0) {
|
|
1058
|
+
body.is_private = input.private;
|
|
1059
|
+
}
|
|
1060
|
+
if (input.notifications !== void 0) {
|
|
1061
|
+
body.notifications = input.notifications;
|
|
1062
|
+
}
|
|
1063
|
+
const raw = await api.post(`${CODE_SUBSTRATE_RUNNER_API}/runs`, body, {
|
|
1064
|
+
authRequired: true
|
|
1065
|
+
});
|
|
1066
|
+
return { data: RunDurableResponseSchema.parse(raw) };
|
|
1067
|
+
}
|
|
1068
|
+
});
|
|
1069
|
+
var CancelDurableRunOptionsSchema = zod.z.object({
|
|
1070
|
+
run: zod.z.string().uuid().describe("Durable run ID")
|
|
1071
|
+
}).describe(
|
|
1072
|
+
"Cancel a run-once durable run in initialized or started status. Returns 409 if the run is already terminal."
|
|
1073
|
+
);
|
|
1074
|
+
var CancelDurableRunResponseSchema = zod.z.object({
|
|
1075
|
+
id: zod.z.string().describe("Run ID that was targeted"),
|
|
1076
|
+
status: zod.z.literal("cancelled").describe(
|
|
1077
|
+
"Always `cancelled` on a successful call. Synthesized client-side \u2014 the backend returns 204; callers needing the run's full state should follow up with getDurableRun."
|
|
1078
|
+
)
|
|
1079
|
+
});
|
|
1080
|
+
|
|
1081
|
+
// src/plugins/codeSubstrate/cancelDurableRun/index.ts
|
|
1082
|
+
var cancelDurableRunPlugin = kitcore.defineMethod({
|
|
1083
|
+
...codeSubstrateDefaults,
|
|
1084
|
+
name: "cancelDurableRun",
|
|
1085
|
+
imports: [chunkTJXDMXEE_cjs.apiPluginRef],
|
|
1086
|
+
type: "update",
|
|
1087
|
+
itemType: "DurableRun",
|
|
1088
|
+
inputSchema: CancelDurableRunOptionsSchema,
|
|
1089
|
+
outputSchema: CancelDurableRunResponseSchema,
|
|
1090
|
+
skipOutputValidation: true,
|
|
1091
|
+
output: "item",
|
|
1092
|
+
resolvers: { run: chunkTJXDMXEE_cjs.durableRunIdResolver },
|
|
1093
|
+
run: async ({ imports, input }) => {
|
|
1094
|
+
const api = imports.api;
|
|
1095
|
+
await api.post(
|
|
1096
|
+
`${CODE_SUBSTRATE_RUNNER_API}/runs/${encodeURIComponent(input.run)}/cancel`,
|
|
1097
|
+
void 0,
|
|
1098
|
+
{
|
|
1099
|
+
authRequired: true,
|
|
1100
|
+
resource: { type: "run", id: input.run }
|
|
1101
|
+
}
|
|
1102
|
+
);
|
|
1103
|
+
return { data: { id: input.run, status: "cancelled" } };
|
|
1104
|
+
}
|
|
1105
|
+
});
|
|
1106
|
+
var PublishWorkflowVersionDescription = "Publish a new version of a durable workflow. Enables the workflow by default.";
|
|
1107
|
+
var PublishWorkflowVersionBaseSchema = zod.z.object({
|
|
1108
|
+
dependencies: zod.z.record(zod.z.string(), zod.z.string()).optional().describe(
|
|
1109
|
+
'Optional npm package dependencies. A version of "latest" is resolved by the server for @zapier/zapier-durable and @zapier/zapier-sdk only; every other value, including a "latest" on any other package, is passed to the install as written.'
|
|
1110
|
+
),
|
|
1111
|
+
zapierDurableVersion: zod.z.string().optional().describe(
|
|
1112
|
+
`Exact semver of @zapier/zapier-durable to use (e.g. "1.2.3"), or "latest". Defaults to the server-configured version if omitted. "latest" is resolved by the server to the newest release old enough to clear the sandbox install age gate (24h) -- this is not npm's "latest" tag, which can point at a release too new to install. Ranges (^1.2.3, ~1.2) are rejected.`
|
|
1113
|
+
),
|
|
1114
|
+
/** @deprecated Use `zapierDurableVersion` instead. */
|
|
1115
|
+
zapier_durable_version: zod.z.string().optional().meta({ deprecated: true }),
|
|
1116
|
+
enabled: zod.z.boolean().optional().describe(
|
|
1117
|
+
"Enable the workflow after publishing. Defaults to true if omitted; pass false to publish without enabling."
|
|
1118
|
+
).meta({ negatable: "disabled" }),
|
|
1119
|
+
ignoreOpenDrafts: zod.z.boolean().optional().describe(
|
|
1120
|
+
"Publish even though the workflow has open draft(s). Without this, the API rejects a direct publish with a 409 while any draft is open, since publishing the draft later would ship its stale content over this version."
|
|
1121
|
+
),
|
|
1122
|
+
connections: zod.z.record(zod.z.string(), ConnectionBindingSchema).nullish().describe(
|
|
1123
|
+
"Map of connection aliases to Zapier connections used by the workflow. Pass `null` to clear an existing binding."
|
|
1124
|
+
),
|
|
1125
|
+
appVersions: zod.z.record(zod.z.string(), AppVersionBindingSchema).nullish().describe(
|
|
1126
|
+
"Map of app keys to pinned app implementation/version used by the workflow. Pass `null` to clear an existing binding."
|
|
1127
|
+
),
|
|
1128
|
+
/** @deprecated Use `appVersions` instead. */
|
|
1129
|
+
app_versions: zod.z.record(zod.z.string(), AppVersionBindingSchema).nullish().meta({ deprecated: true }),
|
|
1130
|
+
trigger: TriggerConfigSchema.optional().describe(
|
|
1131
|
+
"Trigger configuration. When provided, the workflow subscribes to a Zapier trigger; for an on-demand, triggerless workflow, omit this and pass `manual: true` instead."
|
|
1132
|
+
),
|
|
1133
|
+
manual: zod.z.boolean().optional().describe(
|
|
1134
|
+
"Declare this an on-demand, triggerless workflow version. Pass `manual: true` only when omitting `trigger`; passing both is a contradiction the API rejects with a 400."
|
|
1135
|
+
)
|
|
1136
|
+
});
|
|
1137
|
+
var WorkflowPropertySchema = zod.z.string().uuid().describe("Durable workflow ID");
|
|
1138
|
+
function hasNoTriggerManualConflict(data) {
|
|
1139
|
+
return !(data.trigger !== void 0 && data.manual === true);
|
|
1140
|
+
}
|
|
1141
|
+
var TRIGGER_MANUAL_CONFLICT_MESSAGE = "Provide `trigger` or `manual: true`, not both \u2014 a trigger together with manual: true is a contradiction.";
|
|
1142
|
+
var PublishWorkflowVersionSchema = zod.z.object({
|
|
1143
|
+
workflow: WorkflowPropertySchema,
|
|
1144
|
+
sourceFiles: SourceFilesSchema
|
|
1145
|
+
}).merge(PublishWorkflowVersionBaseSchema).refine(hasNoTriggerManualConflict, {
|
|
1146
|
+
message: TRIGGER_MANUAL_CONFLICT_MESSAGE
|
|
1147
|
+
}).describe(PublishWorkflowVersionDescription).meta({
|
|
1148
|
+
aliases: {
|
|
1149
|
+
source_files: "sourceFiles",
|
|
1150
|
+
zapier_durable_version: "zapierDurableVersion",
|
|
1151
|
+
app_versions: "appVersions"
|
|
1152
|
+
}
|
|
1153
|
+
});
|
|
1154
|
+
var PublishWorkflowVersionSchemaDeprecated = zod.z.object({
|
|
1155
|
+
workflow: WorkflowPropertySchema,
|
|
1156
|
+
source_files: SourceFilesSchema
|
|
1157
|
+
}).merge(PublishWorkflowVersionBaseSchema).refine(hasNoTriggerManualConflict, {
|
|
1158
|
+
message: TRIGGER_MANUAL_CONFLICT_MESSAGE
|
|
1159
|
+
});
|
|
1160
|
+
var PublishWorkflowVersionOptionsSchema = zod.z.union([PublishWorkflowVersionSchema, PublishWorkflowVersionSchemaDeprecated]).describe(PublishWorkflowVersionDescription);
|
|
1161
|
+
var PublishWorkflowVersionResponseSchema = WorkflowVersionSchema;
|
|
1162
|
+
|
|
1163
|
+
// src/plugins/codeSubstrate/publishWorkflowVersion/index.ts
|
|
1164
|
+
function toOpenDraftRef(draft) {
|
|
1165
|
+
if (typeof draft !== "object" || draft === null) return void 0;
|
|
1166
|
+
const record = draft;
|
|
1167
|
+
if (typeof record.id !== "string") return void 0;
|
|
1168
|
+
const ref = { id: record.id };
|
|
1169
|
+
if (typeof record.slug === "string") ref.slug = record.slug;
|
|
1170
|
+
const lastEditedAt = record.last_edited_at;
|
|
1171
|
+
if (typeof lastEditedAt === "string" || lastEditedAt === null) {
|
|
1172
|
+
ref.last_edited_at = lastEditedAt;
|
|
1173
|
+
}
|
|
1174
|
+
const lastEditedByUserId = record.last_edited_by_user_id;
|
|
1175
|
+
if (typeof lastEditedByUserId === "string" || lastEditedByUserId === null) {
|
|
1176
|
+
ref.last_edited_by_user_id = lastEditedByUserId;
|
|
1177
|
+
}
|
|
1178
|
+
return ref;
|
|
1179
|
+
}
|
|
1180
|
+
function extractOpenDraftConflict(data) {
|
|
1181
|
+
if (typeof data !== "object" || data === null) return void 0;
|
|
1182
|
+
const errors = data.errors;
|
|
1183
|
+
if (!Array.isArray(errors)) return void 0;
|
|
1184
|
+
for (const entry of errors) {
|
|
1185
|
+
if (typeof entry !== "object" || entry === null) continue;
|
|
1186
|
+
const meta = entry.meta;
|
|
1187
|
+
if (typeof meta !== "object" || meta === null) continue;
|
|
1188
|
+
const drafts = meta.open_drafts;
|
|
1189
|
+
if (!Array.isArray(drafts)) continue;
|
|
1190
|
+
const refs = drafts.map(toOpenDraftRef).filter((ref) => ref !== void 0);
|
|
1191
|
+
if (refs.length === 0) continue;
|
|
1192
|
+
const detail = entry.detail;
|
|
1193
|
+
return {
|
|
1194
|
+
openDrafts: refs,
|
|
1195
|
+
detail: typeof detail === "string" ? detail : void 0
|
|
1196
|
+
};
|
|
1197
|
+
}
|
|
1198
|
+
return void 0;
|
|
1199
|
+
}
|
|
1200
|
+
function describeOpenDraft(draft) {
|
|
1201
|
+
const label = draft.slug ? `${draft.slug} (id: ${draft.id})` : draft.id;
|
|
1202
|
+
return draft.last_edited_at ? ` \u2022 ${label}, last edited ${draft.last_edited_at}` : ` \u2022 ${label}`;
|
|
1203
|
+
}
|
|
1204
|
+
var publishWorkflowVersionPlugin = kitcore.defineMethod({
|
|
1205
|
+
...codeSubstrateDefaults,
|
|
1206
|
+
name: "publishWorkflowVersion",
|
|
1207
|
+
imports: [chunkTJXDMXEE_cjs.apiPluginRef],
|
|
1208
|
+
type: "create",
|
|
1209
|
+
itemType: "WorkflowVersion",
|
|
1210
|
+
inputSchema: PublishWorkflowVersionOptionsSchema,
|
|
1211
|
+
outputSchema: PublishWorkflowVersionResponseSchema,
|
|
1212
|
+
skipOutputValidation: true,
|
|
1213
|
+
output: "item",
|
|
1214
|
+
resolvers: { workflow: chunkTJXDMXEE_cjs.workflowIdResolver, sourceFiles: sourceFilesResolver },
|
|
1215
|
+
run: async ({ imports, input }) => {
|
|
1216
|
+
const api = imports.api;
|
|
1217
|
+
const sourceFiles = "sourceFiles" in input ? input.sourceFiles : input.source_files;
|
|
1218
|
+
const zapierDurableVersion = input.zapierDurableVersion ?? input.zapier_durable_version;
|
|
1219
|
+
const appVersions = "appVersions" in input ? input.appVersions : input.app_versions;
|
|
1220
|
+
const body = { source_files: sourceFiles };
|
|
1221
|
+
if (input.dependencies !== void 0) {
|
|
1222
|
+
body.dependencies = input.dependencies;
|
|
1223
|
+
}
|
|
1224
|
+
if (zapierDurableVersion !== void 0) {
|
|
1225
|
+
body.zapier_durable_version = zapierDurableVersion;
|
|
1226
|
+
}
|
|
1227
|
+
if (input.enabled !== void 0) {
|
|
1228
|
+
body.enabled = input.enabled;
|
|
1229
|
+
}
|
|
1230
|
+
if (input.ignoreOpenDrafts !== void 0) {
|
|
1231
|
+
body.ignore_open_drafts = input.ignoreOpenDrafts;
|
|
1232
|
+
}
|
|
1233
|
+
if (input.connections === null) {
|
|
1234
|
+
body.connections = null;
|
|
1235
|
+
} else if (input.connections !== void 0) {
|
|
1236
|
+
body.connections = toWireConnections(input.connections);
|
|
1237
|
+
}
|
|
1238
|
+
if (appVersions === null) {
|
|
1239
|
+
body.app_versions = null;
|
|
1240
|
+
} else if (appVersions !== void 0) {
|
|
1241
|
+
body.app_versions = toWireAppVersions(appVersions);
|
|
1242
|
+
}
|
|
1243
|
+
if (input.trigger !== void 0) {
|
|
1244
|
+
body.trigger = toWireTrigger(input.trigger);
|
|
1245
|
+
}
|
|
1246
|
+
if (input.manual !== void 0) {
|
|
1247
|
+
body.manual = input.manual;
|
|
1248
|
+
}
|
|
1249
|
+
const raw = await api.post(
|
|
1250
|
+
`${CODE_SUBSTRATE_WORKFLOWS_API}/workflows/${encodeURIComponent(input.workflow)}/versions`,
|
|
1251
|
+
body,
|
|
1252
|
+
{
|
|
1253
|
+
authRequired: true,
|
|
1254
|
+
resource: { type: "workflow", id: input.workflow },
|
|
1255
|
+
// Every 409 from this endpoint is a conflict, so every 409 maps to
|
|
1256
|
+
// ZapierConflictError — mirroring publishWorkflowDraft, and keeping
|
|
1257
|
+
// isZapierConflictError(error) reliable across both publish paths.
|
|
1258
|
+
// The open-draft publish guard's 409 additionally carries
|
|
1259
|
+
// `meta.open_drafts`; surface that list and the remediations instead
|
|
1260
|
+
// of flattening to a generic message — otherwise the caller has to
|
|
1261
|
+
// pick between force-publishing and draft-publishing without seeing
|
|
1262
|
+
// what they'd be forcing over. The structured list rides on the
|
|
1263
|
+
// error's `meta` for programmatic use (CLI --json).
|
|
1264
|
+
customErrorHandler: ({ status, data }) => {
|
|
1265
|
+
if (status !== 409) return void 0;
|
|
1266
|
+
const conflict = extractOpenDraftConflict(data);
|
|
1267
|
+
if (!conflict) {
|
|
1268
|
+
return new chunkTJXDMXEE_cjs.ZapierConflictError(
|
|
1269
|
+
chunkTJXDMXEE_cjs.extractErrorDetail(data) ?? "Workflow version publish conflict.",
|
|
1270
|
+
{ statusCode: status, resourceType: "workflow" }
|
|
1271
|
+
);
|
|
1272
|
+
}
|
|
1273
|
+
const detail = conflict.detail ?? "Cannot publish over open draft(s).";
|
|
1274
|
+
return new chunkTJXDMXEE_cjs.ZapierConflictError(
|
|
1275
|
+
[
|
|
1276
|
+
`${detail} Blocking draft(s):`,
|
|
1277
|
+
...conflict.openDrafts.map(describeOpenDraft),
|
|
1278
|
+
"To keep a draft's changes, publish it with publishWorkflowDraft (CLI: publish-workflow-draft); to abandon them, discard it with discardWorkflowDraft (CLI: discard-workflow-draft); or force-publish over it by retrying with ignoreOpenDrafts: true (CLI: --ignore-open-drafts)."
|
|
1279
|
+
].join("\n"),
|
|
1280
|
+
{
|
|
1281
|
+
statusCode: status,
|
|
1282
|
+
resourceType: "workflow",
|
|
1283
|
+
meta: { open_drafts: conflict.openDrafts }
|
|
1284
|
+
}
|
|
1285
|
+
);
|
|
1286
|
+
}
|
|
1287
|
+
}
|
|
1288
|
+
);
|
|
1289
|
+
return { data: PublishWorkflowVersionResponseSchema.parse(raw) };
|
|
1290
|
+
}
|
|
1291
|
+
});
|
|
1292
|
+
var WorkflowVersionListItemSchema = zod.z.object({
|
|
1293
|
+
id: zod.z.string().describe("Workflow version ID (UUID)"),
|
|
1294
|
+
workflow_id: zod.z.string().describe("Parent workflow ID (UUID)"),
|
|
1295
|
+
zapier_durable_version: zod.z.string().describe(
|
|
1296
|
+
"Pinned semver of @zapier/zapier-durable used by this version's runs"
|
|
1297
|
+
),
|
|
1298
|
+
dependencies: zod.z.record(zod.z.string(), zod.z.string()).nullable().describe("Additional npm dependencies pinned for this version (or null)"),
|
|
1299
|
+
created_by_user_id: zod.z.string().describe("ID of the user who published this version"),
|
|
1300
|
+
created_at: zod.z.string().describe("When the version was published (ISO-8601)"),
|
|
1301
|
+
trigger: WorkflowVersionTriggerConfigSchema.nullable().describe(
|
|
1302
|
+
"Trigger configuration persisted on this version, or null for webhook-only workflows."
|
|
1303
|
+
),
|
|
1304
|
+
connections: zod.z.record(zod.z.string(), ConnectionBindingSchema2).nullable().describe("Connection aliases bound on this version (or null)."),
|
|
1305
|
+
app_versions: zod.z.record(zod.z.string(), AppVersionBindingSchema2).nullable().describe("App-version pins bound on this version (or null)."),
|
|
1306
|
+
creation_client: WorkflowClientAttributionFieldSchema
|
|
1307
|
+
});
|
|
1308
|
+
var ListWorkflowVersionsOptionsSchema = zod.z.object({
|
|
1309
|
+
workflow: zod.z.string().uuid().describe("Durable workflow ID"),
|
|
1310
|
+
pageSize: zod.z.number().int().min(1).max(100).optional().describe("Number of versions per page (max 100)"),
|
|
1311
|
+
cursor: zod.z.string().optional().describe("Pagination cursor"),
|
|
1312
|
+
maxItems: zod.z.number().int().min(1).optional().describe("Maximum total versions to return across all pages")
|
|
1313
|
+
}).describe("List published versions for a workflow, newest first");
|
|
1314
|
+
var ListWorkflowVersionsApiResponseSchema = zod.z.object({
|
|
1315
|
+
results: zod.z.array(WorkflowVersionListItemSchema),
|
|
1316
|
+
meta: zod.z.object({
|
|
1317
|
+
limit: zod.z.number(),
|
|
1318
|
+
cursor: zod.z.string().nullable().optional(),
|
|
1319
|
+
next_cursor: zod.z.string().nullable().optional()
|
|
1320
|
+
}),
|
|
1321
|
+
links: zod.z.object({
|
|
1322
|
+
next: zod.z.string().nullable().optional()
|
|
1323
|
+
}).optional()
|
|
1324
|
+
});
|
|
1325
|
+
|
|
1326
|
+
// src/plugins/codeSubstrate/listWorkflowVersions/index.ts
|
|
1327
|
+
var listWorkflowVersionsPlugin = kitcore.defineMethod({
|
|
1328
|
+
...codeSubstrateDefaults,
|
|
1329
|
+
name: "listWorkflowVersions",
|
|
1330
|
+
imports: [chunkTJXDMXEE_cjs.apiPluginRef],
|
|
1331
|
+
type: "list",
|
|
1332
|
+
itemType: "WorkflowVersion",
|
|
1333
|
+
inputSchema: ListWorkflowVersionsOptionsSchema,
|
|
1334
|
+
outputSchema: WorkflowVersionListItemSchema,
|
|
1335
|
+
skipOutputValidation: true,
|
|
1336
|
+
// The handler already returns a clean `{ data, nextCursor }` page, so the
|
|
1337
|
+
// standard list output (no `adaptPage`) applies.
|
|
1338
|
+
output: { type: "list", defaultPageSize: chunkTJXDMXEE_cjs.DEFAULT_PAGE_SIZE },
|
|
1339
|
+
resolvers: { workflow: chunkTJXDMXEE_cjs.workflowIdResolver },
|
|
1340
|
+
run: async ({ imports, input }) => {
|
|
1341
|
+
const api = imports.api;
|
|
1342
|
+
const searchParams = {};
|
|
1343
|
+
if (input.pageSize !== void 0) {
|
|
1344
|
+
searchParams.limit = input.pageSize.toString();
|
|
1345
|
+
}
|
|
1346
|
+
if (input.cursor) {
|
|
1347
|
+
searchParams.cursor = input.cursor;
|
|
1348
|
+
}
|
|
1349
|
+
const raw = await api.get(
|
|
1350
|
+
`${CODE_SUBSTRATE_WORKFLOWS_API}/workflows/${encodeURIComponent(input.workflow)}/versions`,
|
|
1351
|
+
{
|
|
1352
|
+
searchParams,
|
|
1353
|
+
authRequired: true,
|
|
1354
|
+
resource: { type: "workflow", id: input.workflow }
|
|
1355
|
+
}
|
|
1356
|
+
);
|
|
1357
|
+
const response = ListWorkflowVersionsApiResponseSchema.parse(raw);
|
|
1358
|
+
return {
|
|
1359
|
+
data: response.results,
|
|
1360
|
+
nextCursor: response.meta.next_cursor ?? void 0
|
|
1361
|
+
};
|
|
1362
|
+
}
|
|
1363
|
+
});
|
|
1364
|
+
var GetWorkflowVersionOptionsSchema = zod.z.object({
|
|
1365
|
+
workflow: zod.z.string().uuid().describe("Durable workflow ID"),
|
|
1366
|
+
version: zod.z.string().uuid().describe("Workflow version ID")
|
|
1367
|
+
}).describe("Get full details of a workflow version including source files");
|
|
1368
|
+
var GetWorkflowVersionResponseSchema = WorkflowVersionSchema;
|
|
1369
|
+
|
|
1370
|
+
// src/plugins/codeSubstrate/getWorkflowVersion/index.ts
|
|
1371
|
+
var getWorkflowVersionPlugin = kitcore.defineMethod({
|
|
1372
|
+
...codeSubstrateDefaults,
|
|
1373
|
+
name: "getWorkflowVersion",
|
|
1374
|
+
imports: [chunkTJXDMXEE_cjs.apiPluginRef],
|
|
1375
|
+
itemType: "WorkflowVersion",
|
|
1376
|
+
inputSchema: GetWorkflowVersionOptionsSchema,
|
|
1377
|
+
outputSchema: GetWorkflowVersionResponseSchema,
|
|
1378
|
+
skipOutputValidation: true,
|
|
1379
|
+
output: "item",
|
|
1380
|
+
resolvers: {
|
|
1381
|
+
workflow: chunkTJXDMXEE_cjs.workflowIdResolver,
|
|
1382
|
+
version: chunkTJXDMXEE_cjs.workflowVersionIdResolver
|
|
1383
|
+
},
|
|
1384
|
+
run: async ({ imports, input }) => {
|
|
1385
|
+
const api = imports.api;
|
|
1386
|
+
const raw = await api.get(
|
|
1387
|
+
`${CODE_SUBSTRATE_WORKFLOWS_API}/workflows/${encodeURIComponent(input.workflow)}/versions/${encodeURIComponent(input.version)}`,
|
|
1388
|
+
{
|
|
1389
|
+
authRequired: true,
|
|
1390
|
+
resource: { type: "workflow-version", id: input.version }
|
|
1391
|
+
}
|
|
1392
|
+
);
|
|
1393
|
+
return { data: GetWorkflowVersionResponseSchema.parse(raw) };
|
|
1394
|
+
}
|
|
1395
|
+
});
|
|
1396
|
+
var WorkflowDraftSummarySchema = zod.z.object({
|
|
1397
|
+
id: zod.z.string().describe("Workflow draft ID (UUID)"),
|
|
1398
|
+
workflow_id: zod.z.string().describe("Parent workflow ID (UUID)"),
|
|
1399
|
+
slug: zod.z.string().describe(
|
|
1400
|
+
"Human-friendly display name, not an identifier: two open drafts of a workflow may share one"
|
|
1401
|
+
),
|
|
1402
|
+
base_version_id: zod.z.string().nullable().describe(
|
|
1403
|
+
"The version this draft was forked from (the live version at draft creation), or null when the workflow had no published version yet"
|
|
1404
|
+
),
|
|
1405
|
+
status: WorkflowDraftStatusSchema,
|
|
1406
|
+
last_edited_by_user_id: zod.z.string().nullable().describe("ID of the user who last saved this draft (or null)"),
|
|
1407
|
+
last_edited_at: zod.z.string().nullable().describe("When the draft was last edited (ISO-8601, or null)"),
|
|
1408
|
+
created_at: zod.z.string().describe("When the draft was created (ISO-8601)"),
|
|
1409
|
+
creation_client: WorkflowClientAttributionFieldSchema,
|
|
1410
|
+
last_edited_client: WorkflowClientAttributionFieldSchema
|
|
1411
|
+
});
|
|
1412
|
+
var ListWorkflowDraftsOptionsSchema = zod.z.object({
|
|
1413
|
+
workflow: zod.z.string().uuid().describe("Durable workflow ID"),
|
|
1414
|
+
status: WorkflowDraftStatusSchema.optional().describe(
|
|
1415
|
+
"Filter by draft status (server default: open)"
|
|
1416
|
+
),
|
|
1417
|
+
slug: zod.z.string().optional().describe(
|
|
1418
|
+
"Filter by exact slug match. Slugs are not unique, so this returns every draft with this slug matching the selected status, ordered by most recent activity and paginated"
|
|
1419
|
+
),
|
|
1420
|
+
pageSize: zod.z.number().int().min(1).max(100).optional().describe("Number of drafts per page (max 100)"),
|
|
1421
|
+
cursor: zod.z.string().optional().describe("Pagination cursor"),
|
|
1422
|
+
maxItems: zod.z.number().int().min(1).optional().describe("Maximum total drafts to return across all pages")
|
|
1423
|
+
}).describe(
|
|
1424
|
+
"List drafts for a workflow, most recently edited first (open drafts by default)"
|
|
1425
|
+
);
|
|
1426
|
+
var ListWorkflowDraftsApiResponseSchema = zod.z.object({
|
|
1427
|
+
results: zod.z.array(WorkflowDraftSummarySchema),
|
|
1428
|
+
meta: zod.z.object({
|
|
1429
|
+
limit: zod.z.number(),
|
|
1430
|
+
cursor: zod.z.string().nullable().optional(),
|
|
1431
|
+
next_cursor: zod.z.string().nullable().optional()
|
|
1432
|
+
}),
|
|
1433
|
+
links: zod.z.object({
|
|
1434
|
+
next: zod.z.string().nullable().optional()
|
|
1435
|
+
}).optional()
|
|
1436
|
+
});
|
|
1437
|
+
|
|
1438
|
+
// src/plugins/codeSubstrate/listWorkflowDrafts/index.ts
|
|
1439
|
+
var listWorkflowDraftsPlugin = kitcore.defineMethod({
|
|
1440
|
+
...codeSubstrateDefaults,
|
|
1441
|
+
name: "listWorkflowDrafts",
|
|
1442
|
+
imports: [chunkTJXDMXEE_cjs.apiPluginRef],
|
|
1443
|
+
type: "list",
|
|
1444
|
+
itemType: "WorkflowDraft",
|
|
1445
|
+
inputSchema: ListWorkflowDraftsOptionsSchema,
|
|
1446
|
+
outputSchema: WorkflowDraftSummarySchema,
|
|
1447
|
+
skipOutputValidation: true,
|
|
1448
|
+
// The handler already returns a clean `{ data, nextCursor }` page, so the
|
|
1449
|
+
// standard list output (no `adaptPage`) applies.
|
|
1450
|
+
output: { type: "list", defaultPageSize: chunkTJXDMXEE_cjs.DEFAULT_PAGE_SIZE },
|
|
1451
|
+
resolvers: { workflow: chunkTJXDMXEE_cjs.workflowIdResolver },
|
|
1452
|
+
run: async ({ imports, input }) => {
|
|
1453
|
+
const api = imports.api;
|
|
1454
|
+
const searchParams = {};
|
|
1455
|
+
if (input.status !== void 0) {
|
|
1456
|
+
searchParams.status = input.status;
|
|
1457
|
+
}
|
|
1458
|
+
if (input.slug !== void 0) {
|
|
1459
|
+
searchParams.slug = input.slug;
|
|
1460
|
+
}
|
|
1461
|
+
if (input.pageSize !== void 0) {
|
|
1462
|
+
searchParams.limit = input.pageSize.toString();
|
|
1463
|
+
}
|
|
1464
|
+
if (input.cursor) {
|
|
1465
|
+
searchParams.cursor = input.cursor;
|
|
1466
|
+
}
|
|
1467
|
+
const raw = await api.get(
|
|
1468
|
+
`${CODE_SUBSTRATE_WORKFLOWS_API}/workflows/${encodeURIComponent(input.workflow)}/drafts`,
|
|
1469
|
+
{
|
|
1470
|
+
searchParams,
|
|
1471
|
+
authRequired: true,
|
|
1472
|
+
resource: { type: "workflow", id: input.workflow }
|
|
1473
|
+
}
|
|
1474
|
+
);
|
|
1475
|
+
const response = ListWorkflowDraftsApiResponseSchema.parse(raw);
|
|
1476
|
+
return {
|
|
1477
|
+
data: response.results,
|
|
1478
|
+
nextCursor: response.meta.next_cursor ?? void 0
|
|
1479
|
+
};
|
|
1480
|
+
}
|
|
1481
|
+
});
|
|
1482
|
+
var GetWorkflowDraftOptionsSchema = zod.z.object({
|
|
1483
|
+
workflow: zod.z.string().uuid().describe("Durable workflow ID"),
|
|
1484
|
+
draft: zod.z.string().uuid().describe("Workflow draft ID")
|
|
1485
|
+
}).describe("Get full details of a workflow draft including source files");
|
|
1486
|
+
var GetWorkflowDraftResponseSchema = WorkflowDraftSchema;
|
|
1487
|
+
|
|
1488
|
+
// src/plugins/codeSubstrate/getWorkflowDraft/index.ts
|
|
1489
|
+
var getWorkflowDraftPlugin = kitcore.defineMethod({
|
|
1490
|
+
...codeSubstrateDefaults,
|
|
1491
|
+
name: "getWorkflowDraft",
|
|
1492
|
+
imports: [chunkTJXDMXEE_cjs.apiPluginRef],
|
|
1493
|
+
itemType: "WorkflowDraft",
|
|
1494
|
+
inputSchema: GetWorkflowDraftOptionsSchema,
|
|
1495
|
+
outputSchema: GetWorkflowDraftResponseSchema,
|
|
1496
|
+
skipOutputValidation: true,
|
|
1497
|
+
output: "item",
|
|
1498
|
+
resolvers: {
|
|
1499
|
+
workflow: chunkTJXDMXEE_cjs.workflowIdResolver,
|
|
1500
|
+
draft: chunkTJXDMXEE_cjs.workflowDraftIdResolver
|
|
1501
|
+
},
|
|
1502
|
+
run: async ({ imports, input }) => {
|
|
1503
|
+
const api = imports.api;
|
|
1504
|
+
const raw = await api.get(
|
|
1505
|
+
`${CODE_SUBSTRATE_WORKFLOWS_API}/workflows/${encodeURIComponent(input.workflow)}/drafts/${encodeURIComponent(input.draft)}`,
|
|
1506
|
+
{
|
|
1507
|
+
authRequired: true,
|
|
1508
|
+
resource: { type: "workflow-draft", id: input.draft }
|
|
1509
|
+
}
|
|
1510
|
+
);
|
|
1511
|
+
return { data: GetWorkflowDraftResponseSchema.parse(raw) };
|
|
1512
|
+
}
|
|
1513
|
+
});
|
|
1514
|
+
var CreateWorkflowDraftOptionsSchema = zod.z.object({
|
|
1515
|
+
workflow: zod.z.string().uuid().describe("Durable workflow ID"),
|
|
1516
|
+
slug: zod.z.string().min(1).max(128).optional().describe(
|
|
1517
|
+
"Optional display name for the draft. When omitted, the server generates one. Need not be unique among the workflow's open drafts."
|
|
1518
|
+
),
|
|
1519
|
+
...WorkflowClientAttributionInputSchema.shape
|
|
1520
|
+
}).refine(hasAccessMethodForHarness, HARNESS_WITHOUT_ACCESS_METHOD_ISSUE).describe(
|
|
1521
|
+
"Fork a new draft from the workflow's current live version (or a blank stub before the first publish)"
|
|
1522
|
+
);
|
|
1523
|
+
var CreateWorkflowDraftResponseSchema = WorkflowDraftSchema;
|
|
1524
|
+
|
|
1525
|
+
// src/plugins/codeSubstrate/createWorkflowDraft/index.ts
|
|
1526
|
+
var createWorkflowDraftPlugin = kitcore.defineMethod({
|
|
1527
|
+
...codeSubstrateDefaults,
|
|
1528
|
+
name: "createWorkflowDraft",
|
|
1529
|
+
imports: [chunkTJXDMXEE_cjs.apiPluginRef],
|
|
1530
|
+
type: "create",
|
|
1531
|
+
itemType: "WorkflowDraft",
|
|
1532
|
+
inputSchema: CreateWorkflowDraftOptionsSchema,
|
|
1533
|
+
outputSchema: CreateWorkflowDraftResponseSchema,
|
|
1534
|
+
skipOutputValidation: true,
|
|
1535
|
+
output: "item",
|
|
1536
|
+
resolvers: { workflow: chunkTJXDMXEE_cjs.workflowIdResolver },
|
|
1537
|
+
run: async ({ imports, input }) => {
|
|
1538
|
+
const api = imports.api;
|
|
1539
|
+
const body = {};
|
|
1540
|
+
if (input.slug !== void 0) {
|
|
1541
|
+
body.slug = input.slug;
|
|
1542
|
+
}
|
|
1543
|
+
const creationClient = toWireWorkflowClientAttribution(input);
|
|
1544
|
+
if (creationClient !== void 0) {
|
|
1545
|
+
body.creation_client = creationClient;
|
|
1546
|
+
}
|
|
1547
|
+
const raw = await api.post(
|
|
1548
|
+
`${CODE_SUBSTRATE_WORKFLOWS_API}/workflows/${encodeURIComponent(input.workflow)}/drafts`,
|
|
1549
|
+
body,
|
|
1550
|
+
{
|
|
1551
|
+
authRequired: true,
|
|
1552
|
+
resource: { type: "workflow", id: input.workflow }
|
|
1553
|
+
}
|
|
1554
|
+
);
|
|
1555
|
+
return { data: CreateWorkflowDraftResponseSchema.parse(raw) };
|
|
1556
|
+
}
|
|
1557
|
+
});
|
|
1558
|
+
var TRIGGER_MANUAL_CONFLICT_MESSAGE2 = "Provide `trigger` or `manual: true`, not both \u2014 a trigger together with manual: true is a contradiction.";
|
|
1559
|
+
var UpdateWorkflowDraftOptionsSchema = zod.z.object({
|
|
1560
|
+
workflow: zod.z.string().uuid().describe("Durable workflow ID"),
|
|
1561
|
+
draft: zod.z.string().uuid().describe("Workflow draft ID"),
|
|
1562
|
+
sourceFiles: SourceFilesSchema,
|
|
1563
|
+
zapierDurableVersion: zod.z.string().optional().describe(
|
|
1564
|
+
'Exact semver of @zapier/zapier-durable to use (e.g. "1.2.3"), or "latest". Leaves the stored pin unchanged if omitted. A draft stores what you pass verbatim, so "latest" is recorded as-is and resolved to an exact version when the draft is published -- reading the draft back shows "latest", not a version. Ranges (^1.2.3, ~1.2) are rejected at publish.'
|
|
1565
|
+
),
|
|
1566
|
+
dependencies: zod.z.record(zod.z.string(), zod.z.string()).optional().describe(
|
|
1567
|
+
'Optional npm package dependencies. A version of "latest" is resolved by the server for @zapier/zapier-durable and @zapier/zapier-sdk only; every other value, including a "latest" on any other package, is passed to the install as written.'
|
|
1568
|
+
),
|
|
1569
|
+
draftRevision: zod.z.number().int().min(0).optional().describe(
|
|
1570
|
+
"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."
|
|
1571
|
+
),
|
|
1572
|
+
trigger: TriggerConfigSchema.nullish().describe(
|
|
1573
|
+
"Trigger configuration. Omit to leave the stored trigger unchanged, pass null to clear it, or pass an object to replace it; for an on-demand, triggerless workflow, clear this and pass `manual: true` instead."
|
|
1574
|
+
),
|
|
1575
|
+
connections: zod.z.record(zod.z.string(), ConnectionBindingSchema).nullish().describe(
|
|
1576
|
+
"Map of connection aliases to Zapier connections used by the workflow. Pass `null` to clear an existing binding."
|
|
1577
|
+
),
|
|
1578
|
+
appVersions: zod.z.record(zod.z.string(), AppVersionBindingSchema).nullish().describe(
|
|
1579
|
+
"Map of app keys to pinned app implementation/version used by the workflow. Pass `null` to clear an existing binding."
|
|
1580
|
+
),
|
|
1581
|
+
manual: zod.z.boolean().optional().describe(
|
|
1582
|
+
"Declare this draft on-demand and triggerless. Pass `manual: true` only when omitting `trigger` (or clearing it with `trigger: null`); passing both is a contradiction the API rejects with a 400. Setting a `trigger` later clears a previously stored `manual: true`."
|
|
1583
|
+
),
|
|
1584
|
+
...WorkflowClientAttributionInputSchema.shape
|
|
1585
|
+
}).refine(({ trigger, manual }) => manual !== true || trigger == null, {
|
|
1586
|
+
message: TRIGGER_MANUAL_CONFLICT_MESSAGE2
|
|
1587
|
+
}).refine(hasAccessMethodForHarness, HARNESS_WITHOUT_ACCESS_METHOD_ISSUE).describe("Update (autosave) an open workflow draft");
|
|
1588
|
+
var UpdateWorkflowDraftResponseSchema = WorkflowDraftSchema;
|
|
1589
|
+
|
|
1590
|
+
// src/plugins/codeSubstrate/updateWorkflowDraft/index.ts
|
|
1591
|
+
var updateWorkflowDraftPlugin = kitcore.defineMethod({
|
|
1592
|
+
...codeSubstrateDefaults,
|
|
1593
|
+
name: "updateWorkflowDraft",
|
|
1594
|
+
imports: [chunkTJXDMXEE_cjs.apiPluginRef],
|
|
1595
|
+
type: "update",
|
|
1596
|
+
itemType: "WorkflowDraft",
|
|
1597
|
+
inputSchema: UpdateWorkflowDraftOptionsSchema,
|
|
1598
|
+
outputSchema: UpdateWorkflowDraftResponseSchema,
|
|
1599
|
+
skipOutputValidation: true,
|
|
1600
|
+
output: "item",
|
|
1601
|
+
resolvers: {
|
|
1602
|
+
workflow: chunkTJXDMXEE_cjs.workflowIdResolver,
|
|
1603
|
+
draft: chunkTJXDMXEE_cjs.workflowDraftIdResolver,
|
|
1604
|
+
sourceFiles: sourceFilesResolver
|
|
1605
|
+
},
|
|
1606
|
+
run: async ({ imports, input }) => {
|
|
1607
|
+
const api = imports.api;
|
|
1608
|
+
const body = { source_files: input.sourceFiles };
|
|
1609
|
+
if (input.zapierDurableVersion !== void 0) {
|
|
1610
|
+
body.zapier_durable_version = input.zapierDurableVersion;
|
|
1611
|
+
}
|
|
1612
|
+
if (input.dependencies !== void 0) {
|
|
1613
|
+
body.dependencies = input.dependencies;
|
|
1614
|
+
}
|
|
1615
|
+
if (input.draftRevision !== void 0) {
|
|
1616
|
+
body.draft_revision = input.draftRevision;
|
|
1617
|
+
}
|
|
1618
|
+
if (input.trigger === null) {
|
|
1619
|
+
body.trigger = null;
|
|
1620
|
+
} else if (input.trigger !== void 0) {
|
|
1621
|
+
body.trigger = toWireTrigger(input.trigger);
|
|
1622
|
+
}
|
|
1623
|
+
if (input.connections === null) {
|
|
1624
|
+
body.connections = null;
|
|
1625
|
+
} else if (input.connections !== void 0) {
|
|
1626
|
+
body.connections = toWireConnections(input.connections);
|
|
1627
|
+
}
|
|
1628
|
+
if (input.appVersions === null) {
|
|
1629
|
+
body.app_versions = null;
|
|
1630
|
+
} else if (input.appVersions !== void 0) {
|
|
1631
|
+
body.app_versions = toWireAppVersions(input.appVersions);
|
|
1632
|
+
}
|
|
1633
|
+
if (input.manual !== void 0) {
|
|
1634
|
+
body.manual = input.manual;
|
|
1635
|
+
}
|
|
1636
|
+
const creationClient = toWireWorkflowClientAttribution(input);
|
|
1637
|
+
if (creationClient !== void 0) {
|
|
1638
|
+
body.creation_client = creationClient;
|
|
1639
|
+
}
|
|
1640
|
+
const raw = await api.put(
|
|
1641
|
+
`${CODE_SUBSTRATE_WORKFLOWS_API}/workflows/${encodeURIComponent(input.workflow)}/drafts/${encodeURIComponent(input.draft)}`,
|
|
1642
|
+
body,
|
|
1643
|
+
{
|
|
1644
|
+
authRequired: true,
|
|
1645
|
+
resource: { type: "workflow-draft", id: input.draft },
|
|
1646
|
+
// A 409 is the optimistic-concurrency signal: the draft's revision
|
|
1647
|
+
// moved past the caller's `draftRevision` (someone else saved in
|
|
1648
|
+
// between). Type it so callers can catch ZapierConflictError,
|
|
1649
|
+
// re-read the draft, and retry instead of blind-overwriting.
|
|
1650
|
+
customErrorHandler: ({ status, data }) => {
|
|
1651
|
+
if (status === 409) {
|
|
1652
|
+
const detail = chunkTJXDMXEE_cjs.extractErrorDetail(data);
|
|
1653
|
+
return new chunkTJXDMXEE_cjs.ZapierConflictError(
|
|
1654
|
+
`${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.`,
|
|
1655
|
+
{ statusCode: status, resourceType: "workflow-draft" }
|
|
1656
|
+
);
|
|
1657
|
+
}
|
|
1658
|
+
return void 0;
|
|
1659
|
+
}
|
|
1660
|
+
}
|
|
1661
|
+
);
|
|
1662
|
+
return { data: UpdateWorkflowDraftResponseSchema.parse(raw) };
|
|
1663
|
+
}
|
|
1664
|
+
});
|
|
1665
|
+
var DiscardWorkflowDraftOptionsSchema = zod.z.object({
|
|
1666
|
+
workflow: zod.z.string().uuid().describe("Durable workflow ID"),
|
|
1667
|
+
draft: zod.z.string().uuid().describe("Workflow draft ID")
|
|
1668
|
+
}).describe(
|
|
1669
|
+
"Discard an open workflow draft (soft delete). The draft's unpublished edits stop resolving; the published version is untouched."
|
|
1670
|
+
);
|
|
1671
|
+
var DiscardWorkflowDraftResponseSchema = WorkflowDraftSchema;
|
|
1672
|
+
|
|
1673
|
+
// src/plugins/codeSubstrate/discardWorkflowDraft/index.ts
|
|
1674
|
+
var discardWorkflowDraftPlugin = kitcore.defineMethod({
|
|
1675
|
+
...codeSubstrateDefaults,
|
|
1676
|
+
name: "discardWorkflowDraft",
|
|
1677
|
+
imports: [chunkTJXDMXEE_cjs.apiPluginRef],
|
|
1678
|
+
type: "delete",
|
|
1679
|
+
itemType: "WorkflowDraft",
|
|
1680
|
+
// Soft delete returns the discarded draft, not the `{ success: boolean }`
|
|
1681
|
+
// shape the docs generator assumes for delete methods.
|
|
1682
|
+
returnType: "WorkflowDraftItem",
|
|
1683
|
+
// Discard throws away the draft's unpublished edits, so it warrants the
|
|
1684
|
+
// same interactive confirmation as deleteWorkflow.
|
|
1685
|
+
confirm: "delete",
|
|
1686
|
+
inputSchema: DiscardWorkflowDraftOptionsSchema,
|
|
1687
|
+
outputSchema: DiscardWorkflowDraftResponseSchema,
|
|
1688
|
+
skipOutputValidation: true,
|
|
1689
|
+
output: "item",
|
|
1690
|
+
resolvers: {
|
|
1691
|
+
workflow: chunkTJXDMXEE_cjs.workflowIdResolver,
|
|
1692
|
+
draft: chunkTJXDMXEE_cjs.workflowDraftIdResolver
|
|
1693
|
+
},
|
|
1694
|
+
run: async ({ imports, input }) => {
|
|
1695
|
+
const api = imports.api;
|
|
1696
|
+
const raw = await api.delete(
|
|
1697
|
+
`${CODE_SUBSTRATE_WORKFLOWS_API}/workflows/${encodeURIComponent(input.workflow)}/drafts/${encodeURIComponent(input.draft)}`,
|
|
1698
|
+
void 0,
|
|
1699
|
+
{
|
|
1700
|
+
authRequired: true,
|
|
1701
|
+
resource: { type: "workflow-draft", id: input.draft }
|
|
1702
|
+
}
|
|
1703
|
+
);
|
|
1704
|
+
return { data: DiscardWorkflowDraftResponseSchema.parse(raw) };
|
|
1705
|
+
}
|
|
1706
|
+
});
|
|
1707
|
+
var PublishWorkflowDraftOptionsSchema = zod.z.object({
|
|
1708
|
+
workflow: zod.z.string().uuid().describe("Durable workflow ID"),
|
|
1709
|
+
draft: zod.z.string().uuid().describe("Workflow draft ID"),
|
|
1710
|
+
enabled: zod.z.boolean().optional().describe(
|
|
1711
|
+
"Set the workflow's enabled state as part of the publish. If omitted, the current enabled state is preserved."
|
|
1712
|
+
).meta({ negatable: "disabled" }),
|
|
1713
|
+
draftRevision: zod.z.number().int().min(0).optional().describe(
|
|
1714
|
+
"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."
|
|
1715
|
+
),
|
|
1716
|
+
manual: zod.z.boolean().optional().describe(
|
|
1717
|
+
"Declare this publish on-demand and triggerless, overriding the draft's stored intent for this publish only. Pass `manual: true` only when the draft has no trigger configured; the API rejects a draft with a trigger published as `manual: true` as a contradiction (400)."
|
|
1718
|
+
),
|
|
1719
|
+
...WorkflowClientAttributionInputSchema.shape
|
|
1720
|
+
}).refine(hasAccessMethodForHarness, HARNESS_WITHOUT_ACCESS_METHOD_ISSUE).describe(
|
|
1721
|
+
"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."
|
|
1722
|
+
);
|
|
1723
|
+
var PublishWorkflowDraftResponseSchema = zod.z.object({
|
|
1724
|
+
draft: WorkflowDraftSchema.describe(
|
|
1725
|
+
"The consumed draft: status is 'discarded' and discarded_at is set. base_version_id still records the version the draft was forked from."
|
|
1726
|
+
),
|
|
1727
|
+
version: WorkflowVersionSchema.describe(
|
|
1728
|
+
"The newly published immutable workflow version, now live."
|
|
1729
|
+
)
|
|
1730
|
+
});
|
|
1731
|
+
|
|
1732
|
+
// src/plugins/codeSubstrate/publishWorkflowDraft/index.ts
|
|
1733
|
+
var publishWorkflowDraftPlugin = kitcore.defineMethod({
|
|
1734
|
+
...codeSubstrateDefaults,
|
|
1735
|
+
name: "publishWorkflowDraft",
|
|
1736
|
+
imports: [chunkTJXDMXEE_cjs.apiPluginRef],
|
|
1737
|
+
type: "create",
|
|
1738
|
+
itemType: "WorkflowVersion",
|
|
1739
|
+
// The response is the composite `{ draft, version }`, not the bare
|
|
1740
|
+
// `WorkflowVersionItem` the docs generator derives from itemType.
|
|
1741
|
+
returnType: "PublishWorkflowDraftResponse",
|
|
1742
|
+
inputSchema: PublishWorkflowDraftOptionsSchema,
|
|
1743
|
+
outputSchema: PublishWorkflowDraftResponseSchema,
|
|
1744
|
+
skipOutputValidation: true,
|
|
1745
|
+
output: "item",
|
|
1746
|
+
resolvers: {
|
|
1747
|
+
workflow: chunkTJXDMXEE_cjs.workflowIdResolver,
|
|
1748
|
+
draft: chunkTJXDMXEE_cjs.workflowDraftIdResolver
|
|
1749
|
+
},
|
|
1750
|
+
run: async ({ imports, input }) => {
|
|
1751
|
+
const api = imports.api;
|
|
1752
|
+
const body = {};
|
|
1753
|
+
if (input.enabled !== void 0) {
|
|
1754
|
+
body.enabled = input.enabled;
|
|
1755
|
+
}
|
|
1756
|
+
if (input.draftRevision !== void 0) {
|
|
1757
|
+
body.draft_revision = input.draftRevision;
|
|
1758
|
+
}
|
|
1759
|
+
if (input.manual !== void 0) {
|
|
1760
|
+
body.manual = input.manual;
|
|
1761
|
+
}
|
|
1762
|
+
const creationClient = toWireWorkflowClientAttribution(input);
|
|
1763
|
+
if (creationClient !== void 0) {
|
|
1764
|
+
body.creation_client = creationClient;
|
|
1765
|
+
}
|
|
1766
|
+
const raw = await api.post(
|
|
1767
|
+
`${CODE_SUBSTRATE_WORKFLOWS_API}/workflows/${encodeURIComponent(input.workflow)}/drafts/${encodeURIComponent(input.draft)}/publish`,
|
|
1768
|
+
body,
|
|
1769
|
+
{
|
|
1770
|
+
authRequired: true,
|
|
1771
|
+
resource: { type: "workflow-draft", id: input.draft },
|
|
1772
|
+
// Preserve the endpoint's distinct failure modes instead of letting
|
|
1773
|
+
// them flatten into a generic API error:
|
|
1774
|
+
// 409 — the draft was edited concurrently (draft_revision moved past
|
|
1775
|
+
// the caller's), or a trigger subscription switchover is
|
|
1776
|
+
// already in progress. Retryable after re-reading the draft.
|
|
1777
|
+
// 503 — the trigger config could not be validated against the
|
|
1778
|
+
// platform catalog; validation is fail-closed so the publish
|
|
1779
|
+
// is rejected rather than committing unvalidated config.
|
|
1780
|
+
// Retryable as-is.
|
|
1781
|
+
// 400 (invalid zapier_durable_version / trigger config) already maps
|
|
1782
|
+
// to ZapierValidationError via the client's default handling.
|
|
1783
|
+
customErrorHandler: ({ status, data }) => {
|
|
1784
|
+
if (status === 409) {
|
|
1785
|
+
const detail = chunkTJXDMXEE_cjs.extractErrorDetail(data);
|
|
1786
|
+
return new chunkTJXDMXEE_cjs.ZapierConflictError(
|
|
1787
|
+
`${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.`,
|
|
1788
|
+
{ statusCode: status, resourceType: "workflow-draft" }
|
|
1789
|
+
);
|
|
1790
|
+
}
|
|
1791
|
+
if (status === 503) {
|
|
1792
|
+
const detail = chunkTJXDMXEE_cjs.extractErrorDetail(data);
|
|
1793
|
+
return new chunkTJXDMXEE_cjs.ZapierApiError(
|
|
1794
|
+
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.",
|
|
1795
|
+
{ statusCode: status }
|
|
1796
|
+
);
|
|
1797
|
+
}
|
|
1798
|
+
return void 0;
|
|
1799
|
+
}
|
|
1800
|
+
}
|
|
1801
|
+
);
|
|
1802
|
+
return { data: PublishWorkflowDraftResponseSchema.parse(raw) };
|
|
1803
|
+
}
|
|
1804
|
+
});
|
|
1805
|
+
var WORKFLOW_RUN_WAIT_MAX_SECONDS = 30;
|
|
1806
|
+
var TERMINAL_RUN_STATUSES = /* @__PURE__ */ new Set(["finished", "failed", "cancelled"]);
|
|
1807
|
+
var FIRST_BACKOFF_MILLISECONDS = 250;
|
|
1808
|
+
var MAX_BACKOFF_MILLISECONDS = 2500;
|
|
1809
|
+
var RunWaitSecondsSchema = zod.z.number().int().min(0).optional().describe(
|
|
1810
|
+
"Wait for the run to be finished, failed or cancelled, up to this many seconds, then return it as it stands. The answer comes as soon as the run ends."
|
|
1811
|
+
);
|
|
1812
|
+
var runWaitSearchParams = (holdSeconds) => holdSeconds > 0 ? { wait_seconds: String(holdSeconds) } : void 0;
|
|
1813
|
+
async function readRunUntilEnded({
|
|
1814
|
+
waitSeconds,
|
|
1815
|
+
read,
|
|
1816
|
+
pendingWhileNotFound = false
|
|
1817
|
+
}) {
|
|
1818
|
+
const deadline = Date.now() + waitSeconds * 1e3;
|
|
1819
|
+
let latest;
|
|
1820
|
+
let notFound;
|
|
1821
|
+
let backoffMilliseconds = FIRST_BACKOFF_MILLISECONDS;
|
|
1822
|
+
do {
|
|
1823
|
+
const remaining = Math.max(0, deadline - Date.now());
|
|
1824
|
+
const requestWaitSeconds = Math.min(
|
|
1825
|
+
WORKFLOW_RUN_WAIT_MAX_SECONDS,
|
|
1826
|
+
Math.ceil(remaining / 1e3)
|
|
1827
|
+
);
|
|
1828
|
+
const askedAt = Date.now();
|
|
1829
|
+
try {
|
|
1830
|
+
latest = await read(requestWaitSeconds);
|
|
1831
|
+
if (TERMINAL_RUN_STATUSES.has(latest.status)) return latest;
|
|
1832
|
+
} catch (error) {
|
|
1833
|
+
if (!pendingWhileNotFound || !chunkTJXDMXEE_cjs.isZapierNotFoundError(error)) throw error;
|
|
1834
|
+
notFound = error;
|
|
1835
|
+
}
|
|
1836
|
+
if (Date.now() - askedAt < requestWaitSeconds * 1e3 / 2) {
|
|
1837
|
+
await chunkTJXDMXEE_cjs.sleep(Math.min(backoffMilliseconds, deadline - Date.now()));
|
|
1838
|
+
backoffMilliseconds = Math.min(
|
|
1839
|
+
backoffMilliseconds * 2,
|
|
1840
|
+
MAX_BACKOFF_MILLISECONDS
|
|
1841
|
+
);
|
|
1842
|
+
}
|
|
1843
|
+
} while (Date.now() < deadline);
|
|
1844
|
+
if (latest) return latest;
|
|
1845
|
+
throw notFound;
|
|
1846
|
+
}
|
|
1847
|
+
var WorkflowRunStatusSchema = zod.z.union([
|
|
1848
|
+
zod.z.enum(["initialized", "started", "finished", "failed", "cancelled"]),
|
|
1849
|
+
zod.z.string()
|
|
1850
|
+
]).describe(
|
|
1851
|
+
"Workflow run lifecycle status. `finished` / `failed` / `cancelled` are terminal."
|
|
1852
|
+
);
|
|
1853
|
+
var workflowRunListItemBase = zod.z.object({
|
|
1854
|
+
id: zod.z.string().describe("Workflow run ID (UUIDv7). Unique across live and draft runs."),
|
|
1855
|
+
durable_run_id: zod.z.string().nullable().describe(
|
|
1856
|
+
"Linked code-substrate-runner run ID. Null until the durable run is created."
|
|
1857
|
+
),
|
|
1858
|
+
status: WorkflowRunStatusSchema,
|
|
1859
|
+
input: zod.z.unknown().describe("Input passed to the run"),
|
|
1860
|
+
error: zod.z.unknown().nullable().describe("Error payload when status is `failed` (null otherwise)"),
|
|
1861
|
+
created_at: zod.z.string().describe("When the run was created (ISO-8601)"),
|
|
1862
|
+
updated_at: zod.z.string().describe("When the run was last updated (ISO-8601)")
|
|
1863
|
+
});
|
|
1864
|
+
var LiveWorkflowRunListItemSchema = workflowRunListItemBase.extend({
|
|
1865
|
+
kind: zod.z.literal("live").describe("A run of a published workflow version."),
|
|
1866
|
+
trigger_id: zod.z.string().nullable().describe(
|
|
1867
|
+
"ID of the trigger that fired this run. Null for runs created without a trigger."
|
|
1868
|
+
),
|
|
1869
|
+
workflow_version_id: zod.z.string().nullable().describe("Workflow version the run is bound to. Null in rare edge cases.")
|
|
1870
|
+
});
|
|
1871
|
+
var DraftWorkflowRunListItemSchema = workflowRunListItemBase.extend({
|
|
1872
|
+
kind: zod.z.literal("draft").describe("A run launched from a workflow draft via `runWorkflowDraft`."),
|
|
1873
|
+
workflow_draft_id: zod.z.string().nullable().describe(
|
|
1874
|
+
"The draft this run was launched from. Null once that draft has been deleted (the run outlives its draft)."
|
|
1875
|
+
),
|
|
1876
|
+
draft_revision: zod.z.number().int().describe("The draft's revision at the moment this run was created.")
|
|
1877
|
+
});
|
|
1878
|
+
var WorkflowRunListItemSchema = zod.z.discriminatedUnion("kind", [
|
|
1879
|
+
LiveWorkflowRunListItemSchema,
|
|
1880
|
+
DraftWorkflowRunListItemSchema
|
|
1881
|
+
]);
|
|
1882
|
+
var ListWorkflowRunsOptionsSchema = zod.z.object({
|
|
1883
|
+
workflow: zod.z.string().uuid().describe("Durable workflow ID"),
|
|
1884
|
+
pageSize: zod.z.number().int().min(1).max(100).optional().describe("Number of runs per page (max 100)"),
|
|
1885
|
+
kind: zod.z.enum(["live", "draft"]).optional().describe(
|
|
1886
|
+
"Return only runs of this kind. Omit for both, interleaved by recency."
|
|
1887
|
+
),
|
|
1888
|
+
cursor: zod.z.string().optional().describe("Pagination cursor"),
|
|
1889
|
+
maxItems: zod.z.number().int().min(1).optional().describe("Maximum total runs to return across all pages")
|
|
1890
|
+
}).describe(
|
|
1891
|
+
"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."
|
|
1892
|
+
);
|
|
1893
|
+
var ListWorkflowRunsApiResponseSchema = zod.z.object({
|
|
1894
|
+
results: zod.z.array(WorkflowRunListItemSchema),
|
|
1895
|
+
meta: zod.z.object({
|
|
1896
|
+
limit: zod.z.number(),
|
|
1897
|
+
cursor: zod.z.string().nullable().optional(),
|
|
1898
|
+
next_cursor: zod.z.string().nullable().optional()
|
|
1899
|
+
}),
|
|
1900
|
+
links: zod.z.object({
|
|
1901
|
+
next: zod.z.string().nullable().optional()
|
|
1902
|
+
}).optional()
|
|
1903
|
+
});
|
|
1904
|
+
|
|
1905
|
+
// src/plugins/codeSubstrate/getWorkflowRun/schemas.ts
|
|
1906
|
+
var GetWorkflowRunOptionsSchema = zod.z.object({
|
|
1907
|
+
// Picker-only field — the API endpoint is /workflows/runs/:id and
|
|
1908
|
+
// does not take a workflow id, but the run-id picker is scoped to a
|
|
1909
|
+
// parent workflow so the user can browse runs without enumerating
|
|
1910
|
+
// every run across every workflow on the account.
|
|
1911
|
+
workflow: zod.z.string().uuid().optional().describe(
|
|
1912
|
+
"Parent workflow ID \u2014 used only to scope the CLI run-id picker; ignored by the API call."
|
|
1913
|
+
),
|
|
1914
|
+
run: zod.z.string().uuid().describe("Workflow run ID"),
|
|
1915
|
+
waitSeconds: RunWaitSecondsSchema
|
|
1916
|
+
}).describe(
|
|
1917
|
+
"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)"
|
|
1918
|
+
);
|
|
1919
|
+
var workflowRunBase = zod.z.object({
|
|
1920
|
+
id: zod.z.string().describe("Workflow run ID (UUIDv7). Unique across live and draft runs."),
|
|
1921
|
+
workflow_id: zod.z.string().describe("The workflow this run belongs to"),
|
|
1922
|
+
durable_run_id: zod.z.string().nullable().describe(
|
|
1923
|
+
"Linked code-substrate-runner run ID. Null until the durable run is created."
|
|
1924
|
+
),
|
|
1925
|
+
status: WorkflowRunStatusSchema,
|
|
1926
|
+
input: zod.z.unknown().describe("Input passed to the run"),
|
|
1927
|
+
output: zod.z.unknown().nullable().describe("Return value, present when status is `finished`"),
|
|
1928
|
+
error: zod.z.unknown().nullable().describe("Error payload when status is `failed` (null otherwise)"),
|
|
1929
|
+
created_at: zod.z.string().describe("When the run was created (ISO-8601)"),
|
|
1930
|
+
updated_at: zod.z.string().describe("When the run was last updated (ISO-8601)")
|
|
1931
|
+
});
|
|
1932
|
+
var LiveWorkflowRunSchema = workflowRunBase.extend({
|
|
1933
|
+
kind: zod.z.literal("live").describe("A run of a published workflow version."),
|
|
1934
|
+
trigger_id: zod.z.string().nullable().describe(
|
|
1935
|
+
"ID of the trigger that fired this run. Null for runs created without a trigger."
|
|
1936
|
+
),
|
|
1937
|
+
workflow_version_id: zod.z.string().nullable().describe("Workflow version the run is bound to. Null in rare edge cases.")
|
|
1938
|
+
});
|
|
1939
|
+
var DraftWorkflowRunSchema = workflowRunBase.extend({
|
|
1940
|
+
kind: zod.z.literal("draft").describe("A run launched from a workflow draft via `runWorkflowDraft`."),
|
|
1941
|
+
workflow_draft_id: zod.z.string().nullable().describe(
|
|
1942
|
+
"The draft this run was launched from. Null once that draft has been deleted (the run outlives its draft)."
|
|
1943
|
+
),
|
|
1944
|
+
draft_revision: zod.z.number().int().describe(
|
|
1945
|
+
"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."
|
|
1946
|
+
)
|
|
1947
|
+
});
|
|
1948
|
+
var GetWorkflowRunResponseSchema = zod.z.discriminatedUnion("kind", [
|
|
1949
|
+
LiveWorkflowRunSchema,
|
|
1950
|
+
DraftWorkflowRunSchema
|
|
1951
|
+
]);
|
|
1952
|
+
|
|
1953
|
+
// src/plugins/codeSubstrate/getWorkflowRun/index.ts
|
|
1954
|
+
var getWorkflowRunPlugin = kitcore.defineMethod({
|
|
1955
|
+
...codeSubstrateDefaults,
|
|
1956
|
+
name: "getWorkflowRun",
|
|
1957
|
+
imports: [chunkTJXDMXEE_cjs.apiPluginRef],
|
|
1958
|
+
itemType: "WorkflowRun",
|
|
1959
|
+
inputSchema: GetWorkflowRunOptionsSchema,
|
|
1960
|
+
outputSchema: GetWorkflowRunResponseSchema,
|
|
1961
|
+
skipOutputValidation: true,
|
|
1962
|
+
output: "item",
|
|
1963
|
+
resolvers: {
|
|
1964
|
+
workflow: chunkTJXDMXEE_cjs.workflowIdResolver,
|
|
1965
|
+
run: chunkTJXDMXEE_cjs.workflowRunIdResolver
|
|
1966
|
+
},
|
|
1967
|
+
run: async ({ imports, input }) => {
|
|
1968
|
+
const api = imports.api;
|
|
1969
|
+
const read = async (holdSeconds) => GetWorkflowRunResponseSchema.parse(
|
|
1970
|
+
await api.get(
|
|
1971
|
+
`${CODE_SUBSTRATE_WORKFLOWS_API}/workflows/runs/${encodeURIComponent(input.run)}`,
|
|
1972
|
+
{
|
|
1973
|
+
authRequired: true,
|
|
1974
|
+
resource: { type: "workflow-run", id: input.run },
|
|
1975
|
+
searchParams: runWaitSearchParams(holdSeconds)
|
|
1976
|
+
}
|
|
1977
|
+
)
|
|
1978
|
+
);
|
|
1979
|
+
return {
|
|
1980
|
+
data: await readRunUntilEnded({
|
|
1981
|
+
waitSeconds: input.waitSeconds ?? 0,
|
|
1982
|
+
read
|
|
1983
|
+
})
|
|
1984
|
+
};
|
|
1985
|
+
}
|
|
1986
|
+
});
|
|
1987
|
+
var RunWorkflowDraftOptionsSchema = zod.z.object({
|
|
1988
|
+
workflow: zod.z.string().uuid().describe("Durable workflow ID"),
|
|
1989
|
+
draft: zod.z.string().uuid().describe("Workflow draft ID"),
|
|
1990
|
+
draftRevision: zod.z.number().int().min(0).describe(
|
|
1991
|
+
"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."
|
|
1992
|
+
),
|
|
1993
|
+
input: JsonPayloadSchema.optional().describe(
|
|
1994
|
+
"Input data passed to the workflow. Accepts any JSON value, or its JSON-string encoding. Omit for a workflow that takes no input."
|
|
1995
|
+
),
|
|
1996
|
+
waitSeconds: RunWaitSecondsSchema
|
|
1997
|
+
}).describe(
|
|
1998
|
+
"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. Without `waitSeconds` the run comes back at once, `initialized`; follow it with `getWorkflowRun`, or list it via `listWorkflowRuns` with `kind: \"draft\"`. With `waitSeconds`, the run is returned once it ends (or as it stands when the wait runs out), with `output` set when it finished."
|
|
1999
|
+
);
|
|
2000
|
+
var RunWorkflowDraftResponseSchema = zod.z.object({
|
|
2001
|
+
id: zod.z.string().describe("Workflow run ID (UUIDv7). Unique across live and draft runs."),
|
|
2002
|
+
kind: zod.z.literal("draft").describe("A run launched from a workflow draft."),
|
|
2003
|
+
workflow_id: zod.z.string().describe("The workflow this run belongs to"),
|
|
2004
|
+
durable_run_id: zod.z.string().nullable().describe(
|
|
2005
|
+
"Linked code-substrate-runner run ID. Usually still null in this response \u2014 the run is accepted and launched in the background."
|
|
2006
|
+
),
|
|
2007
|
+
workflow_draft_id: zod.z.string().nullable().describe(
|
|
2008
|
+
"The draft this run was launched from. Becomes null once that draft is deleted \u2014 the run outlives its draft."
|
|
2009
|
+
),
|
|
2010
|
+
draft_revision: zod.z.number().int().describe("The draft's revision at the moment this run was created."),
|
|
2011
|
+
status: WorkflowRunStatusSchema,
|
|
2012
|
+
input: zod.z.unknown().describe("Input passed to the run"),
|
|
2013
|
+
output: zod.z.unknown().nullable().describe("Return value, present when status is `finished`"),
|
|
2014
|
+
error: zod.z.unknown().nullable().describe("Error payload when status is `failed` (null otherwise)"),
|
|
2015
|
+
created_at: zod.z.string().describe("When the run was created (ISO-8601)"),
|
|
2016
|
+
updated_at: zod.z.string().describe("When the run was last updated (ISO-8601)")
|
|
2017
|
+
});
|
|
2018
|
+
|
|
2019
|
+
// src/plugins/codeSubstrate/runWorkflowDraft/index.ts
|
|
2020
|
+
var runWorkflowDraftPlugin = kitcore.defineMethod({
|
|
2021
|
+
...codeSubstrateDefaults,
|
|
2022
|
+
name: "runWorkflowDraft",
|
|
2023
|
+
imports: [chunkTJXDMXEE_cjs.apiPluginRef, getWorkflowRunPlugin],
|
|
2024
|
+
type: "create",
|
|
2025
|
+
itemType: "WorkflowRun",
|
|
2026
|
+
// The response is the draft variant of the run resource (`kind: "draft"`,
|
|
2027
|
+
// required `workflow_draft_id` / `draft_revision`), not the mixed-kind
|
|
2028
|
+
// `WorkflowRun` item the docs generator derives from itemType.
|
|
2029
|
+
returnType: "RunWorkflowDraftResponse",
|
|
2030
|
+
inputSchema: RunWorkflowDraftOptionsSchema,
|
|
2031
|
+
outputSchema: RunWorkflowDraftResponseSchema,
|
|
2032
|
+
skipOutputValidation: true,
|
|
2033
|
+
output: "item",
|
|
2034
|
+
resolvers: {
|
|
2035
|
+
workflow: chunkTJXDMXEE_cjs.workflowIdResolver,
|
|
2036
|
+
draft: chunkTJXDMXEE_cjs.workflowDraftIdResolver,
|
|
2037
|
+
draftRevision: chunkTJXDMXEE_cjs.workflowDraftRevisionResolver
|
|
2038
|
+
},
|
|
2039
|
+
run: async ({ imports, input }) => {
|
|
2040
|
+
const api = imports.api;
|
|
2041
|
+
const body = {
|
|
2042
|
+
draft_revision: input.draftRevision
|
|
2043
|
+
};
|
|
2044
|
+
if (input.input !== void 0) {
|
|
2045
|
+
body.input = input.input;
|
|
2046
|
+
}
|
|
2047
|
+
const raw = await api.post(
|
|
2048
|
+
`${CODE_SUBSTRATE_WORKFLOWS_API}/workflows/${encodeURIComponent(input.workflow)}/drafts/${encodeURIComponent(input.draft)}/runs`,
|
|
2049
|
+
body,
|
|
2050
|
+
{
|
|
2051
|
+
authRequired: true,
|
|
2052
|
+
resource: { type: "workflow-draft", id: input.draft },
|
|
2053
|
+
// 409 — the draft was edited concurrently (its draft_revision moved
|
|
2054
|
+
// past the caller's). Retryable after re-reading the draft. 429 (the
|
|
2055
|
+
// per-user draft-run rate limit) needs no handling here: the client
|
|
2056
|
+
// retries with backoff and then throws ZapierRateLimitError.
|
|
2057
|
+
customErrorHandler: ({ status, data }) => {
|
|
2058
|
+
if (status === 409) {
|
|
2059
|
+
const detail = chunkTJXDMXEE_cjs.extractErrorDetail(data);
|
|
2060
|
+
return new chunkTJXDMXEE_cjs.ZapierConflictError(
|
|
2061
|
+
`${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.`,
|
|
2062
|
+
{ statusCode: status, resourceType: "workflow-draft" }
|
|
2063
|
+
);
|
|
2064
|
+
}
|
|
2065
|
+
return void 0;
|
|
2066
|
+
}
|
|
2067
|
+
}
|
|
2068
|
+
);
|
|
2069
|
+
const started = RunWorkflowDraftResponseSchema.parse(raw);
|
|
2070
|
+
if (!input.waitSeconds) return { data: started };
|
|
2071
|
+
const { data: run } = await imports.getWorkflowRun({
|
|
2072
|
+
run: started.id,
|
|
2073
|
+
waitSeconds: input.waitSeconds
|
|
2074
|
+
});
|
|
2075
|
+
return { data: RunWorkflowDraftResponseSchema.parse(run) };
|
|
2076
|
+
}
|
|
2077
|
+
});
|
|
2078
|
+
var listWorkflowRunsPlugin = kitcore.defineMethod({
|
|
2079
|
+
...codeSubstrateDefaults,
|
|
2080
|
+
name: "listWorkflowRuns",
|
|
2081
|
+
imports: [chunkTJXDMXEE_cjs.apiPluginRef],
|
|
2082
|
+
type: "list",
|
|
2083
|
+
itemType: "WorkflowRun",
|
|
2084
|
+
inputSchema: ListWorkflowRunsOptionsSchema,
|
|
2085
|
+
outputSchema: WorkflowRunListItemSchema,
|
|
2086
|
+
skipOutputValidation: true,
|
|
2087
|
+
// The handler already returns a clean `{ data, nextCursor }` page, so the
|
|
2088
|
+
// standard list output (no `adaptPage`) applies.
|
|
2089
|
+
output: { type: "list", defaultPageSize: chunkTJXDMXEE_cjs.DEFAULT_PAGE_SIZE },
|
|
2090
|
+
resolvers: { workflow: chunkTJXDMXEE_cjs.workflowIdResolver },
|
|
2091
|
+
run: async ({ imports, input }) => {
|
|
2092
|
+
const api = imports.api;
|
|
2093
|
+
const searchParams = {};
|
|
2094
|
+
if (input.pageSize !== void 0) {
|
|
2095
|
+
searchParams.limit = input.pageSize.toString();
|
|
2096
|
+
}
|
|
2097
|
+
if (input.kind !== void 0) {
|
|
2098
|
+
searchParams.kind = input.kind;
|
|
2099
|
+
}
|
|
2100
|
+
if (input.cursor) {
|
|
2101
|
+
searchParams.cursor = input.cursor;
|
|
2102
|
+
}
|
|
2103
|
+
const raw = await api.get(
|
|
2104
|
+
`${CODE_SUBSTRATE_WORKFLOWS_API}/workflows/${encodeURIComponent(input.workflow)}/runs`,
|
|
2105
|
+
{
|
|
2106
|
+
searchParams,
|
|
2107
|
+
authRequired: true,
|
|
2108
|
+
resource: { type: "workflow", id: input.workflow }
|
|
2109
|
+
}
|
|
2110
|
+
);
|
|
2111
|
+
const response = ListWorkflowRunsApiResponseSchema.parse(raw);
|
|
2112
|
+
return {
|
|
2113
|
+
data: response.results,
|
|
2114
|
+
nextCursor: response.meta.next_cursor ?? void 0
|
|
2115
|
+
};
|
|
2116
|
+
}
|
|
2117
|
+
});
|
|
2118
|
+
var GetTriggerRunOptionsSchema = zod.z.object({
|
|
2119
|
+
trigger: zod.z.string().uuid().describe("Workflow trigger ID"),
|
|
2120
|
+
waitSeconds: RunWaitSecondsSchema
|
|
2121
|
+
}).describe(
|
|
2122
|
+
"Get the workflow run associated with a deployed workflow's trigger. Useful immediately after firing a trigger, when you have the trigger ID but not yet the run ID. With `waitSeconds`, the read also waits for the run to be created and to end."
|
|
2123
|
+
);
|
|
2124
|
+
var GetTriggerRunResponseSchema = zod.z.object({
|
|
2125
|
+
id: zod.z.string().describe("Workflow run ID (UUID)"),
|
|
2126
|
+
durable_run_id: zod.z.string().nullable().describe(
|
|
2127
|
+
"Linked code-substrate-runner run ID. Null until the durable run is created."
|
|
2128
|
+
),
|
|
2129
|
+
workflow_version_id: zod.z.string().nullable().describe("Workflow version the run is bound to"),
|
|
2130
|
+
status: WorkflowRunStatusSchema,
|
|
2131
|
+
input: zod.z.unknown().describe("Input passed to the run"),
|
|
2132
|
+
output: zod.z.unknown().nullable().describe("Return value, present when status is `finished`"),
|
|
2133
|
+
error: zod.z.unknown().nullable().describe("Error payload when status is `failed` (null otherwise)"),
|
|
2134
|
+
created_at: zod.z.string().describe("When the run was created (ISO-8601)"),
|
|
2135
|
+
updated_at: zod.z.string().describe("When the run was last updated (ISO-8601)")
|
|
2136
|
+
});
|
|
2137
|
+
|
|
2138
|
+
// src/plugins/codeSubstrate/getTriggerRun/index.ts
|
|
2139
|
+
var getTriggerRunPlugin = kitcore.defineMethod({
|
|
2140
|
+
...codeSubstrateDefaults,
|
|
2141
|
+
name: "getTriggerRun",
|
|
2142
|
+
imports: [chunkTJXDMXEE_cjs.apiPluginRef],
|
|
2143
|
+
itemType: "WorkflowRun",
|
|
2144
|
+
inputSchema: GetTriggerRunOptionsSchema,
|
|
2145
|
+
outputSchema: GetTriggerRunResponseSchema,
|
|
2146
|
+
skipOutputValidation: true,
|
|
2147
|
+
output: "item",
|
|
2148
|
+
// No resolver for `trigger` — users typically have the trigger id
|
|
2149
|
+
// from a recent trigger fire and pass it directly. Authoring a
|
|
2150
|
+
// picker would require listing triggers across all workflows,
|
|
2151
|
+
// which has no clean entry point today.
|
|
2152
|
+
run: async ({ imports, input }) => {
|
|
2153
|
+
const api = imports.api;
|
|
2154
|
+
const read = async (holdSeconds) => GetTriggerRunResponseSchema.parse(
|
|
2155
|
+
await api.get(
|
|
2156
|
+
`${CODE_SUBSTRATE_WORKFLOWS_API}/workflows/triggers/${encodeURIComponent(input.trigger)}/run`,
|
|
2157
|
+
{
|
|
2158
|
+
authRequired: true,
|
|
2159
|
+
resource: { type: "workflow-trigger", id: input.trigger },
|
|
2160
|
+
searchParams: runWaitSearchParams(holdSeconds)
|
|
2161
|
+
}
|
|
2162
|
+
)
|
|
2163
|
+
);
|
|
2164
|
+
return {
|
|
2165
|
+
data: await readRunUntilEnded({
|
|
2166
|
+
waitSeconds: input.waitSeconds ?? 0,
|
|
2167
|
+
read,
|
|
2168
|
+
pendingWhileNotFound: true
|
|
2169
|
+
})
|
|
2170
|
+
};
|
|
2171
|
+
}
|
|
2172
|
+
});
|
|
2173
|
+
var TriggerWorkflowLookupResponseSchema = zod.z.object({
|
|
2174
|
+
trigger_url: zod.z.string()
|
|
2175
|
+
}).passthrough();
|
|
2176
|
+
var TriggerWorkflowOptionsSchema = zod.z.object({
|
|
2177
|
+
workflow: zod.z.string().uuid().describe("Durable workflow ID"),
|
|
2178
|
+
input: JsonPayloadSchema.optional().describe(
|
|
2179
|
+
"JSON payload delivered as the trigger body. Accepts any JSON value, or its JSON-string encoding. Sent as `application/json`; omit to fire with an empty body."
|
|
2180
|
+
)
|
|
2181
|
+
}).describe(
|
|
2182
|
+
"Look up a workflow's trigger URL and fire it manually, as the authenticated account."
|
|
2183
|
+
);
|
|
2184
|
+
var TriggerWorkflowResponseSchema = zod.z.object({
|
|
2185
|
+
id: zod.z.string().describe("Trigger ID (UUID)"),
|
|
2186
|
+
workflow_id: zod.z.string().describe("The workflow that was triggered (UUID)"),
|
|
2187
|
+
created_at: zod.z.string().describe("When the trigger was received (ISO-8601)")
|
|
2188
|
+
});
|
|
2189
|
+
|
|
2190
|
+
// src/plugins/codeSubstrate/triggerWorkflow/index.ts
|
|
2191
|
+
var triggerWorkflowPlugin = kitcore.defineMethod({
|
|
2192
|
+
...codeSubstrateDefaults,
|
|
2193
|
+
name: "triggerWorkflow",
|
|
2194
|
+
imports: [chunkTJXDMXEE_cjs.apiPluginRef],
|
|
2195
|
+
type: "create",
|
|
2196
|
+
itemType: "WorkflowRun",
|
|
2197
|
+
inputSchema: TriggerWorkflowOptionsSchema,
|
|
2198
|
+
outputSchema: TriggerWorkflowResponseSchema,
|
|
2199
|
+
skipOutputValidation: true,
|
|
2200
|
+
output: "item",
|
|
2201
|
+
resolvers: { workflow: chunkTJXDMXEE_cjs.workflowIdResolver },
|
|
2202
|
+
run: async ({ imports, input }) => {
|
|
2203
|
+
const api = imports.api;
|
|
2204
|
+
const rawWorkflow = await api.get(
|
|
2205
|
+
`${CODE_SUBSTRATE_WORKFLOWS_API}/workflows/${encodeURIComponent(input.workflow)}`,
|
|
2206
|
+
{
|
|
2207
|
+
authRequired: true,
|
|
2208
|
+
resource: { type: "workflow", id: input.workflow }
|
|
2209
|
+
}
|
|
2210
|
+
);
|
|
2211
|
+
const workflow = TriggerWorkflowLookupResponseSchema.parse(rawWorkflow);
|
|
2212
|
+
const segments = new URL(workflow.trigger_url).pathname.split("/");
|
|
2213
|
+
const triggerToken = segments[segments.length - 1];
|
|
2214
|
+
if (!triggerToken) {
|
|
2215
|
+
throw new chunkTJXDMXEE_cjs.ZapierApiError(
|
|
2216
|
+
`Workflow ${input.workflow} returned a malformed trigger_url`,
|
|
2217
|
+
{ statusCode: 0, response: workflow.trigger_url }
|
|
2218
|
+
);
|
|
2219
|
+
}
|
|
2220
|
+
const raw = await api.post(
|
|
2221
|
+
`${CODE_SUBSTRATE_WORKFLOWS_API}/workflows/trigger/${encodeURIComponent(triggerToken)}`,
|
|
2222
|
+
input.input,
|
|
2223
|
+
{
|
|
2224
|
+
authRequired: true,
|
|
2225
|
+
resource: { type: "workflow", id: input.workflow }
|
|
2226
|
+
}
|
|
2227
|
+
);
|
|
2228
|
+
return { data: TriggerWorkflowResponseSchema.parse(raw) };
|
|
2229
|
+
}
|
|
2230
|
+
});
|
|
2231
|
+
var DEFAULT_RUN_WORKFLOW_WAIT_SECONDS = 60;
|
|
2232
|
+
var RunWorkflowOptionsSchema = zod.z.object({
|
|
2233
|
+
workflow: zod.z.string().uuid().describe("Durable workflow ID"),
|
|
2234
|
+
input: JsonPayloadSchema.optional().describe(
|
|
2235
|
+
"JSON payload delivered as the trigger body. Accepts any JSON value, or its JSON-string encoding. Omit to run with an empty body."
|
|
2236
|
+
),
|
|
2237
|
+
waitSeconds: zod.z.number().int().positive().optional().describe(
|
|
2238
|
+
"How long to wait for the run to end, in seconds. A run still going after the wait is returned with its current status, not as an error."
|
|
2239
|
+
)
|
|
2240
|
+
}).describe(
|
|
2241
|
+
`Run a published workflow and wait for its result: fires the workflow's trigger as the authenticated account, then returns the run once it is finished, failed or cancelled, with \`output\` set when it finished. Waits up to ${DEFAULT_RUN_WORKFLOW_WAIT_SECONDS} seconds unless \`waitSeconds\` says otherwise. A run that has not ended after \`waitSeconds\` is returned with its current status; wait on it again with getWorkflowRun and \`waitSeconds\`.`
|
|
2242
|
+
);
|
|
2243
|
+
var RunWorkflowResponseSchema = GetTriggerRunResponseSchema.extend({
|
|
2244
|
+
trigger_id: zod.z.string().describe("Trigger ID of the run (UUID)")
|
|
2245
|
+
});
|
|
2246
|
+
|
|
2247
|
+
// src/plugins/codeSubstrate/runWorkflow/index.ts
|
|
2248
|
+
var runWorkflowPlugin = kitcore.defineMethod({
|
|
2249
|
+
...codeSubstrateDefaults,
|
|
2250
|
+
name: "runWorkflow",
|
|
2251
|
+
imports: [triggerWorkflowPlugin, getTriggerRunPlugin],
|
|
2252
|
+
type: "create",
|
|
2253
|
+
itemType: "WorkflowRun",
|
|
2254
|
+
inputSchema: RunWorkflowOptionsSchema,
|
|
2255
|
+
outputSchema: RunWorkflowResponseSchema,
|
|
2256
|
+
skipOutputValidation: true,
|
|
2257
|
+
output: "item",
|
|
2258
|
+
resolvers: { workflow: chunkTJXDMXEE_cjs.workflowIdResolver },
|
|
2259
|
+
run: async ({ imports, input }) => {
|
|
2260
|
+
const { data: trigger } = await imports.triggerWorkflow({
|
|
2261
|
+
workflow: input.workflow,
|
|
2262
|
+
input: input.input
|
|
2263
|
+
});
|
|
2264
|
+
const waitSeconds = input.waitSeconds ?? DEFAULT_RUN_WORKFLOW_WAIT_SECONDS;
|
|
2265
|
+
try {
|
|
2266
|
+
const { data: run } = await imports.getTriggerRun({
|
|
2267
|
+
trigger: trigger.id,
|
|
2268
|
+
waitSeconds
|
|
2269
|
+
});
|
|
2270
|
+
return { data: { ...run, trigger_id: trigger.id } };
|
|
2271
|
+
} catch (error) {
|
|
2272
|
+
if (!chunkTJXDMXEE_cjs.isZapierNotFoundError(error)) throw error;
|
|
2273
|
+
throw new chunkTJXDMXEE_cjs.ZapierTimeoutError(
|
|
2274
|
+
`The run for trigger ${trigger.id} had not started after ${waitSeconds}s. Check it later with getTriggerRun.`,
|
|
2275
|
+
{ cause: error }
|
|
2276
|
+
);
|
|
2277
|
+
}
|
|
2278
|
+
}
|
|
2279
|
+
});
|
|
2280
|
+
var MAX_SOURCE_FILES_COUNT = 50;
|
|
2281
|
+
var MAX_SOURCE_FILE_LENGTH = 2e5;
|
|
2282
|
+
var DEFAULT_ENTRYPOINT_FILE = "/workflow.ts";
|
|
2283
|
+
var EXAMPLE_SOURCE_FILES = {
|
|
2284
|
+
[DEFAULT_ENTRYPOINT_FILE]: 'import { defineDurable } from "@zapier/zapier-durable"; export default defineDurable("hello-world", async (ctx, input) => { return ctx.step("greet", async () => "Hello, world!"); });'
|
|
2285
|
+
};
|
|
2286
|
+
var WorkflowValidationSourceFilesSchema = zod.z.record(
|
|
2287
|
+
zod.z.string().regex(/^\//, "source file paths must start with /"),
|
|
2288
|
+
zod.z.string().max(MAX_SOURCE_FILE_LENGTH)
|
|
2289
|
+
).refine((files) => Object.keys(files).length > 0, {
|
|
2290
|
+
message: "sourceFiles must contain at least one file"
|
|
2291
|
+
}).refine((files) => Object.keys(files).length <= MAX_SOURCE_FILES_COUNT, {
|
|
2292
|
+
message: `sourceFiles must contain at most ${MAX_SOURCE_FILES_COUNT} files`
|
|
2293
|
+
}).describe("Exact TypeScript sources keyed by absolute logical path.").meta({ example: EXAMPLE_SOURCE_FILES });
|
|
2294
|
+
var ValidateWorkflowOptionsSchema = zod.z.object({
|
|
2295
|
+
sourceFiles: WorkflowValidationSourceFilesSchema,
|
|
2296
|
+
entrypointFile: zod.z.string().regex(/^\//, "entrypointFile must start with /").optional().describe(
|
|
2297
|
+
"Absolute logical path of the entry file in sourceFiles. Defaults to /workflow.ts."
|
|
2298
|
+
)
|
|
2299
|
+
}).refine(
|
|
2300
|
+
({ sourceFiles, entrypointFile }) => (entrypointFile ?? DEFAULT_ENTRYPOINT_FILE) in sourceFiles,
|
|
2301
|
+
{
|
|
2302
|
+
path: ["entrypointFile"],
|
|
2303
|
+
message: "entrypointFile must identify a file in sourceFiles"
|
|
2304
|
+
}
|
|
2305
|
+
).describe(
|
|
2306
|
+
"Validate durable workflow source without publishing it. Returns source diagnostics; issue kinds are extensible and may be unfamiliar to the client."
|
|
2307
|
+
);
|
|
2308
|
+
var WorkflowValidationSourceLocationSchema = zod.z.object({
|
|
2309
|
+
file_id: zod.z.string().describe("Source file containing the diagnostic."),
|
|
2310
|
+
start_line: zod.z.number().int().positive().describe("Inclusive 1-based start line."),
|
|
2311
|
+
start_column: zod.z.number().int().positive().describe("Inclusive 1-based start column."),
|
|
2312
|
+
end_line: zod.z.number().int().positive().describe("Inclusive 1-based end line."),
|
|
2313
|
+
end_column: zod.z.number().int().positive().describe("Inclusive 1-based end column.")
|
|
2314
|
+
}).describe("1-based source coordinates within a single sourceFiles entry.");
|
|
2315
|
+
var WorkflowValidationIssueSchema = zod.z.object({
|
|
2316
|
+
kind: zod.z.string().describe(
|
|
2317
|
+
"Extensible diagnostic category; clients must accept unfamiliar values."
|
|
2318
|
+
),
|
|
2319
|
+
message: zod.z.string().describe("Safe human-readable explanation."),
|
|
2320
|
+
// Unlike `kind`, severity is a closed vocabulary on the analyzer side: a
|
|
2321
|
+
// new value requires a new API version, and every issue carries one, so
|
|
2322
|
+
// callers can rank findings without a missing-severity branch.
|
|
2323
|
+
severity: zod.z.enum(["error", "warning", "info", "hint"]).describe("Diagnostic severity."),
|
|
2324
|
+
suggestion: zod.z.string().optional().describe("Actionable fix hint."),
|
|
2325
|
+
source: WorkflowValidationSourceLocationSchema.optional().describe(
|
|
2326
|
+
"Affected source location."
|
|
2327
|
+
),
|
|
2328
|
+
source_excerpt: zod.z.string().optional().describe(
|
|
2329
|
+
"Source text the diagnostic was raised against, truncated to 240 characters."
|
|
2330
|
+
),
|
|
2331
|
+
syntax_kind: zod.z.string().optional().describe(
|
|
2332
|
+
"TypeScript AST node kind the diagnostic was raised against (e.g. `CallExpression`)."
|
|
2333
|
+
)
|
|
2334
|
+
});
|
|
2335
|
+
var ValidateWorkflowResponseSchema = zod.z.object({
|
|
2336
|
+
issues: zod.z.array(WorkflowValidationIssueSchema).describe("Source diagnostics, or an empty array when validation passes.")
|
|
2337
|
+
});
|
|
2338
|
+
|
|
2339
|
+
// src/plugins/codeSubstrate/validateWorkflow/index.ts
|
|
2340
|
+
var validateWorkflowPlugin = kitcore.defineMethod({
|
|
2341
|
+
...codeSubstrateDefaults,
|
|
2342
|
+
name: "validateWorkflow",
|
|
2343
|
+
imports: [chunkTJXDMXEE_cjs.apiPluginRef],
|
|
2344
|
+
itemType: "WorkflowValidation",
|
|
2345
|
+
inputSchema: ValidateWorkflowOptionsSchema,
|
|
2346
|
+
outputSchema: ValidateWorkflowResponseSchema,
|
|
2347
|
+
skipOutputValidation: true,
|
|
2348
|
+
output: "item",
|
|
2349
|
+
resolvers: { sourceFiles: sourceFilesResolver },
|
|
2350
|
+
run: async ({ imports, input }) => {
|
|
2351
|
+
const body = {
|
|
2352
|
+
source_files: input.sourceFiles
|
|
2353
|
+
};
|
|
2354
|
+
if (input.entrypointFile !== void 0) {
|
|
2355
|
+
body.entrypoint_file = input.entrypointFile;
|
|
2356
|
+
}
|
|
2357
|
+
const raw = await imports.api.post(
|
|
2358
|
+
`${CODE_SUBSTRATE_ANALYZER_API}/validations`,
|
|
2359
|
+
body,
|
|
2360
|
+
{ authRequired: true }
|
|
2361
|
+
);
|
|
2362
|
+
return { data: ValidateWorkflowResponseSchema.parse(raw) };
|
|
2363
|
+
}
|
|
2364
|
+
});
|
|
2365
|
+
|
|
2366
|
+
// src/beta.ts
|
|
2367
|
+
var zapierBetaSdkPlugin = kitcore.definePlugin({
|
|
2368
|
+
namespace: "zapier",
|
|
2369
|
+
name: "beta-sdk",
|
|
2370
|
+
exports: [
|
|
2371
|
+
chunkTJXDMXEE_cjs.zapierSdkPlugin,
|
|
2372
|
+
// Next Gen Zaps (workflows, drafts, runs). `list*` plugins are exported
|
|
2373
|
+
// before their `get*` / mutation siblings because per-row resolvers
|
|
2374
|
+
// reach the listing methods.
|
|
2375
|
+
listWorkflowsPlugin,
|
|
2376
|
+
getWorkflowPlugin,
|
|
2377
|
+
createWorkflowPlugin,
|
|
2378
|
+
importWorkflowPlugin,
|
|
2379
|
+
updateWorkflowPlugin,
|
|
2380
|
+
enableWorkflowPlugin,
|
|
2381
|
+
disableWorkflowPlugin,
|
|
2382
|
+
deleteWorkflowPlugin,
|
|
2383
|
+
listDurableRunsPlugin,
|
|
2384
|
+
getDurableRunPlugin,
|
|
2385
|
+
runDurablePlugin,
|
|
2386
|
+
cancelDurableRunPlugin,
|
|
2387
|
+
publishWorkflowVersionPlugin,
|
|
2388
|
+
listWorkflowVersionsPlugin,
|
|
2389
|
+
getWorkflowVersionPlugin,
|
|
2390
|
+
listWorkflowDraftsPlugin,
|
|
2391
|
+
getWorkflowDraftPlugin,
|
|
2392
|
+
createWorkflowDraftPlugin,
|
|
2393
|
+
updateWorkflowDraftPlugin,
|
|
2394
|
+
discardWorkflowDraftPlugin,
|
|
2395
|
+
publishWorkflowDraftPlugin,
|
|
2396
|
+
runWorkflowDraftPlugin,
|
|
2397
|
+
listWorkflowRunsPlugin,
|
|
2398
|
+
getWorkflowRunPlugin,
|
|
2399
|
+
getTriggerRunPlugin,
|
|
2400
|
+
triggerWorkflowPlugin,
|
|
2401
|
+
runWorkflowPlugin,
|
|
2402
|
+
validateWorkflowPlugin
|
|
2403
|
+
]
|
|
2404
|
+
});
|
|
2405
|
+
function createZapierSdk(options = {}) {
|
|
2406
|
+
return kitcore.createSdk(zapierBetaSdkPlugin, {
|
|
2407
|
+
configuration: {
|
|
2408
|
+
[chunkTJXDMXEE_cjs.SDK_OPTIONS_ID]: options,
|
|
2409
|
+
[kitcore.CORE_OPTIONS_ID]: chunkTJXDMXEE_cjs.zapierCoreOptions
|
|
2410
|
+
}
|
|
2411
|
+
});
|
|
2412
|
+
}
|
|
2413
|
+
|
|
2414
|
+
exports.CreateWorkflowOptionsSchema = CreateWorkflowOptionsSchema;
|
|
2415
|
+
exports.CreateWorkflowResponseSchema = CreateWorkflowResponseSchema;
|
|
2416
|
+
exports.ImportWorkflowOptionsSchema = ImportWorkflowOptionsSchema;
|
|
2417
|
+
exports.ImportWorkflowResponseSchema = ImportWorkflowResponseSchema;
|
|
2418
|
+
exports.createZapierSdk = createZapierSdk;
|
|
2419
|
+
exports.zapierBetaSdkPlugin = zapierBetaSdkPlugin;
|