@zapier/zapier-sdk 0.48.1 → 0.50.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 +21 -0
- package/README.md +832 -81
- package/dist/api/client.d.ts.map +1 -1
- package/dist/api/client.js +27 -16
- package/dist/api/polling.d.ts +7 -0
- package/dist/api/polling.d.ts.map +1 -1
- package/dist/api/polling.js +29 -4
- package/dist/api/types.d.ts +15 -7
- package/dist/api/types.d.ts.map +1 -1
- package/dist/constants.d.ts +8 -9
- package/dist/constants.d.ts.map +1 -1
- package/dist/constants.js +8 -11
- package/dist/experimental.cjs +10383 -0
- package/dist/experimental.d.mts +2292 -0
- package/dist/experimental.d.ts +2308 -0
- package/dist/experimental.d.ts.map +1 -0
- package/dist/experimental.js +155 -0
- package/dist/experimental.mjs +10202 -0
- package/dist/index-BQ2ii0Bs.d.mts +9538 -0
- package/dist/index-BQ2ii0Bs.d.ts +9538 -0
- package/dist/index.cjs +718 -513
- package/dist/index.d.mts +6 -8562
- package/dist/index.d.ts +7 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +5 -1
- package/dist/index.mjs +706 -512
- package/dist/plugins/api/index.d.ts.map +1 -1
- package/dist/plugins/api/index.js +1 -2
- package/dist/plugins/apps/index.d.ts +1 -1
- package/dist/plugins/deprecated/inputFields.d.ts +468 -0
- package/dist/plugins/deprecated/inputFields.d.ts.map +1 -0
- package/dist/plugins/deprecated/inputFields.js +73 -0
- package/dist/plugins/fetch/index.d.ts +1 -1
- package/dist/plugins/fetch/schemas.d.ts +1 -1
- package/dist/plugins/{getInputFieldsSchema → getActionInputFieldsSchema}/index.d.ts +4 -4
- package/dist/plugins/getActionInputFieldsSchema/index.d.ts.map +1 -0
- package/dist/plugins/{getInputFieldsSchema → getActionInputFieldsSchema}/index.js +4 -4
- package/dist/plugins/{getInputFieldsSchema → getActionInputFieldsSchema}/schemas.d.ts +8 -8
- package/dist/plugins/getActionInputFieldsSchema/schemas.d.ts.map +1 -0
- package/dist/plugins/{getInputFieldsSchema → getActionInputFieldsSchema}/schemas.js +13 -10
- package/dist/plugins/{listInputFieldChoices → listActionInputFieldChoices}/index.d.ts +4 -4
- package/dist/plugins/listActionInputFieldChoices/index.d.ts.map +1 -0
- package/dist/plugins/{listInputFieldChoices → listActionInputFieldChoices}/index.js +4 -4
- package/dist/plugins/{listInputFieldChoices → listActionInputFieldChoices}/schemas.d.ts +10 -10
- package/dist/plugins/listActionInputFieldChoices/schemas.d.ts.map +1 -0
- package/dist/plugins/{listInputFieldChoices → listActionInputFieldChoices}/schemas.js +13 -10
- package/dist/plugins/{listInputFields → listActionInputFields}/index.d.ts +4 -4
- package/dist/plugins/listActionInputFields/index.d.ts.map +1 -0
- package/dist/plugins/{listInputFields → listActionInputFields}/index.js +4 -4
- package/dist/plugins/{listInputFields → listActionInputFields}/schemas.d.ts +9 -9
- package/dist/plugins/listActionInputFields/schemas.d.ts.map +1 -0
- package/dist/plugins/{listInputFields → listActionInputFields}/schemas.js +7 -7
- package/dist/plugins/request/index.d.ts +2 -2
- package/dist/plugins/request/schemas.d.ts +2 -2
- package/dist/plugins/triggers/ackTriggerInboxMessages/index.d.ts +51 -0
- package/dist/plugins/triggers/ackTriggerInboxMessages/index.d.ts.map +1 -0
- package/dist/plugins/triggers/ackTriggerInboxMessages/index.js +35 -0
- package/dist/plugins/triggers/ackTriggerInboxMessages/schemas.d.ts +34 -0
- package/dist/plugins/triggers/ackTriggerInboxMessages/schemas.d.ts.map +1 -0
- package/dist/plugins/triggers/ackTriggerInboxMessages/schemas.js +17 -0
- package/dist/plugins/triggers/createTriggerInbox/index.d.ts +62 -0
- package/dist/plugins/triggers/createTriggerInbox/index.d.ts.map +1 -0
- package/dist/plugins/triggers/createTriggerInbox/index.js +54 -0
- package/dist/plugins/triggers/createTriggerInbox/schemas.d.ts +20 -0
- package/dist/plugins/triggers/createTriggerInbox/schemas.d.ts.map +1 -0
- package/dist/plugins/triggers/createTriggerInbox/schemas.js +20 -0
- package/dist/plugins/triggers/deleteTriggerInbox/index.d.ts +50 -0
- package/dist/plugins/triggers/deleteTriggerInbox/index.d.ts.map +1 -0
- package/dist/plugins/triggers/deleteTriggerInbox/index.js +27 -0
- package/dist/plugins/triggers/deleteTriggerInbox/schemas.d.ts +14 -0
- package/dist/plugins/triggers/deleteTriggerInbox/schemas.d.ts.map +1 -0
- package/dist/plugins/triggers/deleteTriggerInbox/schemas.js +9 -0
- package/dist/plugins/triggers/drainTriggerInbox/index.d.ts +213 -0
- package/dist/plugins/triggers/drainTriggerInbox/index.d.ts.map +1 -0
- package/dist/plugins/triggers/drainTriggerInbox/index.js +227 -0
- package/dist/plugins/triggers/drainTriggerInbox/pipeline.d.ts +56 -0
- package/dist/plugins/triggers/drainTriggerInbox/pipeline.d.ts.map +1 -0
- package/dist/plugins/triggers/drainTriggerInbox/pipeline.js +225 -0
- package/dist/plugins/triggers/drainTriggerInbox/schemas.d.ts +104 -0
- package/dist/plugins/triggers/drainTriggerInbox/schemas.d.ts.map +1 -0
- package/dist/plugins/triggers/drainTriggerInbox/schemas.js +102 -0
- package/dist/plugins/triggers/ensureTriggerInbox/index.d.ts +63 -0
- package/dist/plugins/triggers/ensureTriggerInbox/index.d.ts.map +1 -0
- package/dist/plugins/triggers/ensureTriggerInbox/index.js +77 -0
- package/dist/plugins/triggers/ensureTriggerInbox/schemas.d.ts +21 -0
- package/dist/plugins/triggers/ensureTriggerInbox/schemas.d.ts.map +1 -0
- package/dist/plugins/triggers/ensureTriggerInbox/schemas.js +21 -0
- package/dist/plugins/triggers/getTriggerInbox/index.d.ts +50 -0
- package/dist/plugins/triggers/getTriggerInbox/index.d.ts.map +1 -0
- package/dist/plugins/triggers/getTriggerInbox/index.js +26 -0
- package/dist/plugins/triggers/getTriggerInbox/schemas.d.ts +14 -0
- package/dist/plugins/triggers/getTriggerInbox/schemas.d.ts.map +1 -0
- package/dist/plugins/triggers/getTriggerInbox/schemas.js +9 -0
- package/dist/plugins/triggers/getTriggerInputFieldsSchema/index.d.ts +48 -0
- package/dist/plugins/triggers/getTriggerInputFieldsSchema/index.d.ts.map +1 -0
- package/dist/plugins/triggers/getTriggerInputFieldsSchema/index.js +23 -0
- package/dist/plugins/triggers/getTriggerInputFieldsSchema/schemas.d.ts +13 -0
- package/dist/plugins/triggers/getTriggerInputFieldsSchema/schemas.d.ts.map +1 -0
- package/dist/plugins/triggers/getTriggerInputFieldsSchema/schemas.js +10 -0
- package/dist/plugins/triggers/leaseTriggerInboxMessages/index.d.ts +58 -0
- package/dist/plugins/triggers/leaseTriggerInboxMessages/index.d.ts.map +1 -0
- package/dist/plugins/triggers/leaseTriggerInboxMessages/index.js +70 -0
- package/dist/plugins/triggers/leaseTriggerInboxMessages/schemas.d.ts +57 -0
- package/dist/plugins/triggers/leaseTriggerInboxMessages/schemas.d.ts.map +1 -0
- package/dist/plugins/triggers/leaseTriggerInboxMessages/schemas.js +25 -0
- package/dist/plugins/triggers/listTriggerInboxMessages/index.d.ts +51 -0
- package/dist/plugins/triggers/listTriggerInboxMessages/index.d.ts.map +1 -0
- package/dist/plugins/triggers/listTriggerInboxMessages/index.js +48 -0
- package/dist/plugins/triggers/listTriggerInboxMessages/schemas.d.ts +37 -0
- package/dist/plugins/triggers/listTriggerInboxMessages/schemas.d.ts.map +1 -0
- package/dist/plugins/triggers/listTriggerInboxMessages/schemas.js +27 -0
- package/dist/plugins/triggers/listTriggerInboxes/index.d.ts +56 -0
- package/dist/plugins/triggers/listTriggerInboxes/index.d.ts.map +1 -0
- package/dist/plugins/triggers/listTriggerInboxes/index.js +51 -0
- package/dist/plugins/triggers/listTriggerInboxes/schemas.d.ts +58 -0
- package/dist/plugins/triggers/listTriggerInboxes/schemas.d.ts.map +1 -0
- package/dist/plugins/triggers/listTriggerInboxes/schemas.js +35 -0
- package/dist/plugins/triggers/listTriggerInputFieldChoices/index.d.ts +77 -0
- package/dist/plugins/triggers/listTriggerInputFieldChoices/index.d.ts.map +1 -0
- package/dist/plugins/triggers/listTriggerInputFieldChoices/index.js +30 -0
- package/dist/plugins/triggers/listTriggerInputFieldChoices/schemas.d.ts +20 -0
- package/dist/plugins/triggers/listTriggerInputFieldChoices/schemas.d.ts.map +1 -0
- package/dist/plugins/triggers/listTriggerInputFieldChoices/schemas.js +28 -0
- package/dist/plugins/triggers/listTriggerInputFields/index.d.ts +101 -0
- package/dist/plugins/triggers/listTriggerInputFields/index.d.ts.map +1 -0
- package/dist/plugins/triggers/listTriggerInputFields/index.js +33 -0
- package/dist/plugins/triggers/listTriggerInputFields/schemas.d.ts +16 -0
- package/dist/plugins/triggers/listTriggerInputFields/schemas.d.ts.map +1 -0
- package/dist/plugins/triggers/listTriggerInputFields/schemas.js +21 -0
- package/dist/plugins/triggers/pauseTriggerInbox/index.d.ts +50 -0
- package/dist/plugins/triggers/pauseTriggerInbox/index.d.ts.map +1 -0
- package/dist/plugins/triggers/pauseTriggerInbox/index.js +26 -0
- package/dist/plugins/triggers/pauseTriggerInbox/schemas.d.ts +14 -0
- package/dist/plugins/triggers/pauseTriggerInbox/schemas.d.ts.map +1 -0
- package/dist/plugins/triggers/pauseTriggerInbox/schemas.js +9 -0
- package/dist/plugins/triggers/releaseTriggerInboxMessages/index.d.ts +51 -0
- package/dist/plugins/triggers/releaseTriggerInboxMessages/index.d.ts.map +1 -0
- package/dist/plugins/triggers/releaseTriggerInboxMessages/index.js +37 -0
- package/dist/plugins/triggers/releaseTriggerInboxMessages/schemas.d.ts +34 -0
- package/dist/plugins/triggers/releaseTriggerInboxMessages/schemas.d.ts.map +1 -0
- package/dist/plugins/triggers/releaseTriggerInboxMessages/schemas.js +17 -0
- package/dist/plugins/triggers/resumeTriggerInbox/index.d.ts +50 -0
- package/dist/plugins/triggers/resumeTriggerInbox/index.d.ts.map +1 -0
- package/dist/plugins/triggers/resumeTriggerInbox/index.js +26 -0
- package/dist/plugins/triggers/resumeTriggerInbox/schemas.d.ts +14 -0
- package/dist/plugins/triggers/resumeTriggerInbox/schemas.d.ts.map +1 -0
- package/dist/plugins/triggers/resumeTriggerInbox/schemas.js +9 -0
- package/dist/plugins/triggers/shared.d.ts +17 -0
- package/dist/plugins/triggers/shared.d.ts.map +1 -0
- package/dist/plugins/triggers/shared.js +16 -0
- package/dist/plugins/triggers/updateTriggerInbox/index.d.ts +51 -0
- package/dist/plugins/triggers/updateTriggerInbox/index.d.ts.map +1 -0
- package/dist/plugins/triggers/updateTriggerInbox/index.js +30 -0
- package/dist/plugins/triggers/updateTriggerInbox/schemas.d.ts +15 -0
- package/dist/plugins/triggers/updateTriggerInbox/schemas.d.ts.map +1 -0
- package/dist/plugins/triggers/updateTriggerInbox/schemas.js +15 -0
- package/dist/plugins/triggers/utils.d.ts +17 -0
- package/dist/plugins/triggers/utils.d.ts.map +1 -0
- package/dist/plugins/triggers/utils.js +28 -0
- package/dist/plugins/triggers/watchTriggerInbox/index.d.ts +163 -0
- package/dist/plugins/triggers/watchTriggerInbox/index.d.ts.map +1 -0
- package/dist/plugins/triggers/watchTriggerInbox/index.js +111 -0
- package/dist/registry.d.ts.map +1 -1
- package/dist/registry.js +2 -0
- package/dist/resolvers/actionKey.d.ts +1 -0
- package/dist/resolvers/actionKey.d.ts.map +1 -1
- package/dist/resolvers/actionKey.js +1 -1
- package/dist/resolvers/index.d.ts +2 -2
- package/dist/resolvers/index.d.ts.map +1 -1
- package/dist/resolvers/index.js +2 -2
- package/dist/resolvers/triggerInbox.d.ts +4 -0
- package/dist/resolvers/triggerInbox.d.ts.map +1 -0
- package/dist/resolvers/triggerInbox.js +18 -0
- package/dist/schemas/TriggerInbox.d.ts +59 -0
- package/dist/schemas/TriggerInbox.d.ts.map +1 -0
- package/dist/schemas/TriggerInbox.js +81 -0
- package/dist/schemas/TriggerMessage.d.ts +48 -0
- package/dist/schemas/TriggerMessage.d.ts.map +1 -0
- package/dist/schemas/TriggerMessage.js +79 -0
- package/dist/sdk.d.ts +621 -17
- package/dist/sdk.d.ts.map +1 -1
- package/dist/sdk.js +26 -9
- package/dist/types/errors.d.ts +18 -5
- package/dist/types/errors.d.ts.map +1 -1
- package/dist/types/errors.js +16 -0
- package/dist/types/plugin.d.ts +12 -1
- package/dist/types/plugin.d.ts.map +1 -1
- package/dist/types/properties.d.ts +12 -0
- package/dist/types/properties.d.ts.map +1 -1
- package/dist/types/properties.js +25 -0
- package/dist/types/registry.d.ts +5 -0
- package/dist/types/registry.d.ts.map +1 -1
- package/dist/types/sdk.d.ts +4 -4
- package/dist/types/sdk.d.ts.map +1 -1
- package/dist/types/sdk.js +4 -11
- package/dist/types/signals.d.ts +20 -0
- package/dist/types/signals.d.ts.map +1 -0
- package/dist/types/signals.js +21 -0
- package/dist/utils/abort-utils.d.ts +13 -0
- package/dist/utils/abort-utils.d.ts.map +1 -1
- package/dist/utils/abort-utils.js +15 -0
- package/dist/utils/retry-utils.d.ts +6 -2
- package/dist/utils/retry-utils.d.ts.map +1 -1
- package/dist/utils/retry-utils.js +22 -3
- package/dist/utils/schema-utils.d.ts +19 -1
- package/dist/utils/schema-utils.d.ts.map +1 -1
- package/package.json +12 -1
- package/dist/plugins/getInputFieldsSchema/index.d.ts.map +0 -1
- package/dist/plugins/getInputFieldsSchema/schemas.d.ts.map +0 -1
- package/dist/plugins/listInputFieldChoices/index.d.ts.map +0 -1
- package/dist/plugins/listInputFieldChoices/schemas.d.ts.map +0 -1
- package/dist/plugins/listInputFields/index.d.ts.map +0 -1
- package/dist/plugins/listInputFields/schemas.d.ts.map +0 -1
package/dist/index.cjs
CHANGED
|
@@ -63,12 +63,10 @@ function parseIntEnvVar(name) {
|
|
|
63
63
|
}
|
|
64
64
|
var ZAPIER_MAX_NETWORK_RETRIES = parseIntEnvVar("ZAPIER_MAX_NETWORK_RETRIES") ?? 3;
|
|
65
65
|
var ZAPIER_MAX_NETWORK_RETRY_DELAY_MS = parseIntEnvVar("ZAPIER_MAX_NETWORK_RETRY_DELAY_MS") ?? 6e4;
|
|
66
|
-
function getZapierIsInteractive() {
|
|
67
|
-
return globalThis.process?.env?.ZAPIER_IS_INTERACTIVE === "true";
|
|
68
|
-
}
|
|
69
66
|
function getZapierApprovalMode() {
|
|
70
67
|
const value = globalThis.process?.env?.ZAPIER_APPROVAL_MODE;
|
|
71
|
-
if (value === "
|
|
68
|
+
if (value === "disabled" || value === "poll" || value === "throw")
|
|
69
|
+
return value;
|
|
72
70
|
return void 0;
|
|
73
71
|
}
|
|
74
72
|
var DEFAULT_APPROVAL_TIMEOUT_MS = 10 * 60 * 1e3;
|
|
@@ -129,6 +127,19 @@ var FieldsPropertySchema = zod.z.array(zod.z.union([zod.z.string(), zod.z.number
|
|
|
129
127
|
var AppsPropertySchema = zod.z.array(zod.z.string()).describe("Filter by app keys (e.g., 'SlackCLIAPI' or slug like 'github')");
|
|
130
128
|
var TablesPropertySchema = zod.z.array(zod.z.string()).describe("Filter by specific table IDs");
|
|
131
129
|
var ConnectionsPropertySchema = zod.z.array(zod.z.string()).describe("List of connection IDs to filter by");
|
|
130
|
+
var TriggerInboxPropertySchema = withPositional(
|
|
131
|
+
zod.z.string().min(1).describe(
|
|
132
|
+
"Trigger inbox identifier \u2014 UUID or name. Non-UUID values are resolved by name via the inbox list endpoint."
|
|
133
|
+
)
|
|
134
|
+
);
|
|
135
|
+
var TriggerInboxNamePropertySchema = zod.z.string().min(1).max(100).describe(
|
|
136
|
+
"Inbox name; unique per (user, account). Enables get-or-create on createTriggerInbox."
|
|
137
|
+
);
|
|
138
|
+
var LeasePropertySchema = zod.z.string().min(1).describe("Lease ID returned from leaseTriggerInboxMessages");
|
|
139
|
+
var LeaseSecondsPropertySchema = zod.z.number().int().min(1).max(3600).describe(
|
|
140
|
+
"Seconds until the lease expires; messages return to available if not acked. API default is 300 (5 minutes)."
|
|
141
|
+
);
|
|
142
|
+
var LeaseLimitPropertySchema = zod.z.number().int().min(1).max(100).describe("Maximum messages to lease in a single batch (1-100)");
|
|
132
143
|
|
|
133
144
|
// src/types/errors.ts
|
|
134
145
|
var ZapierError = class extends Error {
|
|
@@ -232,6 +243,14 @@ var ZapierActionError = class extends ZapierError {
|
|
|
232
243
|
return this.errors;
|
|
233
244
|
}
|
|
234
245
|
};
|
|
246
|
+
var ZapierConflictError = class extends ZapierError {
|
|
247
|
+
constructor(message, options = {}) {
|
|
248
|
+
super(message, options);
|
|
249
|
+
this.name = "ZapierConflictError";
|
|
250
|
+
this.code = "ZAPIER_CONFLICT_ERROR";
|
|
251
|
+
this.resourceType = options.resourceType;
|
|
252
|
+
}
|
|
253
|
+
};
|
|
235
254
|
var ZapierRateLimitError = class extends ZapierError {
|
|
236
255
|
constructor(message, options = {}) {
|
|
237
256
|
super(message, options);
|
|
@@ -285,6 +304,10 @@ ${context.join(", ")}`;
|
|
|
285
304
|
if (error.resourceId) context.push(`ID: ${error.resourceId}`);
|
|
286
305
|
message += `
|
|
287
306
|
${context.join(", ")}`;
|
|
307
|
+
}
|
|
308
|
+
if (error instanceof ZapierConflictError && error.resourceType) {
|
|
309
|
+
message += `
|
|
310
|
+
Type: ${error.resourceType}`;
|
|
288
311
|
}
|
|
289
312
|
if (error instanceof ZapierTimeoutError && (error.attempts || error.maxAttempts)) {
|
|
290
313
|
const context = [];
|
|
@@ -336,6 +359,67 @@ function formatDuration(ms) {
|
|
|
336
359
|
const days = Math.round(hours / 24);
|
|
337
360
|
return `${days}d`;
|
|
338
361
|
}
|
|
362
|
+
|
|
363
|
+
// src/types/signals.ts
|
|
364
|
+
var ZapierSignal = class extends Error {
|
|
365
|
+
constructor(message) {
|
|
366
|
+
super(message);
|
|
367
|
+
Object.setPrototypeOf(this, new.target.prototype);
|
|
368
|
+
}
|
|
369
|
+
};
|
|
370
|
+
var ZapierReleaseTriggerMessageSignal = class extends ZapierSignal {
|
|
371
|
+
constructor() {
|
|
372
|
+
super(...arguments);
|
|
373
|
+
this.name = "ZapierReleaseTriggerMessageSignal";
|
|
374
|
+
this.code = "ZAPIER_RELEASE_TRIGGER_MESSAGE_SIGNAL";
|
|
375
|
+
}
|
|
376
|
+
};
|
|
377
|
+
var ZapierAbortDrainSignal = class extends ZapierSignal {
|
|
378
|
+
constructor() {
|
|
379
|
+
super(...arguments);
|
|
380
|
+
this.name = "ZapierAbortDrainSignal";
|
|
381
|
+
this.code = "ZAPIER_ABORT_DRAIN_SIGNAL";
|
|
382
|
+
}
|
|
383
|
+
};
|
|
384
|
+
var TriggerInboxCommandBaseSchema = zod.z.object({
|
|
385
|
+
inbox: TriggerInboxPropertySchema,
|
|
386
|
+
onMessage: zod.z.function().optional().meta({ exampleRequired: true }).describe(
|
|
387
|
+
"Per-message handler. Resolves to ack; rejects to release-or-leave per `releaseOnError`. Throw `ZapierReleaseTriggerMessageSignal` to release explicitly, or `ZapierAbortDrainSignal` to stop after the current batch."
|
|
388
|
+
),
|
|
389
|
+
concurrency: zod.z.number().int().min(1).optional().describe(
|
|
390
|
+
"Per-message handler workers running in parallel. Defaults to `leaseLimit`, or 1 if neither is set."
|
|
391
|
+
),
|
|
392
|
+
leaseLimit: zod.z.number().int().min(1).max(100).optional().describe(
|
|
393
|
+
"Per-lease HTTP batch size. Defaults to `concurrency`, or 1 if neither is set."
|
|
394
|
+
),
|
|
395
|
+
leaseSeconds: LeaseSecondsPropertySchema.optional(),
|
|
396
|
+
releaseOnError: zod.z.boolean().optional().describe(
|
|
397
|
+
"If true, errors immediately release the message. If false (default), errors leave it leased until the lease timeout. `ZapierReleaseTriggerMessageSignal` always releases regardless."
|
|
398
|
+
),
|
|
399
|
+
continueOnError: zod.z.boolean().optional().describe(
|
|
400
|
+
"If false (default, fail-fast), the first handler error rejects and stops the drain. If true, handler errors are observed via `onError` and the drain continues. SDK-level errors (lease / ack / release) reject regardless."
|
|
401
|
+
),
|
|
402
|
+
onError: zod.z.function().optional().describe(
|
|
403
|
+
"Per-message error observer for `continueOnError: true`. Called with the failure and the message; control-flow signals are filtered out. Throws from `onError` are swallowed."
|
|
404
|
+
),
|
|
405
|
+
signal: zod.z.custom((v) => v instanceof AbortSignal).optional().describe(
|
|
406
|
+
"Abort signal. Aborting cancels in-flight HTTP, releases unprocessed messages, and resolves cleanly. Errors during shutdown still reject."
|
|
407
|
+
)
|
|
408
|
+
});
|
|
409
|
+
TriggerInboxCommandBaseSchema.extend({
|
|
410
|
+
maxMessages: zod.z.number().int().min(1).optional().describe(
|
|
411
|
+
"Cap total messages drained. Defaults to draining the inbox until empty."
|
|
412
|
+
)
|
|
413
|
+
}).describe(
|
|
414
|
+
"Drain an existing trigger inbox: lease currently-available messages and process them via onMessage. Returns when the inbox is empty, maxMessages is reached, the abort signal fires, or a fatal error rejects."
|
|
415
|
+
);
|
|
416
|
+
TriggerInboxCommandBaseSchema.extend({
|
|
417
|
+
maxDrainIntervalSeconds: zod.z.number().int().min(1).optional().describe(
|
|
418
|
+
"Maximum seconds between empty-inbox poll attempts (default: 60). Caps the back-off cadence."
|
|
419
|
+
)
|
|
420
|
+
}).describe(
|
|
421
|
+
"Continuously consume a trigger inbox: drain currently-available messages, then poll with backoff for new arrivals, until aborted. Stop via the `signal` AbortSignal or by throwing `ZapierAbortDrainSignal` from a handler. Resolves cleanly on abort; rejects on a fatal error or a fail-fast handler error."
|
|
422
|
+
);
|
|
339
423
|
var ActionExecutionInputSchema = zod.z.object({
|
|
340
424
|
inputs: zod.z.record(zod.z.string(), zod.z.unknown()).optional(),
|
|
341
425
|
/** @deprecated Use `connection` instead. */
|
|
@@ -1424,6 +1508,9 @@ function getAbortSignalApi() {
|
|
|
1424
1508
|
const api = AbortSignal;
|
|
1425
1509
|
return { any: api.any };
|
|
1426
1510
|
}
|
|
1511
|
+
function isAbortError(err) {
|
|
1512
|
+
return err instanceof Error && err.name === "AbortError";
|
|
1513
|
+
}
|
|
1427
1514
|
function createTimeoutError(timeoutMs) {
|
|
1428
1515
|
if (typeof DOMException !== "undefined") {
|
|
1429
1516
|
return new DOMException(
|
|
@@ -2212,7 +2299,7 @@ var actionKeyResolver = {
|
|
|
2212
2299
|
app: resolvedParams.app
|
|
2213
2300
|
});
|
|
2214
2301
|
return actionsResponse.data.filter(
|
|
2215
|
-
(action) => action.action_type === resolvedParams.actionType
|
|
2302
|
+
(action) => action.action_type === resolvedParams.actionType && !action.is_hidden
|
|
2216
2303
|
);
|
|
2217
2304
|
},
|
|
2218
2305
|
prompt: (actions) => ({
|
|
@@ -2423,6 +2510,23 @@ var tableIdResolver = {
|
|
|
2423
2510
|
}))
|
|
2424
2511
|
})
|
|
2425
2512
|
};
|
|
2513
|
+
|
|
2514
|
+
// src/resolvers/triggerInbox.ts
|
|
2515
|
+
var triggerInboxResolver = {
|
|
2516
|
+
type: "dynamic",
|
|
2517
|
+
fetch: async (sdk) => toIterable(sdk.listTriggerInboxes()),
|
|
2518
|
+
prompt: (inboxes) => ({
|
|
2519
|
+
type: "list",
|
|
2520
|
+
name: "inbox",
|
|
2521
|
+
message: "Select a trigger inbox:",
|
|
2522
|
+
// `deleting` inboxes are on their way out — no operation against them
|
|
2523
|
+
// is useful (delete is a no-op, pause/resume/update are rejected).
|
|
2524
|
+
choices: inboxes.filter((inbox) => inbox.status !== "deleting").map((inbox) => ({
|
|
2525
|
+
name: `${inbox.name ?? inbox.id} (${inbox.subscription.app_key} / ${inbox.subscription.action_key}, ${inbox.status})`,
|
|
2526
|
+
value: inbox.id
|
|
2527
|
+
}))
|
|
2528
|
+
})
|
|
2529
|
+
};
|
|
2426
2530
|
function formatFieldValue(v) {
|
|
2427
2531
|
if (v == null) return "";
|
|
2428
2532
|
if (typeof v === "object") {
|
|
@@ -3097,7 +3201,7 @@ var listActionsPlugin = definePlugin(
|
|
|
3097
3201
|
})
|
|
3098
3202
|
);
|
|
3099
3203
|
var ListInputFieldsDescription = "Get the input fields required for a specific action";
|
|
3100
|
-
var
|
|
3204
|
+
var ListActionInputFieldsBaseSchema = zod.z.object({
|
|
3101
3205
|
connection: ConnectionPropertySchema.optional().describe(
|
|
3102
3206
|
"Connection alias or connection ID (UUID or positive integer). Strings that match a key in the connections map are resolved against it; otherwise the value is used as a connection ID directly. Mutually exclusive with connectionId."
|
|
3103
3207
|
),
|
|
@@ -3113,11 +3217,11 @@ var ListInputFieldsBaseSchema = zod.z.object({
|
|
|
3113
3217
|
maxItems: zod.z.number().min(1).optional().describe("Maximum total items to return across all pages"),
|
|
3114
3218
|
cursor: zod.z.string().optional().describe("Cursor to start from")
|
|
3115
3219
|
});
|
|
3116
|
-
var
|
|
3220
|
+
var ListActionInputFieldsSchema = zod.z.object({
|
|
3117
3221
|
app: AppPropertySchema,
|
|
3118
3222
|
actionType: ActionTypePropertySchema,
|
|
3119
3223
|
action: ActionPropertySchema
|
|
3120
|
-
}).merge(
|
|
3224
|
+
}).merge(ListActionInputFieldsBaseSchema).describe(ListInputFieldsDescription).meta({
|
|
3121
3225
|
aliases: {
|
|
3122
3226
|
appKey: "app",
|
|
3123
3227
|
actionKey: "action",
|
|
@@ -3125,12 +3229,12 @@ var ListInputFieldsSchema = zod.z.object({
|
|
|
3125
3229
|
authenticationId: "connection"
|
|
3126
3230
|
}
|
|
3127
3231
|
});
|
|
3128
|
-
var
|
|
3232
|
+
var ListActionInputFieldsSchemaDeprecated = zod.z.object({
|
|
3129
3233
|
appKey: AppKeyPropertySchema,
|
|
3130
3234
|
actionType: ActionTypePropertySchema,
|
|
3131
3235
|
actionKey: ActionKeyPropertySchema
|
|
3132
|
-
}).merge(
|
|
3133
|
-
var
|
|
3236
|
+
}).merge(ListActionInputFieldsBaseSchema);
|
|
3237
|
+
var ListActionInputFieldsInputSchema = zod.z.union([ListActionInputFieldsSchema, ListActionInputFieldsSchemaDeprecated]).describe(ListInputFieldsDescription);
|
|
3134
3238
|
var BaseFieldItemSchema = zod.z.object({
|
|
3135
3239
|
type: zod.z.string(),
|
|
3136
3240
|
// "input_field", "info_field", or "fieldset"
|
|
@@ -3307,7 +3411,7 @@ async function fetchImplementationChoices({
|
|
|
3307
3411
|
return response;
|
|
3308
3412
|
}
|
|
3309
3413
|
|
|
3310
|
-
// src/plugins/
|
|
3414
|
+
// src/plugins/listActionInputFields/index.ts
|
|
3311
3415
|
function getInputFieldTypeFromNeed(need) {
|
|
3312
3416
|
if (need.list) {
|
|
3313
3417
|
return "ARRAY" /* ARRAY */;
|
|
@@ -3406,13 +3510,13 @@ function transformNeedsToFields(needs) {
|
|
|
3406
3510
|
}
|
|
3407
3511
|
return rootFields;
|
|
3408
3512
|
}
|
|
3409
|
-
var
|
|
3513
|
+
var listActionInputFieldsPlugin = definePlugin(
|
|
3410
3514
|
(sdk) => createPaginatedPluginMethod(sdk, {
|
|
3411
|
-
name: "
|
|
3515
|
+
name: "listActionInputFields",
|
|
3412
3516
|
categories: ["action"],
|
|
3413
3517
|
type: "list",
|
|
3414
3518
|
itemType: "RootField",
|
|
3415
|
-
inputSchema:
|
|
3519
|
+
inputSchema: ListActionInputFieldsInputSchema,
|
|
3416
3520
|
outputSchema: RootFieldItemSchema,
|
|
3417
3521
|
defaultPageSize: DEFAULT_PAGE_SIZE,
|
|
3418
3522
|
resolvers: {
|
|
@@ -3473,146 +3577,441 @@ var listInputFieldsPlugin = definePlugin(
|
|
|
3473
3577
|
}
|
|
3474
3578
|
})
|
|
3475
3579
|
);
|
|
3476
|
-
var
|
|
3477
|
-
offset: true,
|
|
3478
|
-
// Omit snake_case fields, we'll add camelCase versions
|
|
3479
|
-
app_key: true,
|
|
3480
|
-
connection_ids: true,
|
|
3481
|
-
account_id: true,
|
|
3482
|
-
is_expired: true,
|
|
3483
|
-
page_size: true
|
|
3484
|
-
}).extend({
|
|
3485
|
-
// New name for appKey
|
|
3486
|
-
app: AppPropertySchema.optional().describe(
|
|
3487
|
-
"App key of connections to list (e.g., 'SlackCLIAPI' or slug like 'github')"
|
|
3488
|
-
),
|
|
3489
|
-
/** @deprecated Use `app` instead. */
|
|
3490
|
-
appKey: AppKeyPropertySchema.optional().describe(
|
|
3491
|
-
"App key of connections to list (e.g., 'SlackCLIAPI' or slug like 'github')"
|
|
3492
|
-
).meta({ deprecated: true }),
|
|
3493
|
-
// New name for connectionIds
|
|
3494
|
-
connections: ConnectionsPropertySchema.optional().describe(
|
|
3495
|
-
"List of connection IDs to filter by"
|
|
3496
|
-
),
|
|
3497
|
-
/** @deprecated Use `connections` instead. */
|
|
3498
|
-
connectionIds: zod.z.array(zod.z.string()).optional().describe("List of connection IDs to filter by").meta({ deprecated: true }),
|
|
3499
|
-
/** @deprecated Use `connections` instead. */
|
|
3500
|
-
authenticationIds: zod.z.array(zod.z.string()).optional().describe(
|
|
3501
|
-
"List of authentication IDs to filter by (deprecated, use connections)"
|
|
3502
|
-
).meta({ deprecated: true }),
|
|
3503
|
-
account: zod.z.string().optional().describe("Account to filter by"),
|
|
3504
|
-
/** @deprecated Use `account` instead. */
|
|
3505
|
-
accountId: zod.z.string().optional().describe("Account ID to filter by").meta({ deprecated: true }),
|
|
3506
|
-
// Include shared connections (overrides default owner=me filter)
|
|
3507
|
-
includeShared: zod.z.boolean().optional().describe(
|
|
3508
|
-
"Include connections shared with you. By default, only your own connections are returned (owner=me). Set to true to also include shared connections."
|
|
3509
|
-
),
|
|
3510
|
-
/** @deprecated Use `expired` instead */
|
|
3511
|
-
isExpired: zod.z.boolean().optional().describe("Filter by expired status").meta({
|
|
3512
|
-
deprecated: true,
|
|
3513
|
-
deprecationMessage: "Use --expired instead to show only expired connections."
|
|
3514
|
-
}),
|
|
3515
|
-
expired: zod.z.boolean().optional().describe(
|
|
3516
|
-
"Show only expired connections (default: only non-expired connections are returned)"
|
|
3517
|
-
),
|
|
3518
|
-
// Override pageSize to make optional
|
|
3519
|
-
pageSize: zod.z.number().min(1).optional().describe("Number of connections per page"),
|
|
3520
|
-
// SDK specific property for pagination/iterable helpers
|
|
3521
|
-
maxItems: zod.z.number().min(1).optional().describe("Maximum total items to return across all pages"),
|
|
3522
|
-
// SDK specific property for pagination/iterable helpers
|
|
3523
|
-
cursor: zod.z.string().optional().describe("Cursor to start from")
|
|
3524
|
-
}).describe("List available connections with optional filtering");
|
|
3525
|
-
var ConnectionItemSchema = withFormatter(connections.ConnectionItemSchema, {
|
|
3580
|
+
var InputFieldChoiceItemSchema = withFormatter(NeedChoicesSchema, {
|
|
3526
3581
|
format: (item) => {
|
|
3582
|
+
const title = item.label || item.key || "Choice";
|
|
3527
3583
|
const details = [];
|
|
3528
|
-
if (item.
|
|
3529
|
-
details.push({
|
|
3530
|
-
text: `Identifier: ${item.identifier}`,
|
|
3531
|
-
style: "accent"
|
|
3532
|
-
});
|
|
3584
|
+
if (item.label && item.key && item.label !== item.key) {
|
|
3585
|
+
details.push({ text: `Key: ${item.key}`, style: "dim" });
|
|
3533
3586
|
}
|
|
3534
|
-
|
|
3535
|
-
text: `
|
|
3536
|
-
|
|
3537
|
-
|
|
3538
|
-
|
|
3539
|
-
details.push({
|
|
3540
|
-
text: `Warning: Marked stale: ${new Date(item.marked_stale_at).toLocaleDateString()}`,
|
|
3541
|
-
style: "warning"
|
|
3542
|
-
});
|
|
3587
|
+
if (item.sample && item.sample !== item.key) {
|
|
3588
|
+
details.push({ text: `Sample: ${item.sample}`, style: "dim" });
|
|
3589
|
+
}
|
|
3590
|
+
if (item.value && item.value !== item.key) {
|
|
3591
|
+
details.push({ text: `Value: ${item.value}`, style: "normal" });
|
|
3543
3592
|
}
|
|
3544
3593
|
return {
|
|
3545
|
-
title
|
|
3546
|
-
|
|
3594
|
+
title,
|
|
3595
|
+
key: item.key,
|
|
3547
3596
|
details
|
|
3548
3597
|
};
|
|
3549
3598
|
}
|
|
3550
3599
|
});
|
|
3600
|
+
var ListActionInputFieldChoicesDescription = "Get the available choices for a dynamic dropdown input field";
|
|
3601
|
+
var ListActionInputFieldChoicesBaseSchema = zod.z.object({
|
|
3602
|
+
connection: ConnectionPropertySchema.optional().describe(
|
|
3603
|
+
"Connection alias or connection ID (UUID or positive integer). Strings that match a key in the connections map are resolved against it; otherwise the value is used as a connection ID directly. Mutually exclusive with connectionId."
|
|
3604
|
+
),
|
|
3605
|
+
connectionId: ConnectionIdPropertySchema.nullable().optional().describe(
|
|
3606
|
+
"Connection ID to use when listing available field choices. Required if the action needs a connection to populate dynamic dropdown options."
|
|
3607
|
+
).meta({ deprecated: true }),
|
|
3608
|
+
/** @deprecated Use connection instead */
|
|
3609
|
+
authenticationId: AuthenticationIdPropertySchema.nullable().optional().meta({ deprecated: true }),
|
|
3610
|
+
inputs: InputsPropertySchema.optional().describe(
|
|
3611
|
+
"Current input values that may affect available choices"
|
|
3612
|
+
),
|
|
3613
|
+
page: zod.z.number().int().min(0).optional().describe("Page number for paginated results"),
|
|
3614
|
+
pageSize: zod.z.number().min(1).optional().describe("Number of choices per page"),
|
|
3615
|
+
maxItems: zod.z.number().min(1).optional().describe("Maximum total items to return across all pages"),
|
|
3616
|
+
cursor: zod.z.string().optional().describe("Cursor to start from")
|
|
3617
|
+
});
|
|
3618
|
+
var ListActionInputFieldChoicesSchema = zod.z.object({
|
|
3619
|
+
app: AppPropertySchema,
|
|
3620
|
+
actionType: ActionTypePropertySchema,
|
|
3621
|
+
action: ActionPropertySchema,
|
|
3622
|
+
inputField: InputFieldPropertySchema
|
|
3623
|
+
}).merge(ListActionInputFieldChoicesBaseSchema).describe(ListActionInputFieldChoicesDescription).meta({
|
|
3624
|
+
aliases: {
|
|
3625
|
+
appKey: "app",
|
|
3626
|
+
actionKey: "action",
|
|
3627
|
+
inputFieldKey: "inputField",
|
|
3628
|
+
connectionId: "connection",
|
|
3629
|
+
authenticationId: "connection"
|
|
3630
|
+
}
|
|
3631
|
+
});
|
|
3632
|
+
var ListActionInputFieldChoicesSchemaDeprecated = zod.z.object({
|
|
3633
|
+
appKey: AppKeyPropertySchema,
|
|
3634
|
+
actionType: ActionTypePropertySchema,
|
|
3635
|
+
actionKey: ActionKeyPropertySchema,
|
|
3636
|
+
inputFieldKey: zod.z.string().min(1).describe("Input field key to get choices for.")
|
|
3637
|
+
}).merge(ListActionInputFieldChoicesBaseSchema);
|
|
3638
|
+
var ListActionInputFieldChoicesInputSchema = zod.z.union([
|
|
3639
|
+
ListActionInputFieldChoicesSchema,
|
|
3640
|
+
ListActionInputFieldChoicesSchemaDeprecated
|
|
3641
|
+
]).describe(ListActionInputFieldChoicesDescription);
|
|
3551
3642
|
|
|
3552
|
-
// src/plugins/
|
|
3553
|
-
|
|
3643
|
+
// src/plugins/listActionInputFieldChoices/index.ts
|
|
3644
|
+
function transformNeedChoicesToInputFieldChoiceItem(choice) {
|
|
3645
|
+
return {
|
|
3646
|
+
key: choice.key,
|
|
3647
|
+
label: choice.label,
|
|
3648
|
+
sample: choice.sample,
|
|
3649
|
+
value: choice.value
|
|
3650
|
+
};
|
|
3651
|
+
}
|
|
3652
|
+
var listActionInputFieldChoicesPlugin = definePlugin(
|
|
3554
3653
|
(sdk) => createPaginatedPluginMethod(sdk, {
|
|
3555
|
-
name: "
|
|
3556
|
-
categories: ["
|
|
3654
|
+
name: "listActionInputFieldChoices",
|
|
3655
|
+
categories: ["action"],
|
|
3557
3656
|
type: "list",
|
|
3558
|
-
itemType: "
|
|
3559
|
-
inputSchema:
|
|
3560
|
-
outputSchema:
|
|
3657
|
+
itemType: "InputFieldChoice",
|
|
3658
|
+
inputSchema: ListActionInputFieldChoicesInputSchema,
|
|
3659
|
+
outputSchema: InputFieldChoiceItemSchema,
|
|
3561
3660
|
defaultPageSize: DEFAULT_PAGE_SIZE,
|
|
3562
|
-
resolvers: {
|
|
3563
|
-
|
|
3564
|
-
|
|
3565
|
-
|
|
3566
|
-
|
|
3661
|
+
resolvers: {
|
|
3662
|
+
app: appKeyResolver,
|
|
3663
|
+
actionType: actionTypeResolver,
|
|
3664
|
+
action: actionKeyResolver,
|
|
3665
|
+
connection: connectionIdResolver,
|
|
3666
|
+
inputField: inputFieldKeyResolver,
|
|
3667
|
+
inputs: inputsAllOptionalResolver
|
|
3668
|
+
},
|
|
3669
|
+
handler: async ({
|
|
3670
|
+
sdk: sdk2,
|
|
3671
|
+
options
|
|
3672
|
+
}) => {
|
|
3567
3673
|
const { api, getVersionedImplementationId } = sdk2.context;
|
|
3568
|
-
const
|
|
3569
|
-
|
|
3570
|
-
|
|
3571
|
-
|
|
3572
|
-
|
|
3573
|
-
|
|
3574
|
-
|
|
3575
|
-
|
|
3576
|
-
|
|
3577
|
-
|
|
3578
|
-
|
|
3579
|
-
|
|
3580
|
-
|
|
3581
|
-
|
|
3582
|
-
|
|
3583
|
-
|
|
3584
|
-
|
|
3585
|
-
|
|
3586
|
-
|
|
3587
|
-
|
|
3588
|
-
|
|
3589
|
-
|
|
3590
|
-
|
|
3591
|
-
})
|
|
3592
|
-
)
|
|
3593
|
-
);
|
|
3594
|
-
searchParams.connection_ids = resolvedIds.filter((id) => id != null).join(",");
|
|
3595
|
-
} else if (legacyConnectionIds && legacyConnectionIds.length > 0) {
|
|
3596
|
-
searchParams.connection_ids = legacyConnectionIds.join(",");
|
|
3597
|
-
}
|
|
3598
|
-
if (options.search) {
|
|
3599
|
-
searchParams.search = options.search;
|
|
3600
|
-
}
|
|
3601
|
-
if (options.title) {
|
|
3602
|
-
searchParams.title = options.title;
|
|
3603
|
-
}
|
|
3604
|
-
const accountId = options.account ?? options.accountId;
|
|
3605
|
-
if (accountId) {
|
|
3606
|
-
searchParams.account_id = accountId;
|
|
3607
|
-
}
|
|
3608
|
-
if (options.owner && options.owner !== "me" && !options.includeShared) {
|
|
3609
|
-
throw new ZapierValidationError(
|
|
3610
|
-
'The "owner" option requires "includeShared" to be true. Without includeShared, only your own connections are returned.'
|
|
3674
|
+
const appKey = "app" in options ? options.app : options.appKey;
|
|
3675
|
+
const actionKey = "action" in options ? options.action : options.actionKey;
|
|
3676
|
+
const inputFieldKey = "inputField" in options ? options.inputField : options.inputFieldKey;
|
|
3677
|
+
const {
|
|
3678
|
+
actionType,
|
|
3679
|
+
connection,
|
|
3680
|
+
connectionId,
|
|
3681
|
+
authenticationId,
|
|
3682
|
+
inputs,
|
|
3683
|
+
page,
|
|
3684
|
+
cursor
|
|
3685
|
+
} = options;
|
|
3686
|
+
const resolvedConnectionId = await resolveConnectionId({
|
|
3687
|
+
connection,
|
|
3688
|
+
connectionId,
|
|
3689
|
+
authenticationId,
|
|
3690
|
+
resolveConnection: sdk2.context.resolveConnection
|
|
3691
|
+
});
|
|
3692
|
+
const selectedApi = await getVersionedImplementationId(appKey);
|
|
3693
|
+
if (!selectedApi) {
|
|
3694
|
+
throw new ZapierConfigurationError(
|
|
3695
|
+
"No current_implementation_id found for app",
|
|
3696
|
+
{ configType: "current_implementation_id" }
|
|
3611
3697
|
);
|
|
3612
3698
|
}
|
|
3613
|
-
|
|
3614
|
-
|
|
3615
|
-
|
|
3699
|
+
setMethodMetadata({
|
|
3700
|
+
selectedApi,
|
|
3701
|
+
operationType: actionType,
|
|
3702
|
+
operationKey: actionKey
|
|
3703
|
+
});
|
|
3704
|
+
const { data: action } = await sdk2.getAction({
|
|
3705
|
+
app: appKey,
|
|
3706
|
+
actionType,
|
|
3707
|
+
action: actionKey
|
|
3708
|
+
});
|
|
3709
|
+
const needsData = await fetchImplementationNeeds({
|
|
3710
|
+
api,
|
|
3711
|
+
selectedApi,
|
|
3712
|
+
action: action.key,
|
|
3713
|
+
actionType,
|
|
3714
|
+
connectionId: resolvedConnectionId ?? null,
|
|
3715
|
+
inputs
|
|
3716
|
+
});
|
|
3717
|
+
const targetNeed = needsData.needs?.find(
|
|
3718
|
+
(need) => need.key === inputFieldKey
|
|
3719
|
+
);
|
|
3720
|
+
if (targetNeed?.choices && targetNeed.choices.length > 0) {
|
|
3721
|
+
return {
|
|
3722
|
+
data: targetNeed.choices.map(
|
|
3723
|
+
transformNeedChoicesToInputFieldChoiceItem
|
|
3724
|
+
)
|
|
3725
|
+
};
|
|
3726
|
+
}
|
|
3727
|
+
if (!action.id) {
|
|
3728
|
+
throw new ZapierApiError(
|
|
3729
|
+
`Action ${actionKey} does not have an ID - cannot retrieve input field choices`
|
|
3730
|
+
);
|
|
3731
|
+
}
|
|
3732
|
+
const requestPage = cursor ? parseInt(cursor, 10) : page ?? 0;
|
|
3733
|
+
const choicesData = await fetchImplementationChoices({
|
|
3734
|
+
api,
|
|
3735
|
+
actionId: action.id,
|
|
3736
|
+
inputFieldId: inputFieldKey,
|
|
3737
|
+
connectionId: resolvedConnectionId ?? null,
|
|
3738
|
+
inputs,
|
|
3739
|
+
page: requestPage
|
|
3740
|
+
});
|
|
3741
|
+
const choices = (choicesData.choices || []).map(
|
|
3742
|
+
transformNeedChoicesToInputFieldChoiceItem
|
|
3743
|
+
);
|
|
3744
|
+
let nextCursor;
|
|
3745
|
+
if (choicesData.next_page != null) {
|
|
3746
|
+
nextCursor = choicesData.next_page.toString();
|
|
3747
|
+
} else if (choicesData.links?.next) {
|
|
3748
|
+
try {
|
|
3749
|
+
const nextUrl = new URL(choicesData.links.next);
|
|
3750
|
+
const nextPage = nextUrl.searchParams.get("page");
|
|
3751
|
+
if (nextPage) {
|
|
3752
|
+
nextCursor = nextPage;
|
|
3753
|
+
}
|
|
3754
|
+
} catch {
|
|
3755
|
+
}
|
|
3756
|
+
}
|
|
3757
|
+
return { data: choices, nextCursor };
|
|
3758
|
+
}
|
|
3759
|
+
})
|
|
3760
|
+
);
|
|
3761
|
+
var GetActionInputFieldsSchemaDescription = "Get the JSON Schema representation of input fields for an action. Returns a JSON Schema object describing the structure, types, and validation rules for the action's input parameters.";
|
|
3762
|
+
var GetActionInputFieldsSchemaBaseSchema = zod.z.object({
|
|
3763
|
+
connection: ConnectionPropertySchema.optional().describe(
|
|
3764
|
+
"Connection alias or connection ID (UUID or positive integer). Strings that match a key in the connections map are resolved against it; otherwise the value is used as a connection ID directly. Mutually exclusive with connectionId."
|
|
3765
|
+
),
|
|
3766
|
+
connectionId: ConnectionIdPropertySchema.nullable().optional().describe(
|
|
3767
|
+
"Connection ID to use when fetching the schema. Required if the action needs a connection to determine available fields."
|
|
3768
|
+
).meta({ deprecated: true }),
|
|
3769
|
+
/** @deprecated Use connection instead */
|
|
3770
|
+
authenticationId: AuthenticationIdPropertySchema.nullable().optional().describe(
|
|
3771
|
+
"Authentication ID to use when fetching the schema. Required if the action needs a connection to determine available fields."
|
|
3772
|
+
).meta({ deprecated: true }),
|
|
3773
|
+
inputs: InputsPropertySchema.optional().describe(
|
|
3774
|
+
"Current input values that may affect the schema (e.g., when fields depend on other field values)"
|
|
3775
|
+
)
|
|
3776
|
+
});
|
|
3777
|
+
var GetActionInputFieldsSchemaSchema = zod.z.object({
|
|
3778
|
+
app: AppPropertySchema.describe(
|
|
3779
|
+
"App key (e.g., 'SlackCLIAPI' or slug like 'github') to get the input schema for"
|
|
3780
|
+
),
|
|
3781
|
+
actionType: ActionTypePropertySchema.describe(
|
|
3782
|
+
"Action type that matches the action's defined type"
|
|
3783
|
+
),
|
|
3784
|
+
action: ActionPropertySchema.describe(
|
|
3785
|
+
"Action key to get the input schema for"
|
|
3786
|
+
)
|
|
3787
|
+
}).merge(GetActionInputFieldsSchemaBaseSchema).describe(GetActionInputFieldsSchemaDescription).meta({
|
|
3788
|
+
aliases: {
|
|
3789
|
+
appKey: "app",
|
|
3790
|
+
actionKey: "action",
|
|
3791
|
+
connectionId: "connection",
|
|
3792
|
+
authenticationId: "connection"
|
|
3793
|
+
}
|
|
3794
|
+
});
|
|
3795
|
+
var GetActionInputFieldsSchemaSchemaDeprecated = zod.z.object({
|
|
3796
|
+
appKey: AppKeyPropertySchema.describe(
|
|
3797
|
+
"App key (e.g., 'SlackCLIAPI' or slug like 'github') to get the input schema for"
|
|
3798
|
+
),
|
|
3799
|
+
actionType: ActionTypePropertySchema.describe(
|
|
3800
|
+
"Action type that matches the action's defined type"
|
|
3801
|
+
),
|
|
3802
|
+
actionKey: ActionKeyPropertySchema.describe(
|
|
3803
|
+
"Action key to get the input schema for"
|
|
3804
|
+
)
|
|
3805
|
+
}).merge(GetActionInputFieldsSchemaBaseSchema);
|
|
3806
|
+
var GetActionInputFieldsSchemaInputSchema = zod.z.union([
|
|
3807
|
+
GetActionInputFieldsSchemaSchema,
|
|
3808
|
+
GetActionInputFieldsSchemaSchemaDeprecated
|
|
3809
|
+
]).describe(GetActionInputFieldsSchemaDescription);
|
|
3810
|
+
|
|
3811
|
+
// src/plugins/getActionInputFieldsSchema/index.ts
|
|
3812
|
+
var getActionInputFieldsSchemaPlugin = definePlugin(
|
|
3813
|
+
(sdk) => createPluginMethod(sdk, {
|
|
3814
|
+
name: "getActionInputFieldsSchema",
|
|
3815
|
+
categories: ["action"],
|
|
3816
|
+
type: "item",
|
|
3817
|
+
itemType: "InputSchema",
|
|
3818
|
+
inputSchema: GetActionInputFieldsSchemaInputSchema,
|
|
3819
|
+
resolvers: {
|
|
3820
|
+
app: appKeyResolver,
|
|
3821
|
+
actionType: actionTypeResolver,
|
|
3822
|
+
action: actionKeyResolver,
|
|
3823
|
+
connection: connectionIdResolver,
|
|
3824
|
+
inputs: inputsAllOptionalResolver
|
|
3825
|
+
},
|
|
3826
|
+
handler: async ({
|
|
3827
|
+
sdk: sdk2,
|
|
3828
|
+
options
|
|
3829
|
+
}) => {
|
|
3830
|
+
const { api, getVersionedImplementationId } = sdk2.context;
|
|
3831
|
+
const appKey = "app" in options ? options.app : options.appKey;
|
|
3832
|
+
const actionKey = "action" in options ? options.action : options.actionKey;
|
|
3833
|
+
const {
|
|
3834
|
+
actionType,
|
|
3835
|
+
connection,
|
|
3836
|
+
connectionId,
|
|
3837
|
+
authenticationId,
|
|
3838
|
+
inputs
|
|
3839
|
+
} = options;
|
|
3840
|
+
const resolvedConnectionId = await resolveConnectionId({
|
|
3841
|
+
connection,
|
|
3842
|
+
connectionId,
|
|
3843
|
+
authenticationId,
|
|
3844
|
+
resolveConnection: sdk2.context.resolveConnection
|
|
3845
|
+
});
|
|
3846
|
+
const selectedApi = await getVersionedImplementationId(appKey);
|
|
3847
|
+
if (!selectedApi) {
|
|
3848
|
+
throw new ZapierConfigurationError(
|
|
3849
|
+
"No current_implementation_id found for app",
|
|
3850
|
+
{ configType: "current_implementation_id" }
|
|
3851
|
+
);
|
|
3852
|
+
}
|
|
3853
|
+
setMethodMetadata({
|
|
3854
|
+
selectedApi,
|
|
3855
|
+
operationType: actionType,
|
|
3856
|
+
operationKey: actionKey
|
|
3857
|
+
});
|
|
3858
|
+
const { data: action } = await sdk2.getAction({
|
|
3859
|
+
app: appKey,
|
|
3860
|
+
actionType,
|
|
3861
|
+
action: actionKey
|
|
3862
|
+
});
|
|
3863
|
+
const needsData = await fetchImplementationNeeds({
|
|
3864
|
+
api,
|
|
3865
|
+
selectedApi,
|
|
3866
|
+
action: action.key,
|
|
3867
|
+
actionType,
|
|
3868
|
+
connectionId: resolvedConnectionId ?? null,
|
|
3869
|
+
inputs
|
|
3870
|
+
});
|
|
3871
|
+
return { data: needsData.schema || {} };
|
|
3872
|
+
}
|
|
3873
|
+
})
|
|
3874
|
+
);
|
|
3875
|
+
var ListConnectionsQuerySchema = connections.ListConnectionsQuerySchema.omit({
|
|
3876
|
+
offset: true,
|
|
3877
|
+
// Omit snake_case fields, we'll add camelCase versions
|
|
3878
|
+
app_key: true,
|
|
3879
|
+
connection_ids: true,
|
|
3880
|
+
account_id: true,
|
|
3881
|
+
is_expired: true,
|
|
3882
|
+
page_size: true
|
|
3883
|
+
}).extend({
|
|
3884
|
+
// New name for appKey
|
|
3885
|
+
app: AppPropertySchema.optional().describe(
|
|
3886
|
+
"App key of connections to list (e.g., 'SlackCLIAPI' or slug like 'github')"
|
|
3887
|
+
),
|
|
3888
|
+
/** @deprecated Use `app` instead. */
|
|
3889
|
+
appKey: AppKeyPropertySchema.optional().describe(
|
|
3890
|
+
"App key of connections to list (e.g., 'SlackCLIAPI' or slug like 'github')"
|
|
3891
|
+
).meta({ deprecated: true }),
|
|
3892
|
+
// New name for connectionIds
|
|
3893
|
+
connections: ConnectionsPropertySchema.optional().describe(
|
|
3894
|
+
"List of connection IDs to filter by"
|
|
3895
|
+
),
|
|
3896
|
+
/** @deprecated Use `connections` instead. */
|
|
3897
|
+
connectionIds: zod.z.array(zod.z.string()).optional().describe("List of connection IDs to filter by").meta({ deprecated: true }),
|
|
3898
|
+
/** @deprecated Use `connections` instead. */
|
|
3899
|
+
authenticationIds: zod.z.array(zod.z.string()).optional().describe(
|
|
3900
|
+
"List of authentication IDs to filter by (deprecated, use connections)"
|
|
3901
|
+
).meta({ deprecated: true }),
|
|
3902
|
+
account: zod.z.string().optional().describe("Account to filter by"),
|
|
3903
|
+
/** @deprecated Use `account` instead. */
|
|
3904
|
+
accountId: zod.z.string().optional().describe("Account ID to filter by").meta({ deprecated: true }),
|
|
3905
|
+
// Include shared connections (overrides default owner=me filter)
|
|
3906
|
+
includeShared: zod.z.boolean().optional().describe(
|
|
3907
|
+
"Include connections shared with you. By default, only your own connections are returned (owner=me). Set to true to also include shared connections."
|
|
3908
|
+
),
|
|
3909
|
+
/** @deprecated Use `expired` instead */
|
|
3910
|
+
isExpired: zod.z.boolean().optional().describe("Filter by expired status").meta({
|
|
3911
|
+
deprecated: true,
|
|
3912
|
+
deprecationMessage: "Use --expired instead to show only expired connections."
|
|
3913
|
+
}),
|
|
3914
|
+
expired: zod.z.boolean().optional().describe(
|
|
3915
|
+
"Show only expired connections (default: only non-expired connections are returned)"
|
|
3916
|
+
),
|
|
3917
|
+
// Override pageSize to make optional
|
|
3918
|
+
pageSize: zod.z.number().min(1).optional().describe("Number of connections per page"),
|
|
3919
|
+
// SDK specific property for pagination/iterable helpers
|
|
3920
|
+
maxItems: zod.z.number().min(1).optional().describe("Maximum total items to return across all pages"),
|
|
3921
|
+
// SDK specific property for pagination/iterable helpers
|
|
3922
|
+
cursor: zod.z.string().optional().describe("Cursor to start from")
|
|
3923
|
+
}).describe("List available connections with optional filtering");
|
|
3924
|
+
var ConnectionItemSchema = withFormatter(connections.ConnectionItemSchema, {
|
|
3925
|
+
format: (item) => {
|
|
3926
|
+
const details = [];
|
|
3927
|
+
if (item.identifier) {
|
|
3928
|
+
details.push({
|
|
3929
|
+
text: `Identifier: ${item.identifier}`,
|
|
3930
|
+
style: "accent"
|
|
3931
|
+
});
|
|
3932
|
+
}
|
|
3933
|
+
details.push({
|
|
3934
|
+
text: `Account: ${item.account_id} | Private: ${item.is_private} | Shared: ${item.shared_with_all}`,
|
|
3935
|
+
style: "dim"
|
|
3936
|
+
});
|
|
3937
|
+
if (item.marked_stale_at) {
|
|
3938
|
+
details.push({
|
|
3939
|
+
text: `Warning: Marked stale: ${new Date(item.marked_stale_at).toLocaleDateString()}`,
|
|
3940
|
+
style: "warning"
|
|
3941
|
+
});
|
|
3942
|
+
}
|
|
3943
|
+
return {
|
|
3944
|
+
title: item.title || `Connection ${item.id}`,
|
|
3945
|
+
id: item.id?.toString(),
|
|
3946
|
+
details
|
|
3947
|
+
};
|
|
3948
|
+
}
|
|
3949
|
+
});
|
|
3950
|
+
|
|
3951
|
+
// src/plugins/listConnections/index.ts
|
|
3952
|
+
var listConnectionsPlugin = definePlugin(
|
|
3953
|
+
(sdk) => createPaginatedPluginMethod(sdk, {
|
|
3954
|
+
name: "listConnections",
|
|
3955
|
+
categories: ["connection"],
|
|
3956
|
+
type: "list",
|
|
3957
|
+
itemType: "Connection",
|
|
3958
|
+
inputSchema: ListConnectionsQuerySchema,
|
|
3959
|
+
outputSchema: ConnectionItemSchema,
|
|
3960
|
+
defaultPageSize: DEFAULT_PAGE_SIZE,
|
|
3961
|
+
resolvers: { app: appKeyResolver },
|
|
3962
|
+
handler: async ({ sdk: sdk2, options }) => {
|
|
3963
|
+
if (options.includeShared) {
|
|
3964
|
+
await sdk2.context.checkCapability("canIncludeSharedConnections");
|
|
3965
|
+
}
|
|
3966
|
+
const { api, getVersionedImplementationId } = sdk2.context;
|
|
3967
|
+
const searchParams = {};
|
|
3968
|
+
if (options.pageSize !== void 0) {
|
|
3969
|
+
searchParams.page_size = options.pageSize.toString();
|
|
3970
|
+
}
|
|
3971
|
+
const appKey = options.app ?? options.appKey;
|
|
3972
|
+
if (appKey) {
|
|
3973
|
+
const implementationId = await getVersionedImplementationId(appKey);
|
|
3974
|
+
if (implementationId) {
|
|
3975
|
+
setMethodMetadata({ selectedApi: implementationId });
|
|
3976
|
+
const [versionlessSelectedApi] = splitVersionedKey(implementationId);
|
|
3977
|
+
searchParams.app_key = versionlessSelectedApi;
|
|
3978
|
+
} else {
|
|
3979
|
+
searchParams.app_key = appKey;
|
|
3980
|
+
}
|
|
3981
|
+
}
|
|
3982
|
+
const connectionRefs = options.connections;
|
|
3983
|
+
const legacyConnectionIds = options.connectionIds ?? options.authenticationIds;
|
|
3984
|
+
if (connectionRefs && connectionRefs.length > 0) {
|
|
3985
|
+
const resolvedIds = await Promise.all(
|
|
3986
|
+
connectionRefs.map(
|
|
3987
|
+
(ref) => resolveConnectionId({
|
|
3988
|
+
connection: ref,
|
|
3989
|
+
resolveConnection: sdk2.context.resolveConnection
|
|
3990
|
+
})
|
|
3991
|
+
)
|
|
3992
|
+
);
|
|
3993
|
+
searchParams.connection_ids = resolvedIds.filter((id) => id != null).join(",");
|
|
3994
|
+
} else if (legacyConnectionIds && legacyConnectionIds.length > 0) {
|
|
3995
|
+
searchParams.connection_ids = legacyConnectionIds.join(",");
|
|
3996
|
+
}
|
|
3997
|
+
if (options.search) {
|
|
3998
|
+
searchParams.search = options.search;
|
|
3999
|
+
}
|
|
4000
|
+
if (options.title) {
|
|
4001
|
+
searchParams.title = options.title;
|
|
4002
|
+
}
|
|
4003
|
+
const accountId = options.account ?? options.accountId;
|
|
4004
|
+
if (accountId) {
|
|
4005
|
+
searchParams.account_id = accountId;
|
|
4006
|
+
}
|
|
4007
|
+
if (options.owner && options.owner !== "me" && !options.includeShared) {
|
|
4008
|
+
throw new ZapierValidationError(
|
|
4009
|
+
'The "owner" option requires "includeShared" to be true. Without includeShared, only your own connections are returned.'
|
|
4010
|
+
);
|
|
4011
|
+
}
|
|
4012
|
+
const owner = options.includeShared ? options.owner : "me";
|
|
4013
|
+
if (owner) {
|
|
4014
|
+
searchParams.owner = owner;
|
|
3616
4015
|
}
|
|
3617
4016
|
if (options.isExpired !== void 0) {
|
|
3618
4017
|
searchParams.is_expired = options.isExpired.toString();
|
|
@@ -4987,8 +5386,22 @@ function calculateExponentialBackoffMs(attempt, baseDelayMs = BASE_EXPONENTIAL_B
|
|
|
4987
5386
|
const jitter = Math.random() * JITTER_FACTOR * baseDelay;
|
|
4988
5387
|
return Math.floor(baseDelay + jitter);
|
|
4989
5388
|
}
|
|
4990
|
-
function sleep(ms) {
|
|
4991
|
-
|
|
5389
|
+
function sleep(ms, signal) {
|
|
5390
|
+
if (!signal) {
|
|
5391
|
+
return new Promise((resolve2) => setTimeout(resolve2, ms));
|
|
5392
|
+
}
|
|
5393
|
+
if (signal.aborted) return Promise.resolve();
|
|
5394
|
+
return new Promise((resolve2) => {
|
|
5395
|
+
const timer = setTimeout(() => {
|
|
5396
|
+
signal.removeEventListener("abort", onAbort);
|
|
5397
|
+
resolve2();
|
|
5398
|
+
}, ms);
|
|
5399
|
+
const onAbort = () => {
|
|
5400
|
+
clearTimeout(timer);
|
|
5401
|
+
resolve2();
|
|
5402
|
+
};
|
|
5403
|
+
signal.addEventListener("abort", onAbort, { once: true });
|
|
5404
|
+
});
|
|
4992
5405
|
}
|
|
4993
5406
|
|
|
4994
5407
|
// src/api/polling.ts
|
|
@@ -5018,6 +5431,14 @@ function getPollingInterval(elapsedMs) {
|
|
|
5018
5431
|
const stage = POLLING_STAGES.find(([threshold]) => elapsedMs < threshold);
|
|
5019
5432
|
return stage ? stage[1] : DEFAULT_MAX_POLLING_INTERVAL_MS;
|
|
5020
5433
|
}
|
|
5434
|
+
function makeAbortError() {
|
|
5435
|
+
if (typeof DOMException !== "undefined") {
|
|
5436
|
+
return new DOMException("Polling was aborted", "AbortError");
|
|
5437
|
+
}
|
|
5438
|
+
const err = new Error("Polling was aborted");
|
|
5439
|
+
err.name = "AbortError";
|
|
5440
|
+
return err;
|
|
5441
|
+
}
|
|
5021
5442
|
var processResponse = async (response, successStatus, pendingStatus, isPending, resultExtractor, errorCount) => {
|
|
5022
5443
|
if (!response.ok) {
|
|
5023
5444
|
return {
|
|
@@ -5071,7 +5492,8 @@ async function pollUntilComplete(options) {
|
|
|
5071
5492
|
successStatus = DEFAULT_SUCCESS_STATUS,
|
|
5072
5493
|
pendingStatus = DEFAULT_PENDING_STATUS,
|
|
5073
5494
|
isPending,
|
|
5074
|
-
resultExtractor = (response) => response
|
|
5495
|
+
resultExtractor = (response) => response,
|
|
5496
|
+
signal
|
|
5075
5497
|
} = options;
|
|
5076
5498
|
if (timeoutMs <= 0) {
|
|
5077
5499
|
throw new ZapierValidationError("Timeout must be greater than 0", {
|
|
@@ -5083,13 +5505,16 @@ async function pollUntilComplete(options) {
|
|
|
5083
5505
|
details: { initialDelay }
|
|
5084
5506
|
});
|
|
5085
5507
|
}
|
|
5508
|
+
if (signal?.aborted) throw makeAbortError();
|
|
5086
5509
|
const startTime = Date.now();
|
|
5087
5510
|
let attempts = 0;
|
|
5088
5511
|
let errorCount = 0;
|
|
5089
5512
|
if (initialDelay > 0) {
|
|
5090
|
-
await sleep(initialDelay);
|
|
5513
|
+
await sleep(initialDelay, signal);
|
|
5514
|
+
if (signal?.aborted) throw makeAbortError();
|
|
5091
5515
|
}
|
|
5092
5516
|
while (true) {
|
|
5517
|
+
if (signal?.aborted) throw makeAbortError();
|
|
5093
5518
|
const elapsedTime = Date.now() - startTime;
|
|
5094
5519
|
if (elapsedTime >= timeoutMs) {
|
|
5095
5520
|
throw new ZapierTimeoutError(
|
|
@@ -5102,7 +5527,8 @@ async function pollUntilComplete(options) {
|
|
|
5102
5527
|
if (attempts > 0) {
|
|
5103
5528
|
const interval = getPollingInterval(elapsedTime);
|
|
5104
5529
|
const waitTime = calculateErrorBackoffMs(interval, errorCount);
|
|
5105
|
-
await sleep(waitTime);
|
|
5530
|
+
await sleep(waitTime, signal);
|
|
5531
|
+
if (signal?.aborted) throw makeAbortError();
|
|
5106
5532
|
}
|
|
5107
5533
|
attempts++;
|
|
5108
5534
|
try {
|
|
@@ -5130,6 +5556,7 @@ async function pollUntilComplete(options) {
|
|
|
5130
5556
|
);
|
|
5131
5557
|
}
|
|
5132
5558
|
} catch (error) {
|
|
5559
|
+
if (isAbortError(error)) throw error;
|
|
5133
5560
|
errorCount++;
|
|
5134
5561
|
if (errorCount >= MAX_CONSECUTIVE_ERRORS) {
|
|
5135
5562
|
throw new ZapierApiError(
|
|
@@ -5631,7 +6058,7 @@ async function invalidateCredentialsToken(options) {
|
|
|
5631
6058
|
}
|
|
5632
6059
|
|
|
5633
6060
|
// src/sdk-version.ts
|
|
5634
|
-
var SDK_VERSION = (typeof process !== "undefined" && process.env ? "0.
|
|
6061
|
+
var SDK_VERSION = (typeof process !== "undefined" && process.env ? "0.50.0" : void 0) || "unknown";
|
|
5635
6062
|
|
|
5636
6063
|
// src/utils/open-url.ts
|
|
5637
6064
|
var nodePrefix = "node:";
|
|
@@ -5771,6 +6198,11 @@ var pathConfig = {
|
|
|
5771
6198
|
"/tables": {
|
|
5772
6199
|
authHeader: "Authorization",
|
|
5773
6200
|
pathPrefix: "/api/v0/sdk/tables"
|
|
6201
|
+
},
|
|
6202
|
+
// e.g. /trigger-inbox -> https://sdkapi.zapier.com/api/v0/sdk/trigger-inbox/...
|
|
6203
|
+
"/trigger-inbox": {
|
|
6204
|
+
authHeader: "Authorization",
|
|
6205
|
+
pathPrefix: "/api/v0/sdk/trigger-inbox"
|
|
5774
6206
|
}
|
|
5775
6207
|
};
|
|
5776
6208
|
var ZapierApiClient = class {
|
|
@@ -5833,7 +6265,7 @@ var ZapierApiClient = class {
|
|
|
5833
6265
|
method: init?.method ?? "GET",
|
|
5834
6266
|
rateLimit: rateLimitInfo
|
|
5835
6267
|
});
|
|
5836
|
-
await sleep(delayMs);
|
|
6268
|
+
await sleep(delayMs, init?.signal ?? void 0);
|
|
5837
6269
|
}
|
|
5838
6270
|
};
|
|
5839
6271
|
/**
|
|
@@ -5901,10 +6333,10 @@ var ZapierApiClient = class {
|
|
|
5901
6333
|
}
|
|
5902
6334
|
if (errorType !== "approval_required") return response;
|
|
5903
6335
|
if (attempt === maxRetries) break;
|
|
5904
|
-
const
|
|
5905
|
-
if (
|
|
6336
|
+
const mode = this.options.approvalMode ?? getZapierApprovalMode() ?? "disabled";
|
|
6337
|
+
if (mode === "disabled") {
|
|
5906
6338
|
throw new ZapierApprovalError(
|
|
5907
|
-
"
|
|
6339
|
+
"Approvals are disabled. Set approvalMode to 'poll' or 'throw' (or ZAPIER_APPROVAL_MODE) to enable.",
|
|
5908
6340
|
{ status: "approval_required" }
|
|
5909
6341
|
);
|
|
5910
6342
|
}
|
|
@@ -5914,7 +6346,7 @@ var ZapierApiClient = class {
|
|
|
5914
6346
|
{ statusCode: 403 }
|
|
5915
6347
|
);
|
|
5916
6348
|
}
|
|
5917
|
-
await this.runOneApprovalRound(init.approvalContext);
|
|
6349
|
+
await this.runOneApprovalRound(init.approvalContext, mode);
|
|
5918
6350
|
}
|
|
5919
6351
|
throw new ZapierApprovalError(
|
|
5920
6352
|
`Exceeded maximum approval retries (${maxRetries}) for ${path}`,
|
|
@@ -5941,14 +6373,16 @@ var ZapierApiClient = class {
|
|
|
5941
6373
|
fetchPoll: () => this.fetch(path, {
|
|
5942
6374
|
method: "GET",
|
|
5943
6375
|
searchParams: options.searchParams,
|
|
5944
|
-
authRequired: options.authRequired
|
|
6376
|
+
authRequired: options.authRequired,
|
|
6377
|
+
signal: options.signal
|
|
5945
6378
|
}),
|
|
5946
6379
|
initialDelay: options.initialDelay,
|
|
5947
6380
|
timeoutMs: options.timeoutMs,
|
|
5948
6381
|
successStatus: options.successStatus,
|
|
5949
6382
|
pendingStatus: options.pendingStatus,
|
|
5950
6383
|
isPending: options.isPending,
|
|
5951
|
-
resultExtractor: options.resultExtractor
|
|
6384
|
+
resultExtractor: options.resultExtractor,
|
|
6385
|
+
signal: options.signal
|
|
5952
6386
|
});
|
|
5953
6387
|
};
|
|
5954
6388
|
this.maxNetworkRetries = options.maxNetworkRetries ?? ZAPIER_MAX_NETWORK_RETRIES;
|
|
@@ -6231,10 +6665,13 @@ var ZapierApiClient = class {
|
|
|
6231
6665
|
}
|
|
6232
6666
|
/**
|
|
6233
6667
|
* Run a single approval round: create the approval, open the URL (poll mode)
|
|
6234
|
-
* or throw (
|
|
6668
|
+
* or throw (throw mode), poll until resolved, and emit events. Throws on
|
|
6235
6669
|
* denied/timeout/unexpected status. Returns on approved.
|
|
6670
|
+
*
|
|
6671
|
+
* Caller is responsible for passing a non-"disabled" mode; this method
|
|
6672
|
+
* unconditionally creates an approval.
|
|
6236
6673
|
*/
|
|
6237
|
-
async runOneApprovalRound(buildContext) {
|
|
6674
|
+
async runOneApprovalRound(buildContext, mode) {
|
|
6238
6675
|
const context = buildContext();
|
|
6239
6676
|
let approvalResponse;
|
|
6240
6677
|
try {
|
|
@@ -6309,8 +6746,7 @@ var ZapierApiClient = class {
|
|
|
6309
6746
|
approvalId: approval.approval_id,
|
|
6310
6747
|
approvalUrl: approval.approval_url
|
|
6311
6748
|
});
|
|
6312
|
-
|
|
6313
|
-
if (approvalMode === "fail") {
|
|
6749
|
+
if (mode === "throw") {
|
|
6314
6750
|
throw new ZapierApprovalError("This request requires approval.", {
|
|
6315
6751
|
approvalId: approval.approval_id,
|
|
6316
6752
|
approvalUrl: approval.approval_url,
|
|
@@ -6409,7 +6845,6 @@ var apiPlugin = definePlugin(
|
|
|
6409
6845
|
debug = false,
|
|
6410
6846
|
maxNetworkRetries = ZAPIER_MAX_NETWORK_RETRIES,
|
|
6411
6847
|
maxNetworkRetryDelayMs = ZAPIER_MAX_NETWORK_RETRY_DELAY_MS,
|
|
6412
|
-
isInteractive,
|
|
6413
6848
|
approvalTimeoutMs,
|
|
6414
6849
|
maxApprovalRetries,
|
|
6415
6850
|
approvalMode,
|
|
@@ -6424,7 +6859,6 @@ var apiPlugin = definePlugin(
|
|
|
6424
6859
|
onEvent,
|
|
6425
6860
|
maxNetworkRetries,
|
|
6426
6861
|
maxNetworkRetryDelayMs,
|
|
6427
|
-
isInteractive,
|
|
6428
6862
|
approvalTimeoutMs,
|
|
6429
6863
|
maxApprovalRetries,
|
|
6430
6864
|
approvalMode,
|
|
@@ -7416,6 +7850,7 @@ var categoryDefinitions = {
|
|
|
7416
7850
|
titlePlural: "Client Credentials"
|
|
7417
7851
|
},
|
|
7418
7852
|
table: { title: "Table" },
|
|
7853
|
+
trigger: { title: "Trigger" },
|
|
7419
7854
|
http: { title: "HTTP Request" },
|
|
7420
7855
|
utility: { title: "Utility", titlePlural: "Utilities" },
|
|
7421
7856
|
other: { title: "Other" }
|
|
@@ -7446,6 +7881,7 @@ function buildRegistry({
|
|
|
7446
7881
|
categories: m.categories || [],
|
|
7447
7882
|
resolvers: m.resolvers,
|
|
7448
7883
|
formatter: m.formatter,
|
|
7884
|
+
experimental: m.experimental,
|
|
7449
7885
|
packages: m.packages,
|
|
7450
7886
|
confirm: m.confirm ?? (m.type === "delete" ? "delete" : void 0),
|
|
7451
7887
|
deprecation: m.deprecation,
|
|
@@ -7477,359 +7913,120 @@ function buildRegistry({
|
|
|
7477
7913
|
|
|
7478
7914
|
// src/plugins/deprecated/authentications.ts
|
|
7479
7915
|
var listAuthenticationsPlugin = definePlugin(
|
|
7480
|
-
(sdk) => ({
|
|
7481
|
-
listAuthentications: sdk.listConnections,
|
|
7482
|
-
context: {
|
|
7483
|
-
meta: {
|
|
7484
|
-
listAuthentications: {
|
|
7485
|
-
packages: ["cli", "mcp"],
|
|
7486
|
-
categories: ["connection", "deprecated"],
|
|
7487
|
-
type: "list",
|
|
7488
|
-
itemType: "Connection",
|
|
7489
|
-
inputSchema: ListConnectionsQuerySchema,
|
|
7490
|
-
outputSchema: ConnectionItemSchema
|
|
7491
|
-
}
|
|
7492
|
-
}
|
|
7493
|
-
}
|
|
7494
|
-
})
|
|
7495
|
-
);
|
|
7496
|
-
var getAuthenticationPlugin = definePlugin(
|
|
7497
|
-
(sdk) => ({
|
|
7498
|
-
getAuthentication: sdk.getConnection,
|
|
7499
|
-
context: {
|
|
7500
|
-
meta: {
|
|
7501
|
-
getAuthentication: {
|
|
7502
|
-
packages: ["cli", "mcp"],
|
|
7503
|
-
categories: ["connection", "deprecated"],
|
|
7504
|
-
type: "item",
|
|
7505
|
-
itemType: "Connection",
|
|
7506
|
-
inputSchema: GetConnectionParamSchema,
|
|
7507
|
-
outputSchema: ConnectionItemSchema
|
|
7508
|
-
}
|
|
7509
|
-
}
|
|
7510
|
-
}
|
|
7511
|
-
})
|
|
7512
|
-
);
|
|
7513
|
-
var findFirstAuthenticationPlugin = definePlugin(
|
|
7514
|
-
(sdk) => ({
|
|
7515
|
-
findFirstAuthentication: sdk.findFirstConnection,
|
|
7516
|
-
context: {
|
|
7517
|
-
meta: {
|
|
7518
|
-
findFirstAuthentication: {
|
|
7519
|
-
packages: ["cli", "mcp"],
|
|
7520
|
-
categories: ["connection", "deprecated"],
|
|
7521
|
-
type: "item",
|
|
7522
|
-
itemType: "Connection",
|
|
7523
|
-
inputSchema: FindFirstConnectionSchema,
|
|
7524
|
-
outputSchema: ConnectionItemSchema
|
|
7525
|
-
}
|
|
7526
|
-
}
|
|
7527
|
-
}
|
|
7528
|
-
})
|
|
7529
|
-
);
|
|
7530
|
-
var findUniqueAuthenticationPlugin = definePlugin(
|
|
7531
|
-
(sdk) => ({
|
|
7532
|
-
findUniqueAuthentication: sdk.findUniqueConnection,
|
|
7533
|
-
context: {
|
|
7534
|
-
meta: {
|
|
7535
|
-
findUniqueAuthentication: {
|
|
7536
|
-
packages: ["cli", "mcp"],
|
|
7537
|
-
categories: ["connection", "deprecated"],
|
|
7538
|
-
type: "item",
|
|
7539
|
-
itemType: "Connection",
|
|
7540
|
-
inputSchema: FindUniqueConnectionSchema,
|
|
7541
|
-
outputSchema: ConnectionItemSchema
|
|
7542
|
-
}
|
|
7543
|
-
}
|
|
7544
|
-
}
|
|
7545
|
-
})
|
|
7546
|
-
);
|
|
7547
|
-
var GetInputFieldsSchemaDescription = "Get the JSON Schema representation of input fields for an action. Returns a JSON Schema object describing the structure, types, and validation rules for the action's input parameters.";
|
|
7548
|
-
var GetInputFieldsSchemaBaseSchema = zod.z.object({
|
|
7549
|
-
connection: ConnectionPropertySchema.optional().describe(
|
|
7550
|
-
"Connection alias or connection ID (UUID or positive integer). Strings that match a key in the connections map are resolved against it; otherwise the value is used as a connection ID directly. Mutually exclusive with connectionId."
|
|
7551
|
-
),
|
|
7552
|
-
connectionId: ConnectionIdPropertySchema.nullable().optional().describe(
|
|
7553
|
-
"Connection ID to use when fetching the schema. Required if the action needs a connection to determine available fields."
|
|
7554
|
-
).meta({ deprecated: true }),
|
|
7555
|
-
/** @deprecated Use connection instead */
|
|
7556
|
-
authenticationId: AuthenticationIdPropertySchema.nullable().optional().describe(
|
|
7557
|
-
"Authentication ID to use when fetching the schema. Required if the action needs a connection to determine available fields."
|
|
7558
|
-
).meta({ deprecated: true }),
|
|
7559
|
-
inputs: InputsPropertySchema.optional().describe(
|
|
7560
|
-
"Current input values that may affect the schema (e.g., when fields depend on other field values)"
|
|
7561
|
-
)
|
|
7562
|
-
});
|
|
7563
|
-
var GetInputFieldsSchemaSchema = zod.z.object({
|
|
7564
|
-
app: AppPropertySchema.describe(
|
|
7565
|
-
"App key (e.g., 'SlackCLIAPI' or slug like 'github') to get the input schema for"
|
|
7566
|
-
),
|
|
7567
|
-
actionType: ActionTypePropertySchema.describe(
|
|
7568
|
-
"Action type that matches the action's defined type"
|
|
7569
|
-
),
|
|
7570
|
-
action: ActionPropertySchema.describe(
|
|
7571
|
-
"Action key to get the input schema for"
|
|
7572
|
-
)
|
|
7573
|
-
}).merge(GetInputFieldsSchemaBaseSchema).describe(GetInputFieldsSchemaDescription).meta({
|
|
7574
|
-
aliases: {
|
|
7575
|
-
appKey: "app",
|
|
7576
|
-
actionKey: "action",
|
|
7577
|
-
connectionId: "connection",
|
|
7578
|
-
authenticationId: "connection"
|
|
7579
|
-
}
|
|
7580
|
-
});
|
|
7581
|
-
var GetInputFieldsSchemaSchemaDeprecated = zod.z.object({
|
|
7582
|
-
appKey: AppKeyPropertySchema.describe(
|
|
7583
|
-
"App key (e.g., 'SlackCLIAPI' or slug like 'github') to get the input schema for"
|
|
7584
|
-
),
|
|
7585
|
-
actionType: ActionTypePropertySchema.describe(
|
|
7586
|
-
"Action type that matches the action's defined type"
|
|
7587
|
-
),
|
|
7588
|
-
actionKey: ActionKeyPropertySchema.describe(
|
|
7589
|
-
"Action key to get the input schema for"
|
|
7590
|
-
)
|
|
7591
|
-
}).merge(GetInputFieldsSchemaBaseSchema);
|
|
7592
|
-
var GetInputFieldsSchemaInputSchema = zod.z.union([GetInputFieldsSchemaSchema, GetInputFieldsSchemaSchemaDeprecated]).describe(GetInputFieldsSchemaDescription);
|
|
7593
|
-
|
|
7594
|
-
// src/plugins/getInputFieldsSchema/index.ts
|
|
7595
|
-
var getInputFieldsSchemaPlugin = definePlugin(
|
|
7596
|
-
(sdk) => createPluginMethod(sdk, {
|
|
7597
|
-
name: "getInputFieldsSchema",
|
|
7598
|
-
categories: ["action"],
|
|
7599
|
-
type: "item",
|
|
7600
|
-
itemType: "InputSchema",
|
|
7601
|
-
inputSchema: GetInputFieldsSchemaInputSchema,
|
|
7602
|
-
resolvers: {
|
|
7603
|
-
app: appKeyResolver,
|
|
7604
|
-
actionType: actionTypeResolver,
|
|
7605
|
-
action: actionKeyResolver,
|
|
7606
|
-
connection: connectionIdResolver,
|
|
7607
|
-
inputs: inputsAllOptionalResolver
|
|
7608
|
-
},
|
|
7609
|
-
handler: async ({
|
|
7610
|
-
sdk: sdk2,
|
|
7611
|
-
options
|
|
7612
|
-
}) => {
|
|
7613
|
-
const { api, getVersionedImplementationId } = sdk2.context;
|
|
7614
|
-
const appKey = "app" in options ? options.app : options.appKey;
|
|
7615
|
-
const actionKey = "action" in options ? options.action : options.actionKey;
|
|
7616
|
-
const {
|
|
7617
|
-
actionType,
|
|
7618
|
-
connection,
|
|
7619
|
-
connectionId,
|
|
7620
|
-
authenticationId,
|
|
7621
|
-
inputs
|
|
7622
|
-
} = options;
|
|
7623
|
-
const resolvedConnectionId = await resolveConnectionId({
|
|
7624
|
-
connection,
|
|
7625
|
-
connectionId,
|
|
7626
|
-
authenticationId,
|
|
7627
|
-
resolveConnection: sdk2.context.resolveConnection
|
|
7628
|
-
});
|
|
7629
|
-
const selectedApi = await getVersionedImplementationId(appKey);
|
|
7630
|
-
if (!selectedApi) {
|
|
7631
|
-
throw new ZapierConfigurationError(
|
|
7632
|
-
"No current_implementation_id found for app",
|
|
7633
|
-
{ configType: "current_implementation_id" }
|
|
7634
|
-
);
|
|
7916
|
+
(sdk) => ({
|
|
7917
|
+
listAuthentications: sdk.listConnections,
|
|
7918
|
+
context: {
|
|
7919
|
+
meta: {
|
|
7920
|
+
listAuthentications: {
|
|
7921
|
+
packages: ["cli", "mcp"],
|
|
7922
|
+
categories: ["connection", "deprecated"],
|
|
7923
|
+
type: "list",
|
|
7924
|
+
itemType: "Connection",
|
|
7925
|
+
inputSchema: ListConnectionsQuerySchema,
|
|
7926
|
+
outputSchema: ConnectionItemSchema
|
|
7927
|
+
}
|
|
7635
7928
|
}
|
|
7636
|
-
setMethodMetadata({
|
|
7637
|
-
selectedApi,
|
|
7638
|
-
operationType: actionType,
|
|
7639
|
-
operationKey: actionKey
|
|
7640
|
-
});
|
|
7641
|
-
const { data: action } = await sdk2.getAction({
|
|
7642
|
-
app: appKey,
|
|
7643
|
-
actionType,
|
|
7644
|
-
action: actionKey
|
|
7645
|
-
});
|
|
7646
|
-
const needsData = await fetchImplementationNeeds({
|
|
7647
|
-
api,
|
|
7648
|
-
selectedApi,
|
|
7649
|
-
action: action.key,
|
|
7650
|
-
actionType,
|
|
7651
|
-
connectionId: resolvedConnectionId ?? null,
|
|
7652
|
-
inputs
|
|
7653
|
-
});
|
|
7654
|
-
return { data: needsData.schema || {} };
|
|
7655
7929
|
}
|
|
7656
7930
|
})
|
|
7657
7931
|
);
|
|
7658
|
-
var
|
|
7659
|
-
|
|
7660
|
-
|
|
7661
|
-
|
|
7662
|
-
|
|
7663
|
-
|
|
7932
|
+
var getAuthenticationPlugin = definePlugin(
|
|
7933
|
+
(sdk) => ({
|
|
7934
|
+
getAuthentication: sdk.getConnection,
|
|
7935
|
+
context: {
|
|
7936
|
+
meta: {
|
|
7937
|
+
getAuthentication: {
|
|
7938
|
+
packages: ["cli", "mcp"],
|
|
7939
|
+
categories: ["connection", "deprecated"],
|
|
7940
|
+
type: "item",
|
|
7941
|
+
itemType: "Connection",
|
|
7942
|
+
inputSchema: GetConnectionParamSchema,
|
|
7943
|
+
outputSchema: ConnectionItemSchema
|
|
7944
|
+
}
|
|
7945
|
+
}
|
|
7664
7946
|
}
|
|
7665
|
-
|
|
7666
|
-
|
|
7947
|
+
})
|
|
7948
|
+
);
|
|
7949
|
+
var findFirstAuthenticationPlugin = definePlugin(
|
|
7950
|
+
(sdk) => ({
|
|
7951
|
+
findFirstAuthentication: sdk.findFirstConnection,
|
|
7952
|
+
context: {
|
|
7953
|
+
meta: {
|
|
7954
|
+
findFirstAuthentication: {
|
|
7955
|
+
packages: ["cli", "mcp"],
|
|
7956
|
+
categories: ["connection", "deprecated"],
|
|
7957
|
+
type: "item",
|
|
7958
|
+
itemType: "Connection",
|
|
7959
|
+
inputSchema: FindFirstConnectionSchema,
|
|
7960
|
+
outputSchema: ConnectionItemSchema
|
|
7961
|
+
}
|
|
7962
|
+
}
|
|
7667
7963
|
}
|
|
7668
|
-
|
|
7669
|
-
|
|
7964
|
+
})
|
|
7965
|
+
);
|
|
7966
|
+
var findUniqueAuthenticationPlugin = definePlugin(
|
|
7967
|
+
(sdk) => ({
|
|
7968
|
+
findUniqueAuthentication: sdk.findUniqueConnection,
|
|
7969
|
+
context: {
|
|
7970
|
+
meta: {
|
|
7971
|
+
findUniqueAuthentication: {
|
|
7972
|
+
packages: ["cli", "mcp"],
|
|
7973
|
+
categories: ["connection", "deprecated"],
|
|
7974
|
+
type: "item",
|
|
7975
|
+
itemType: "Connection",
|
|
7976
|
+
inputSchema: FindUniqueConnectionSchema,
|
|
7977
|
+
outputSchema: ConnectionItemSchema
|
|
7978
|
+
}
|
|
7979
|
+
}
|
|
7670
7980
|
}
|
|
7671
|
-
|
|
7672
|
-
|
|
7673
|
-
key: item.key,
|
|
7674
|
-
details
|
|
7675
|
-
};
|
|
7676
|
-
}
|
|
7677
|
-
});
|
|
7678
|
-
var ListInputFieldChoicesDescription = "Get the available choices for a dynamic dropdown input field";
|
|
7679
|
-
var ListInputFieldChoicesBaseSchema = zod.z.object({
|
|
7680
|
-
connection: ConnectionPropertySchema.optional().describe(
|
|
7681
|
-
"Connection alias or connection ID (UUID or positive integer). Strings that match a key in the connections map are resolved against it; otherwise the value is used as a connection ID directly. Mutually exclusive with connectionId."
|
|
7682
|
-
),
|
|
7683
|
-
connectionId: ConnectionIdPropertySchema.nullable().optional().describe(
|
|
7684
|
-
"Connection ID to use when listing available field choices. Required if the action needs a connection to populate dynamic dropdown options."
|
|
7685
|
-
).meta({ deprecated: true }),
|
|
7686
|
-
/** @deprecated Use connection instead */
|
|
7687
|
-
authenticationId: AuthenticationIdPropertySchema.nullable().optional().meta({ deprecated: true }),
|
|
7688
|
-
inputs: InputsPropertySchema.optional().describe(
|
|
7689
|
-
"Current input values that may affect available choices"
|
|
7690
|
-
),
|
|
7691
|
-
page: zod.z.number().int().min(0).optional().describe("Page number for paginated results"),
|
|
7692
|
-
pageSize: zod.z.number().min(1).optional().describe("Number of choices per page"),
|
|
7693
|
-
maxItems: zod.z.number().min(1).optional().describe("Maximum total items to return across all pages"),
|
|
7694
|
-
cursor: zod.z.string().optional().describe("Cursor to start from")
|
|
7695
|
-
});
|
|
7696
|
-
var ListInputFieldChoicesSchema = zod.z.object({
|
|
7697
|
-
app: AppPropertySchema,
|
|
7698
|
-
actionType: ActionTypePropertySchema,
|
|
7699
|
-
action: ActionPropertySchema,
|
|
7700
|
-
inputField: InputFieldPropertySchema
|
|
7701
|
-
}).merge(ListInputFieldChoicesBaseSchema).describe(ListInputFieldChoicesDescription).meta({
|
|
7702
|
-
aliases: {
|
|
7703
|
-
appKey: "app",
|
|
7704
|
-
actionKey: "action",
|
|
7705
|
-
inputFieldKey: "inputField",
|
|
7706
|
-
connectionId: "connection",
|
|
7707
|
-
authenticationId: "connection"
|
|
7708
|
-
}
|
|
7709
|
-
});
|
|
7710
|
-
var ListInputFieldChoicesSchemaDeprecated = zod.z.object({
|
|
7711
|
-
appKey: AppKeyPropertySchema,
|
|
7712
|
-
actionType: ActionTypePropertySchema,
|
|
7713
|
-
actionKey: ActionKeyPropertySchema,
|
|
7714
|
-
inputFieldKey: zod.z.string().min(1).describe("Input field key to get choices for.")
|
|
7715
|
-
}).merge(ListInputFieldChoicesBaseSchema);
|
|
7716
|
-
var ListInputFieldChoicesInputSchema = zod.z.union([ListInputFieldChoicesSchema, ListInputFieldChoicesSchemaDeprecated]).describe(ListInputFieldChoicesDescription);
|
|
7981
|
+
})
|
|
7982
|
+
);
|
|
7717
7983
|
|
|
7718
|
-
// src/plugins/
|
|
7719
|
-
|
|
7720
|
-
|
|
7721
|
-
|
|
7722
|
-
|
|
7723
|
-
|
|
7724
|
-
|
|
7725
|
-
|
|
7726
|
-
|
|
7727
|
-
|
|
7728
|
-
|
|
7729
|
-
|
|
7730
|
-
|
|
7731
|
-
|
|
7732
|
-
itemType: "InputFieldChoice",
|
|
7733
|
-
inputSchema: ListInputFieldChoicesInputSchema,
|
|
7734
|
-
outputSchema: InputFieldChoiceItemSchema,
|
|
7735
|
-
defaultPageSize: DEFAULT_PAGE_SIZE,
|
|
7736
|
-
resolvers: {
|
|
7737
|
-
app: appKeyResolver,
|
|
7738
|
-
actionType: actionTypeResolver,
|
|
7739
|
-
action: actionKeyResolver,
|
|
7740
|
-
connection: connectionIdResolver,
|
|
7741
|
-
inputField: inputFieldKeyResolver,
|
|
7742
|
-
inputs: inputsAllOptionalResolver
|
|
7743
|
-
},
|
|
7744
|
-
handler: async ({
|
|
7745
|
-
sdk: sdk2,
|
|
7746
|
-
options
|
|
7747
|
-
}) => {
|
|
7748
|
-
const { api, getVersionedImplementationId } = sdk2.context;
|
|
7749
|
-
const appKey = "app" in options ? options.app : options.appKey;
|
|
7750
|
-
const actionKey = "action" in options ? options.action : options.actionKey;
|
|
7751
|
-
const inputFieldKey = "inputField" in options ? options.inputField : options.inputFieldKey;
|
|
7752
|
-
const {
|
|
7753
|
-
actionType,
|
|
7754
|
-
connection,
|
|
7755
|
-
connectionId,
|
|
7756
|
-
authenticationId,
|
|
7757
|
-
inputs,
|
|
7758
|
-
page,
|
|
7759
|
-
cursor
|
|
7760
|
-
} = options;
|
|
7761
|
-
const resolvedConnectionId = await resolveConnectionId({
|
|
7762
|
-
connection,
|
|
7763
|
-
connectionId,
|
|
7764
|
-
authenticationId,
|
|
7765
|
-
resolveConnection: sdk2.context.resolveConnection
|
|
7766
|
-
});
|
|
7767
|
-
const selectedApi = await getVersionedImplementationId(appKey);
|
|
7768
|
-
if (!selectedApi) {
|
|
7769
|
-
throw new ZapierConfigurationError(
|
|
7770
|
-
"No current_implementation_id found for app",
|
|
7771
|
-
{ configType: "current_implementation_id" }
|
|
7772
|
-
);
|
|
7773
|
-
}
|
|
7774
|
-
setMethodMetadata({
|
|
7775
|
-
selectedApi,
|
|
7776
|
-
operationType: actionType,
|
|
7777
|
-
operationKey: actionKey
|
|
7778
|
-
});
|
|
7779
|
-
const { data: action } = await sdk2.getAction({
|
|
7780
|
-
app: appKey,
|
|
7781
|
-
actionType,
|
|
7782
|
-
action: actionKey
|
|
7783
|
-
});
|
|
7784
|
-
const needsData = await fetchImplementationNeeds({
|
|
7785
|
-
api,
|
|
7786
|
-
selectedApi,
|
|
7787
|
-
action: action.key,
|
|
7788
|
-
actionType,
|
|
7789
|
-
connectionId: resolvedConnectionId ?? null,
|
|
7790
|
-
inputs
|
|
7791
|
-
});
|
|
7792
|
-
const targetNeed = needsData.needs?.find(
|
|
7793
|
-
(need) => need.key === inputFieldKey
|
|
7794
|
-
);
|
|
7795
|
-
if (targetNeed?.choices && targetNeed.choices.length > 0) {
|
|
7796
|
-
return {
|
|
7797
|
-
data: targetNeed.choices.map(
|
|
7798
|
-
transformNeedChoicesToInputFieldChoiceItem
|
|
7799
|
-
)
|
|
7800
|
-
};
|
|
7984
|
+
// src/plugins/deprecated/inputFields.ts
|
|
7985
|
+
var listInputFieldsDeprecatedPlugin = definePlugin(
|
|
7986
|
+
(sdk) => ({
|
|
7987
|
+
listInputFields: sdk.listActionInputFields,
|
|
7988
|
+
context: {
|
|
7989
|
+
meta: {
|
|
7990
|
+
listInputFields: {
|
|
7991
|
+
categories: ["action", "deprecated"],
|
|
7992
|
+
type: "list",
|
|
7993
|
+
itemType: "RootField",
|
|
7994
|
+
inputSchema: ListActionInputFieldsInputSchema,
|
|
7995
|
+
outputSchema: RootFieldItemSchema,
|
|
7996
|
+
defaultPageSize: DEFAULT_PAGE_SIZE
|
|
7997
|
+
}
|
|
7801
7998
|
}
|
|
7802
|
-
|
|
7803
|
-
|
|
7804
|
-
|
|
7805
|
-
|
|
7999
|
+
}
|
|
8000
|
+
})
|
|
8001
|
+
);
|
|
8002
|
+
var listInputFieldChoicesDeprecatedPlugin = definePlugin(
|
|
8003
|
+
(sdk) => ({
|
|
8004
|
+
listInputFieldChoices: sdk.listActionInputFieldChoices,
|
|
8005
|
+
context: {
|
|
8006
|
+
meta: {
|
|
8007
|
+
listInputFieldChoices: {
|
|
8008
|
+
categories: ["action", "deprecated"],
|
|
8009
|
+
type: "list",
|
|
8010
|
+
itemType: "InputFieldChoiceItem",
|
|
8011
|
+
inputSchema: ListActionInputFieldChoicesInputSchema,
|
|
8012
|
+
outputSchema: InputFieldChoiceItemSchema,
|
|
8013
|
+
defaultPageSize: DEFAULT_PAGE_SIZE
|
|
8014
|
+
}
|
|
7806
8015
|
}
|
|
7807
|
-
|
|
7808
|
-
|
|
7809
|
-
|
|
7810
|
-
|
|
7811
|
-
|
|
7812
|
-
|
|
7813
|
-
|
|
7814
|
-
|
|
7815
|
-
|
|
7816
|
-
|
|
7817
|
-
|
|
7818
|
-
|
|
7819
|
-
let nextCursor;
|
|
7820
|
-
if (choicesData.next_page != null) {
|
|
7821
|
-
nextCursor = choicesData.next_page.toString();
|
|
7822
|
-
} else if (choicesData.links?.next) {
|
|
7823
|
-
try {
|
|
7824
|
-
const nextUrl = new URL(choicesData.links.next);
|
|
7825
|
-
const nextPage = nextUrl.searchParams.get("page");
|
|
7826
|
-
if (nextPage) {
|
|
7827
|
-
nextCursor = nextPage;
|
|
7828
|
-
}
|
|
7829
|
-
} catch {
|
|
8016
|
+
}
|
|
8017
|
+
})
|
|
8018
|
+
);
|
|
8019
|
+
var getInputFieldsSchemaDeprecatedPlugin = definePlugin(
|
|
8020
|
+
(sdk) => ({
|
|
8021
|
+
getInputFieldsSchema: sdk.getActionInputFieldsSchema,
|
|
8022
|
+
context: {
|
|
8023
|
+
meta: {
|
|
8024
|
+
getInputFieldsSchema: {
|
|
8025
|
+
categories: ["action", "deprecated"],
|
|
8026
|
+
type: "function",
|
|
8027
|
+
inputSchema: GetActionInputFieldsSchemaInputSchema
|
|
7830
8028
|
}
|
|
7831
8029
|
}
|
|
7832
|
-
return { data: choices, nextCursor };
|
|
7833
8030
|
}
|
|
7834
8031
|
})
|
|
7835
8032
|
);
|
|
@@ -8482,7 +8679,7 @@ function buildSdk(properties, context) {
|
|
|
8482
8679
|
}
|
|
8483
8680
|
return registryCache.get(cacheKey);
|
|
8484
8681
|
},
|
|
8485
|
-
addPlugin(plugin) {
|
|
8682
|
+
addPlugin(plugin, options) {
|
|
8486
8683
|
const pluginResult = plugin({
|
|
8487
8684
|
...properties,
|
|
8488
8685
|
context: frozenContext
|
|
@@ -8499,10 +8696,10 @@ function buildSdk(properties, context) {
|
|
|
8499
8696
|
for (const key of Object.keys(pluginContextRest)) {
|
|
8500
8697
|
if (key in existingContext) collisions.push(`context.${key}`);
|
|
8501
8698
|
}
|
|
8502
|
-
if (collisions.length > 0) {
|
|
8699
|
+
if (collisions.length > 0 && !options?.override) {
|
|
8503
8700
|
const name = plugin.name || "anonymous plugin";
|
|
8504
8701
|
console.warn(
|
|
8505
|
-
`[zapier-sdk] Skipping "${name}" \u2014 duplicate registration of: ${collisions.join(", ")}. If the duplicate is intentional, wrap with composePlugins(...). Otherwise rename the method or remove the duplicate.`
|
|
8702
|
+
`[zapier-sdk] Skipping "${name}" \u2014 duplicate registration of: ${collisions.join(", ")}. If the duplicate is intentional, pass { override: true } to addPlugin or wrap with composePlugins(...). Otherwise rename the method or remove the duplicate.`
|
|
8506
8703
|
);
|
|
8507
8704
|
return buildSdk(properties, context);
|
|
8508
8705
|
}
|
|
@@ -8527,7 +8724,7 @@ function createZapierSdkWithoutRegistry(options = {}) {
|
|
|
8527
8724
|
return createZapierSdk(options);
|
|
8528
8725
|
}
|
|
8529
8726
|
function createZapierSdk(options = {}) {
|
|
8530
|
-
return createSdk().addPlugin(createOptionsPlugin(options)).addPlugin(eventEmissionPlugin).addPlugin(apiPlugin).addPlugin(manifestPlugin).addPlugin(capabilitiesPlugin).addPlugin(connectionsPlugin).addPlugin(listAppsPlugin).addPlugin(getAppPlugin).addPlugin(listActionsPlugin).addPlugin(getActionPlugin).addPlugin(
|
|
8727
|
+
return createSdk().addPlugin(createOptionsPlugin(options)).addPlugin(eventEmissionPlugin).addPlugin(apiPlugin).addPlugin(manifestPlugin).addPlugin(capabilitiesPlugin).addPlugin(connectionsPlugin).addPlugin(listAppsPlugin).addPlugin(getAppPlugin).addPlugin(listActionsPlugin).addPlugin(getActionPlugin).addPlugin(listActionInputFieldsPlugin).addPlugin(getActionInputFieldsSchemaPlugin).addPlugin(listActionInputFieldChoicesPlugin).addPlugin(listInputFieldsDeprecatedPlugin).addPlugin(getInputFieldsSchemaDeprecatedPlugin).addPlugin(listInputFieldChoicesDeprecatedPlugin).addPlugin(runActionPlugin).addPlugin(listConnectionsPlugin).addPlugin(getConnectionPlugin).addPlugin(findFirstConnectionPlugin).addPlugin(findUniqueConnectionPlugin).addPlugin(listAuthenticationsPlugin).addPlugin(getAuthenticationPlugin).addPlugin(findFirstAuthenticationPlugin).addPlugin(findUniqueAuthenticationPlugin).addPlugin(listClientCredentialsPlugin).addPlugin(createClientCredentialsPlugin).addPlugin(deleteClientCredentialsPlugin).addPlugin(fetchPlugin).addPlugin(requestPlugin).addPlugin(listTablesPlugin).addPlugin(getTablePlugin).addPlugin(deleteTablePlugin).addPlugin(createTablePlugin).addPlugin(listTableFieldsPlugin).addPlugin(createTableFieldsPlugin).addPlugin(deleteTableFieldsPlugin).addPlugin(getTableRecordPlugin).addPlugin(listTableRecordsPlugin).addPlugin(createTableRecordsPlugin).addPlugin(deleteTableRecordsPlugin).addPlugin(updateTableRecordsPlugin).addPlugin(appsPlugin).addPlugin(getProfilePlugin);
|
|
8531
8728
|
}
|
|
8532
8729
|
var BaseSdkOptionsSchema = zod.z.object({
|
|
8533
8730
|
credentials: CredentialsSchema.optional().describe(
|
|
@@ -8547,16 +8744,13 @@ var BaseSdkOptionsSchema = zod.z.object({
|
|
|
8547
8744
|
* Default is 60000 (60 seconds).
|
|
8548
8745
|
*/
|
|
8549
8746
|
maxNetworkRetryDelayMs: zod.z.number().optional().describe("Max delay in ms to wait for retry (default: 60000).").meta({ valueHint: "ms" }),
|
|
8550
|
-
|
|
8551
|
-
"Whether this session is interactive (user can visit approval URLs). Defaults to ZAPIER_IS_INTERACTIVE env var."
|
|
8552
|
-
).meta({ internal: true }),
|
|
8553
|
-
approvalTimeoutMs: zod.z.number().optional().describe("Timeout in ms for approval polling. Default: 600000 (10 min).").meta({ valueHint: "ms", internal: true }),
|
|
8747
|
+
approvalTimeoutMs: zod.z.number().optional().describe("Timeout in ms for approval polling. Default: 600000 (10 min).").meta({ valueHint: "ms" }),
|
|
8554
8748
|
maxApprovalRetries: zod.z.number().optional().describe(
|
|
8555
8749
|
"Maximum number of sequential approval rounds per request (one per gating policy) before giving up. Default: 2."
|
|
8556
|
-
)
|
|
8557
|
-
approvalMode: zod.z.enum(["poll", "
|
|
8558
|
-
'Approval flow behavior. "poll" opens browser and
|
|
8559
|
-
)
|
|
8750
|
+
),
|
|
8751
|
+
approvalMode: zod.z.enum(["disabled", "poll", "throw"]).optional().describe(
|
|
8752
|
+
'Approval flow behavior. "disabled" (default) throws a ZapierApprovalError on approval-required responses without creating an approval. "poll" creates the approval, opens it in a browser, polls until resolved, and retries the original request. "throw" creates the approval and throws a ZapierApprovalError with the approval URL so the caller can surface it. Defaults to the ZAPIER_APPROVAL_MODE env var, then "disabled".'
|
|
8753
|
+
),
|
|
8560
8754
|
// Internal
|
|
8561
8755
|
manifestPath: zod.z.string().optional().describe("Path to a .zapierrc manifest file for app version locking.").meta({ internal: true }),
|
|
8562
8756
|
manifest: zod.z.custom().optional().describe("Manifest for app version locking.").meta({ internal: true }),
|
|
@@ -8610,6 +8804,9 @@ exports.DebugPropertySchema = DebugPropertySchema;
|
|
|
8610
8804
|
exports.FieldsPropertySchema = FieldsPropertySchema;
|
|
8611
8805
|
exports.InputFieldPropertySchema = InputFieldPropertySchema;
|
|
8612
8806
|
exports.InputsPropertySchema = InputsPropertySchema;
|
|
8807
|
+
exports.LeaseLimitPropertySchema = LeaseLimitPropertySchema;
|
|
8808
|
+
exports.LeasePropertySchema = LeasePropertySchema;
|
|
8809
|
+
exports.LeaseSecondsPropertySchema = LeaseSecondsPropertySchema;
|
|
8613
8810
|
exports.LimitPropertySchema = LimitPropertySchema;
|
|
8614
8811
|
exports.MAX_PAGE_LIMIT = MAX_PAGE_LIMIT;
|
|
8615
8812
|
exports.OffsetPropertySchema = OffsetPropertySchema;
|
|
@@ -8623,9 +8820,12 @@ exports.RelayRequestSchema = RelayRequestSchema;
|
|
|
8623
8820
|
exports.ResolvedCredentialsSchema = ResolvedCredentialsSchema;
|
|
8624
8821
|
exports.TablePropertySchema = TablePropertySchema;
|
|
8625
8822
|
exports.TablesPropertySchema = TablesPropertySchema;
|
|
8823
|
+
exports.TriggerInboxNamePropertySchema = TriggerInboxNamePropertySchema;
|
|
8824
|
+
exports.TriggerInboxPropertySchema = TriggerInboxPropertySchema;
|
|
8626
8825
|
exports.ZAPIER_BASE_URL = ZAPIER_BASE_URL;
|
|
8627
8826
|
exports.ZAPIER_MAX_NETWORK_RETRIES = ZAPIER_MAX_NETWORK_RETRIES;
|
|
8628
8827
|
exports.ZAPIER_MAX_NETWORK_RETRY_DELAY_MS = ZAPIER_MAX_NETWORK_RETRY_DELAY_MS;
|
|
8828
|
+
exports.ZapierAbortDrainSignal = ZapierAbortDrainSignal;
|
|
8629
8829
|
exports.ZapierActionError = ZapierActionError;
|
|
8630
8830
|
exports.ZapierApiError = ZapierApiError;
|
|
8631
8831
|
exports.ZapierAppNotFoundError = ZapierAppNotFoundError;
|
|
@@ -8633,11 +8833,14 @@ exports.ZapierApprovalError = ZapierApprovalError;
|
|
|
8633
8833
|
exports.ZapierAuthenticationError = ZapierAuthenticationError;
|
|
8634
8834
|
exports.ZapierBundleError = ZapierBundleError;
|
|
8635
8835
|
exports.ZapierConfigurationError = ZapierConfigurationError;
|
|
8836
|
+
exports.ZapierConflictError = ZapierConflictError;
|
|
8636
8837
|
exports.ZapierError = ZapierError;
|
|
8637
8838
|
exports.ZapierNotFoundError = ZapierNotFoundError;
|
|
8638
8839
|
exports.ZapierRateLimitError = ZapierRateLimitError;
|
|
8639
8840
|
exports.ZapierRelayError = ZapierRelayError;
|
|
8841
|
+
exports.ZapierReleaseTriggerMessageSignal = ZapierReleaseTriggerMessageSignal;
|
|
8640
8842
|
exports.ZapierResourceNotFoundError = ZapierResourceNotFoundError;
|
|
8843
|
+
exports.ZapierSignal = ZapierSignal;
|
|
8641
8844
|
exports.ZapierTimeoutError = ZapierTimeoutError;
|
|
8642
8845
|
exports.ZapierUnknownError = ZapierUnknownError;
|
|
8643
8846
|
exports.ZapierValidationError = ZapierValidationError;
|
|
@@ -8685,6 +8888,7 @@ exports.findManifestEntry = findManifestEntry;
|
|
|
8685
8888
|
exports.findUniqueConnectionPlugin = findUniqueConnectionPlugin;
|
|
8686
8889
|
exports.formatErrorMessage = formatErrorMessage;
|
|
8687
8890
|
exports.generateEventId = generateEventId;
|
|
8891
|
+
exports.getActionInputFieldsSchemaPlugin = getActionInputFieldsSchemaPlugin;
|
|
8688
8892
|
exports.getActionPlugin = getActionPlugin;
|
|
8689
8893
|
exports.getAppPlugin = getAppPlugin;
|
|
8690
8894
|
exports.getBaseUrlFromCredentials = getBaseUrlFromCredentials;
|
|
@@ -8703,7 +8907,6 @@ exports.getTablePlugin = getTablePlugin;
|
|
|
8703
8907
|
exports.getTableRecordPlugin = getTableRecordPlugin;
|
|
8704
8908
|
exports.getTokenFromCliLogin = getTokenFromCliLogin;
|
|
8705
8909
|
exports.getZapierApprovalMode = getZapierApprovalMode;
|
|
8706
|
-
exports.getZapierIsInteractive = getZapierIsInteractive;
|
|
8707
8910
|
exports.getZapierSdkService = getZapierSdkService;
|
|
8708
8911
|
exports.injectCliLogin = injectCliLogin;
|
|
8709
8912
|
exports.inputFieldKeyResolver = inputFieldKeyResolver;
|
|
@@ -8718,11 +8921,12 @@ exports.isCredentialsFunction = isCredentialsFunction;
|
|
|
8718
8921
|
exports.isCredentialsObject = isCredentialsObject;
|
|
8719
8922
|
exports.isPkceCredentials = isPkceCredentials;
|
|
8720
8923
|
exports.isPositional = isPositional;
|
|
8924
|
+
exports.listActionInputFieldChoicesPlugin = listActionInputFieldChoicesPlugin;
|
|
8925
|
+
exports.listActionInputFieldsPlugin = listActionInputFieldsPlugin;
|
|
8721
8926
|
exports.listActionsPlugin = listActionsPlugin;
|
|
8722
8927
|
exports.listAppsPlugin = listAppsPlugin;
|
|
8723
8928
|
exports.listClientCredentialsPlugin = listClientCredentialsPlugin;
|
|
8724
8929
|
exports.listConnectionsPlugin = listConnectionsPlugin;
|
|
8725
|
-
exports.listInputFieldsPlugin = listInputFieldsPlugin;
|
|
8726
8930
|
exports.listTableFieldsPlugin = listTableFieldsPlugin;
|
|
8727
8931
|
exports.listTableRecordsPlugin = listTableRecordsPlugin;
|
|
8728
8932
|
exports.listTablesPlugin = listTablesPlugin;
|
|
@@ -8749,4 +8953,5 @@ exports.tableSortResolver = tableSortResolver;
|
|
|
8749
8953
|
exports.tableUpdateRecordsResolver = tableUpdateRecordsResolver;
|
|
8750
8954
|
exports.toSnakeCase = toSnakeCase;
|
|
8751
8955
|
exports.toTitleCase = toTitleCase;
|
|
8956
|
+
exports.triggerInboxResolver = triggerInboxResolver;
|
|
8752
8957
|
exports.updateTableRecordsPlugin = updateTableRecordsPlugin;
|