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