@zapier/zapier-sdk 0.93.0 → 0.94.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +20 -0
- package/README.md +70 -0
- package/dist/{chunk-S2WSKNCP.cjs → chunk-7NCOFRA6.cjs} +1152 -1006
- package/dist/{chunk-DSWOSGEW.mjs → chunk-XETAS26U.mjs} +1150 -1007
- package/dist/experimental.cjs +389 -377
- package/dist/experimental.d.mts +149 -7
- package/dist/experimental.d.ts +149 -7
- package/dist/experimental.mjs +2 -2
- package/dist/{index-BUPBfgvQ.d.mts → index-DsMsmowr.d.mts} +304 -11
- package/dist/{index-BUPBfgvQ.d.ts → index-DsMsmowr.d.ts} +304 -11
- package/dist/index.cjs +285 -273
- package/dist/index.d.mts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.mjs +1 -1
- package/package.json +1 -1
|
@@ -4219,6 +4219,7 @@ function getZapierSdkService() {
|
|
|
4219
4219
|
var MAX_PAGE_LIMIT = 1e4;
|
|
4220
4220
|
var DEFAULT_PAGE_SIZE = 100;
|
|
4221
4221
|
var DEFAULT_ACTION_TIMEOUT_MILLISECONDS = 18e4;
|
|
4222
|
+
var ACTION_RUNS_PATH = "/zapier/api/actions/v1/runs";
|
|
4222
4223
|
function parseIntEnvVar(name) {
|
|
4223
4224
|
const value = globalThis.process?.env?.[name];
|
|
4224
4225
|
if (value === void 0) return void 0;
|
|
@@ -4512,6 +4513,7 @@ var ZapierRelayError = class extends ZapierError {
|
|
|
4512
4513
|
super(message, options);
|
|
4513
4514
|
this.name = "ZapierRelayError";
|
|
4514
4515
|
this.code = "ZAPIER_RELAY_ERROR";
|
|
4516
|
+
if (options.retryable !== void 0) this.retryable = options.retryable;
|
|
4515
4517
|
}
|
|
4516
4518
|
};
|
|
4517
4519
|
function hasZapierErrorCode(value, code) {
|
|
@@ -6192,7 +6194,7 @@ function parseDeprecationDate(value) {
|
|
|
6192
6194
|
}
|
|
6193
6195
|
|
|
6194
6196
|
// src/sdk-version.ts
|
|
6195
|
-
var SDK_VERSION = (typeof process !== "undefined" && process.env ? "0.
|
|
6197
|
+
var SDK_VERSION = (typeof process !== "undefined" && process.env ? "0.94.1" : void 0) || "unknown";
|
|
6196
6198
|
|
|
6197
6199
|
// src/utils/open-url.ts
|
|
6198
6200
|
var nodePrefix = "node:";
|
|
@@ -7064,7 +7066,7 @@ var ZapierApiClient = class {
|
|
|
7064
7066
|
requiredScopes: options.requiredScopes
|
|
7065
7067
|
});
|
|
7066
7068
|
if (typeof result === "string") {
|
|
7067
|
-
if (result === "" && (method === "DELETE" || response.status === 204)) {
|
|
7069
|
+
if (result === "" && (method === "DELETE" || response.status === 204 || response.status === 202)) {
|
|
7068
7070
|
return void 0;
|
|
7069
7071
|
}
|
|
7070
7072
|
throw new ZapierValidationError(
|
|
@@ -8460,8 +8462,20 @@ var fetchPlugin = defineMethod({
|
|
|
8460
8462
|
});
|
|
8461
8463
|
const relayError = result.headers.get("x-relay-error");
|
|
8462
8464
|
if (relayError) {
|
|
8465
|
+
const relayErrorCode = result.headers.get("x-relay-error-code");
|
|
8466
|
+
const retryableHeader = result.headers.get("x-relay-error-retryable");
|
|
8467
|
+
const retryable = retryableHeader === "true" ? true : retryableHeader === "false" ? false : void 0;
|
|
8463
8468
|
throw new ZapierRelayError(relayError, {
|
|
8464
|
-
statusCode: result.status
|
|
8469
|
+
statusCode: result.status,
|
|
8470
|
+
retryable,
|
|
8471
|
+
errors: relayErrorCode ? [
|
|
8472
|
+
{
|
|
8473
|
+
status: result.status,
|
|
8474
|
+
code: relayErrorCode,
|
|
8475
|
+
title: "API Proxy Error",
|
|
8476
|
+
detail: relayError
|
|
8477
|
+
}
|
|
8478
|
+
] : void 0
|
|
8465
8479
|
});
|
|
8466
8480
|
}
|
|
8467
8481
|
return result;
|
|
@@ -8538,538 +8552,166 @@ var actionResultItemFormatter = defineFormatter({
|
|
|
8538
8552
|
};
|
|
8539
8553
|
}
|
|
8540
8554
|
});
|
|
8541
|
-
|
|
8542
|
-
|
|
8543
|
-
|
|
8544
|
-
|
|
8545
|
-
|
|
8546
|
-
|
|
8547
|
-
|
|
8548
|
-
|
|
8549
|
-
|
|
8550
|
-
|
|
8551
|
-
|
|
8552
|
-
|
|
8553
|
-
|
|
8554
|
-
|
|
8555
|
-
|
|
8556
|
-
|
|
8557
|
-
|
|
8558
|
-
|
|
8559
|
-
|
|
8560
|
-
|
|
8561
|
-
|
|
8562
|
-
|
|
8563
|
-
|
|
8564
|
-
|
|
8565
|
-
|
|
8566
|
-
}
|
|
8567
|
-
|
|
8568
|
-
|
|
8569
|
-
|
|
8570
|
-
|
|
8571
|
-
|
|
8572
|
-
|
|
8573
|
-
)
|
|
8574
|
-
|
|
8575
|
-
|
|
8576
|
-
|
|
8577
|
-
|
|
8578
|
-
|
|
8579
|
-
|
|
8580
|
-
|
|
8555
|
+
|
|
8556
|
+
// src/resolvers/appKey.ts
|
|
8557
|
+
var getAppRef = declareMethod({ id: "getApp" });
|
|
8558
|
+
var listAppsRef = declareMethod({ id: "listApps" });
|
|
8559
|
+
var appKeyResolver = defineResolver({
|
|
8560
|
+
imports: [getAppRef, listAppsRef],
|
|
8561
|
+
inputType: "search",
|
|
8562
|
+
placeholder: "e.g., 'slack' or 'SlackCLIAPI' or 'mail'",
|
|
8563
|
+
// Try the typed string as an exact app locator (getApp accepts slug, key, or
|
|
8564
|
+
// implementation id). On a hit, resolve with the input as-is and skip the
|
|
8565
|
+
// picker — every variant the user could type is already a valid value
|
|
8566
|
+
// wherever `app` is required, so no canonicalization is needed. A 404 falls
|
|
8567
|
+
// through to the search list; any other error (auth, network, rate-limit)
|
|
8568
|
+
// propagates. ZapierAppNotFoundError and ZapierNotFoundError are independent
|
|
8569
|
+
// siblings, so both are checked.
|
|
8570
|
+
tryResolveFromSearch: async ({ imports, search }) => {
|
|
8571
|
+
if (!search) return null;
|
|
8572
|
+
try {
|
|
8573
|
+
await imports.getApp({ app: search });
|
|
8574
|
+
return { resolvedValue: search };
|
|
8575
|
+
} catch (err) {
|
|
8576
|
+
if (!isZapierAppNotFoundError(err) && !isZapierNotFoundError(err)) {
|
|
8577
|
+
throw err;
|
|
8578
|
+
}
|
|
8579
|
+
return null;
|
|
8580
|
+
}
|
|
8581
|
+
},
|
|
8582
|
+
listItems: ({
|
|
8583
|
+
imports,
|
|
8584
|
+
search,
|
|
8585
|
+
cursor
|
|
8586
|
+
}) => imports.listApps({ search, cursor }),
|
|
8587
|
+
prompt: ({ items }) => ({
|
|
8588
|
+
type: "list",
|
|
8589
|
+
message: "Select app:",
|
|
8590
|
+
choices: items.map((app) => ({
|
|
8591
|
+
label: app.title || app.key,
|
|
8592
|
+
hint: app.title ? getAppKeyList(app) : void 0,
|
|
8593
|
+
value: app.key
|
|
8594
|
+
}))
|
|
8595
|
+
})
|
|
8581
8596
|
});
|
|
8582
|
-
|
|
8583
|
-
|
|
8584
|
-
|
|
8585
|
-
|
|
8586
|
-
|
|
8587
|
-
|
|
8588
|
-
|
|
8589
|
-
|
|
8590
|
-
|
|
8591
|
-
|
|
8592
|
-
|
|
8593
|
-
|
|
8594
|
-
|
|
8595
|
-
|
|
8596
|
-
|
|
8597
|
-
|
|
8598
|
-
|
|
8599
|
-
|
|
8600
|
-
|
|
8601
|
-
|
|
8602
|
-
|
|
8603
|
-
searchfill: zod.z.string().optional(),
|
|
8604
|
-
send_in_json: zod.z.boolean().optional(),
|
|
8605
|
-
regex: zod.z.string().optional(),
|
|
8606
|
-
type: zod.z.enum([
|
|
8607
|
-
"integer",
|
|
8608
|
-
"string",
|
|
8609
|
-
"text",
|
|
8610
|
-
"datetime",
|
|
8611
|
-
"boolean",
|
|
8612
|
-
"file",
|
|
8613
|
-
"decimal",
|
|
8614
|
-
"copy",
|
|
8615
|
-
"password",
|
|
8616
|
-
"dict",
|
|
8617
|
-
"code",
|
|
8618
|
-
"filter",
|
|
8619
|
-
"json"
|
|
8620
|
-
]).optional(),
|
|
8621
|
-
list: zod.z.boolean().optional()
|
|
8597
|
+
|
|
8598
|
+
// src/resolvers/actionType.ts
|
|
8599
|
+
var listActionsRef = declareMethod({ id: "listActions" });
|
|
8600
|
+
var actionTypeResolver = defineResolver({
|
|
8601
|
+
imports: [listActionsRef],
|
|
8602
|
+
requireParameters: ["app"],
|
|
8603
|
+
listItems: async ({
|
|
8604
|
+
imports,
|
|
8605
|
+
input
|
|
8606
|
+
}) => {
|
|
8607
|
+
const types = /* @__PURE__ */ new Set();
|
|
8608
|
+
for await (const action of imports.listActions({ app: input.app }).items()) {
|
|
8609
|
+
types.add(action.action_type);
|
|
8610
|
+
}
|
|
8611
|
+
return { data: [...types].map((type) => ({ key: type, name: type })) };
|
|
8612
|
+
},
|
|
8613
|
+
prompt: ({ items }) => ({
|
|
8614
|
+
type: "list",
|
|
8615
|
+
message: "Select action type:",
|
|
8616
|
+
choices: items.map((type) => ({ label: type.name, value: type.key }))
|
|
8617
|
+
})
|
|
8622
8618
|
});
|
|
8623
|
-
|
|
8624
|
-
|
|
8619
|
+
|
|
8620
|
+
// src/resolvers/actionKey.ts
|
|
8621
|
+
var listActionsRef2 = declareMethod({ id: "listActions" });
|
|
8622
|
+
var actionKeyResolver = defineResolver({
|
|
8623
|
+
imports: [listActionsRef2],
|
|
8624
|
+
requireParameters: ["app", "actionType"],
|
|
8625
|
+
listItems: async ({
|
|
8626
|
+
imports,
|
|
8627
|
+
input,
|
|
8628
|
+
cursor
|
|
8629
|
+
}) => {
|
|
8630
|
+
const page = await imports.listActions({ app: input.app, cursor });
|
|
8631
|
+
return {
|
|
8632
|
+
data: page.data.filter(
|
|
8633
|
+
(action) => action.action_type === input.actionType && !action.is_hidden
|
|
8634
|
+
),
|
|
8635
|
+
nextCursor: page.nextCursor
|
|
8636
|
+
};
|
|
8637
|
+
},
|
|
8638
|
+
prompt: ({ items }) => ({
|
|
8639
|
+
type: "list",
|
|
8640
|
+
message: "Select action:",
|
|
8641
|
+
choices: items.map((action) => ({
|
|
8642
|
+
label: action.title || action.name || action.key,
|
|
8643
|
+
hint: action.description || void 0,
|
|
8644
|
+
value: action.key
|
|
8645
|
+
}))
|
|
8646
|
+
})
|
|
8625
8647
|
});
|
|
8626
|
-
|
|
8627
|
-
|
|
8628
|
-
|
|
8629
|
-
|
|
8630
|
-
|
|
8631
|
-
|
|
8632
|
-
|
|
8633
|
-
|
|
8634
|
-
|
|
8635
|
-
|
|
8636
|
-
|
|
8637
|
-
|
|
8638
|
-
|
|
8639
|
-
|
|
8640
|
-
|
|
8641
|
-
|
|
8642
|
-
|
|
8643
|
-
|
|
8644
|
-
|
|
8645
|
-
|
|
8646
|
-
|
|
8647
|
-
|
|
8648
|
-
|
|
8649
|
-
|
|
8650
|
-
|
|
8651
|
-
|
|
8652
|
-
|
|
8653
|
-
|
|
8654
|
-
|
|
8655
|
-
|
|
8656
|
-
|
|
8657
|
-
|
|
8658
|
-
|
|
8659
|
-
|
|
8660
|
-
|
|
8661
|
-
|
|
8662
|
-
|
|
8663
|
-
|
|
8664
|
-
|
|
8665
|
-
|
|
8666
|
-
|
|
8667
|
-
|
|
8668
|
-
|
|
8669
|
-
|
|
8670
|
-
|
|
8671
|
-
|
|
8672
|
-
|
|
8673
|
-
|
|
8674
|
-
}
|
|
8675
|
-
|
|
8676
|
-
|
|
8677
|
-
|
|
8678
|
-
|
|
8679
|
-
|
|
8680
|
-
|
|
8681
|
-
|
|
8682
|
-
|
|
8683
|
-
|
|
8684
|
-
|
|
8685
|
-
|
|
8686
|
-
|
|
8687
|
-
|
|
8688
|
-
|
|
8689
|
-
|
|
8690
|
-
}
|
|
8691
|
-
|
|
8692
|
-
|
|
8693
|
-
public_id: zod.z.string().optional(),
|
|
8694
|
-
code: zod.z.string(),
|
|
8695
|
-
user_id: zod.z.number(),
|
|
8696
|
-
auto_provisioned: zod.z.boolean(),
|
|
8697
|
-
first_name: zod.z.string(),
|
|
8698
|
-
last_name: zod.z.string(),
|
|
8699
|
-
username: zod.z.string(),
|
|
8700
|
-
personas: zod.z.string(),
|
|
8701
|
-
user_generated_personas: zod.z.string(),
|
|
8702
|
-
last_login: zod.z.string(),
|
|
8703
|
-
email: zod.z.string(),
|
|
8704
|
-
email_hash: zod.z.string(),
|
|
8705
|
-
email_confirmed: zod.z.boolean(),
|
|
8706
|
-
timezone: zod.z.string(),
|
|
8707
|
-
photo_url: zod.z.string(),
|
|
8708
|
-
has_seen_notifications: zod.z.record(zod.z.string(), zod.z.boolean().nullable()),
|
|
8709
|
-
signup: zod.z.string(),
|
|
8710
|
-
since_signup: zod.z.string(),
|
|
8711
|
-
has_activated: zod.z.boolean(),
|
|
8712
|
-
enable_gz_creator: zod.z.boolean(),
|
|
8713
|
-
should_see_nps_survey: zod.z.boolean(),
|
|
8714
|
-
is_developer: zod.z.boolean(),
|
|
8715
|
-
is_expert: zod.z.boolean(),
|
|
8716
|
-
tos_agreement: zod.z.boolean(),
|
|
8717
|
-
should_renew_tos: zod.z.boolean(),
|
|
8718
|
-
is_gdpr_consented: zod.z.boolean(),
|
|
8719
|
-
disable_ssl_check: zod.z.boolean(),
|
|
8720
|
-
identity: zod.z.number(),
|
|
8721
|
-
summary_schedule: zod.z.string(),
|
|
8722
|
-
alert_triggers: zod.z.string(),
|
|
8723
|
-
alert_actions: zod.z.string(),
|
|
8724
|
-
is_staff: zod.z.boolean(),
|
|
8725
|
-
is_zt_reviewer: zod.z.boolean(),
|
|
8726
|
-
is_high_value: zod.z.boolean(),
|
|
8727
|
-
is_temporary: zod.z.boolean(),
|
|
8728
|
-
banner_message: zod.z.string(),
|
|
8729
|
-
enable_totp_2fa: zod.z.boolean(),
|
|
8730
|
-
viewed_help: zod.z.record(zod.z.string(), zod.z.boolean()),
|
|
8731
|
-
show_editor_migration_mesaging: zod.z.boolean(),
|
|
8732
|
-
switches: zod.z.record(zod.z.string(), zod.z.unknown()),
|
|
8733
|
-
organizations: zod.z.array(zod.z.record(zod.z.string(), zod.z.unknown()).nullable()),
|
|
8734
|
-
primary_organization: zod.z.record(zod.z.string(), zod.z.unknown()).nullable(),
|
|
8735
|
-
has_active_zaps: zod.z.boolean(),
|
|
8736
|
-
has_google_sso: zod.z.boolean(),
|
|
8737
|
-
auth_realm: zod.z.string(),
|
|
8738
|
-
roles: zod.z.array(
|
|
8739
|
-
zod.z.object({
|
|
8740
|
-
account_id: zod.z.number(),
|
|
8741
|
-
role: zod.z.string()
|
|
8742
|
-
})
|
|
8743
|
-
)
|
|
8744
|
-
});
|
|
8745
|
-
zod.z.object({
|
|
8746
|
-
age_in_days: zod.z.string().optional(),
|
|
8747
|
-
api_docs_url: zod.z.string().nullable().optional(),
|
|
8748
|
-
app_profile_url: zod.z.string(),
|
|
8749
|
-
banner: zod.z.string().optional(),
|
|
8750
|
-
categories: zod.z.array(zod.z.string()).optional(),
|
|
8751
|
-
// Service category names
|
|
8752
|
-
canonical_id: zod.z.string().optional(),
|
|
8753
|
-
current_implementation_id: zod.z.string(),
|
|
8754
|
-
days_since_last_update: zod.z.string().optional(),
|
|
8755
|
-
description: zod.z.string(),
|
|
8756
|
-
external_url: zod.z.string(),
|
|
8757
|
-
hashtag: zod.z.string().optional(),
|
|
8758
|
-
id: zod.z.number().optional(),
|
|
8759
|
-
image: zod.z.string().optional(),
|
|
8760
|
-
images: zod.z.string().optional(),
|
|
8761
|
-
integration_overview_html: zod.z.string().nullable().optional(),
|
|
8762
|
-
internal_id: zod.z.string(),
|
|
8763
|
-
invite_url: zod.z.string().nullable().optional(),
|
|
8764
|
-
is_beta: zod.z.string().optional(),
|
|
8765
|
-
is_built_in: zod.z.string().optional(),
|
|
8766
|
-
is_featured: zod.z.string().optional(),
|
|
8767
|
-
is_premium: zod.z.boolean().optional(),
|
|
8768
|
-
is_public: zod.z.string().optional(),
|
|
8769
|
-
is_upcoming: zod.z.string().optional(),
|
|
8770
|
-
learn_more_url: zod.z.string(),
|
|
8771
|
-
name: zod.z.string(),
|
|
8772
|
-
popularity: zod.z.number(),
|
|
8773
|
-
primary_color: zod.z.string(),
|
|
8774
|
-
request_count: zod.z.string().optional(),
|
|
8775
|
-
slug: zod.z.string(),
|
|
8776
|
-
zap_usage_count: zod.z.number().nullable().optional()
|
|
8777
|
-
});
|
|
8778
|
-
var ServiceSchema = zod.z.object({
|
|
8779
|
-
id: zod.z.number().optional(),
|
|
8780
|
-
canonical_id: zod.z.string().optional(),
|
|
8781
|
-
current_implementation_id: zod.z.string(),
|
|
8782
|
-
name: zod.z.string(),
|
|
8783
|
-
slug: zod.z.string(),
|
|
8784
|
-
app_url: zod.z.string().optional(),
|
|
8785
|
-
learn_more_url: zod.z.string().optional(),
|
|
8786
|
-
description: zod.z.string(),
|
|
8787
|
-
primary_color: zod.z.string(),
|
|
8788
|
-
popularity: zod.z.number(),
|
|
8789
|
-
image: zod.z.string().optional(),
|
|
8790
|
-
images: zod.z.string().optional()
|
|
8791
|
-
});
|
|
8792
|
-
zod.z.object({
|
|
8793
|
-
results: zod.z.array(ServiceSchema),
|
|
8794
|
-
next: zod.z.string().nullable().optional(),
|
|
8795
|
-
previous: zod.z.string().nullable().optional()
|
|
8796
|
-
});
|
|
8797
|
-
zod.z.object({
|
|
8798
|
-
selected_api: zod.z.string(),
|
|
8799
|
-
action: zod.z.string(),
|
|
8800
|
-
type_of: zod.z.string(),
|
|
8801
|
-
authentication_id: zod.z.union([zod.z.string(), zod.z.number()]).optional(),
|
|
8802
|
-
params: zod.z.record(zod.z.string(), zod.z.unknown()).optional()
|
|
8803
|
-
});
|
|
8804
|
-
zod.z.object({
|
|
8805
|
-
success: zod.z.boolean(),
|
|
8806
|
-
needs: zod.z.array(NeedSchema).optional(),
|
|
8807
|
-
errors: zod.z.array(zod.z.string()).optional(),
|
|
8808
|
-
last_fetched_at: zod.z.string().optional(),
|
|
8809
|
-
schema: zod.z.record(zod.z.string(), zod.z.unknown()).optional()
|
|
8810
|
-
});
|
|
8811
|
-
var ImplementationSchema = zod.z.object({
|
|
8812
|
-
selected_api: zod.z.string(),
|
|
8813
|
-
app_id: zod.z.number().optional(),
|
|
8814
|
-
auth_type: zod.z.string().optional(),
|
|
8815
|
-
auth_fields: zod.z.string().optional(),
|
|
8816
|
-
actions: zod.z.array(ActionSchema).optional(),
|
|
8817
|
-
is_deprecated: zod.z.boolean().optional(),
|
|
8818
|
-
is_private_only: zod.z.boolean().optional(),
|
|
8819
|
-
is_invite_only: zod.z.boolean().optional(),
|
|
8820
|
-
is_beta: zod.z.boolean().optional().default(false),
|
|
8821
|
-
is_premium: zod.z.boolean().optional().default(false),
|
|
8822
|
-
is_hidden: zod.z.string().optional(),
|
|
8823
|
-
name: zod.z.string().optional(),
|
|
8824
|
-
slug: zod.z.string().optional(),
|
|
8825
|
-
images: zod.z.record(zod.z.string(), zod.z.string().nullable()).optional(),
|
|
8826
|
-
primary_color: zod.z.string().optional(),
|
|
8827
|
-
secondary_color: zod.z.string().optional(),
|
|
8828
|
-
current_implementation: zod.z.string().optional(),
|
|
8829
|
-
other_implementations: zod.z.string().optional()
|
|
8830
|
-
});
|
|
8831
|
-
zod.z.object({
|
|
8832
|
-
count: zod.z.number(),
|
|
8833
|
-
next: zod.z.string().nullable().optional(),
|
|
8834
|
-
previous: zod.z.string().nullable().optional(),
|
|
8835
|
-
results: zod.z.array(ImplementationSchema)
|
|
8836
|
-
});
|
|
8837
|
-
var NeedChoicesResponseMetaSchema = zod.z.object({
|
|
8838
|
-
page: zod.z.string().nullable().optional()
|
|
8839
|
-
});
|
|
8840
|
-
var NeedChoicesResponseLinksSchema = zod.z.object({
|
|
8841
|
-
next: zod.z.string().nullable().optional(),
|
|
8842
|
-
prev: zod.z.string().nullable().optional()
|
|
8843
|
-
});
|
|
8844
|
-
zod.z.object({
|
|
8845
|
-
selected_api: zod.z.string().optional().describe(
|
|
8846
|
-
"Something like `SlackAPI` (for Python apps) or `SplitwiseCLIAPI@1.0.0` (for CLI apps). Non-public apps are fine as long as the authed user can access them."
|
|
8847
|
-
),
|
|
8848
|
-
authentication_id: zod.z.union([zod.z.string(), zod.z.number()]).optional().describe(
|
|
8849
|
-
"If the app needs auth, provide an `authentication_id` that has the `selected_api` of the app you want to run. Can be any auth visible to the user (including shared)."
|
|
8850
|
-
),
|
|
8851
|
-
params: zod.z.record(zod.z.string(), zod.z.unknown()).optional().describe(
|
|
8852
|
-
"Object that matches the input the node would normally get. Has all the same keys/types as the `needs` of the action."
|
|
8853
|
-
),
|
|
8854
|
-
page: zod.z.number().optional().default(0),
|
|
8855
|
-
prefill: zod.z.string().optional().describe(
|
|
8856
|
-
"The prefill string to indicate what we're fetching choices for. Likely something like `spreadsheet.id.title`. Must be provided alongside `selected_api` if both `action_id` and `input_field_id` are not."
|
|
8857
|
-
),
|
|
8858
|
-
action_id: zod.z.string().optional().describe(
|
|
8859
|
-
"The id that will be used to lookup the Action for prefill lookup. If provided, `input_field_id` is required, else `prefill` must be provided."
|
|
8860
|
-
),
|
|
8861
|
-
input_field_id: zod.z.string().optional().describe(
|
|
8862
|
-
"The id (key) of the input field (Need) that dynamic choices are being retrieved for. If provided, `action_id` is required, else `prefill` must be provided."
|
|
8863
|
-
)
|
|
8864
|
-
});
|
|
8865
|
-
zod.z.object({
|
|
8866
|
-
success: zod.z.boolean(),
|
|
8867
|
-
choices: zod.z.array(NeedChoicesSchema).optional(),
|
|
8868
|
-
next_page: zod.z.number().optional(),
|
|
8869
|
-
errors: zod.z.array(zod.z.string()).optional(),
|
|
8870
|
-
meta: NeedChoicesResponseMetaSchema.optional(),
|
|
8871
|
-
links: NeedChoicesResponseLinksSchema.optional()
|
|
8872
|
-
});
|
|
8873
|
-
|
|
8874
|
-
// src/schemas/Action.ts
|
|
8875
|
-
var ActionItemSchema = ActionSchema.omit({
|
|
8876
|
-
type: true,
|
|
8877
|
-
name: true,
|
|
8878
|
-
selected_api: true
|
|
8879
|
-
}).extend({
|
|
8880
|
-
app_key: zod.z.string(),
|
|
8881
|
-
// App key without version (extracted from selected_api)
|
|
8882
|
-
app_version: zod.z.string().optional(),
|
|
8883
|
-
// Version extracted from selected_api
|
|
8884
|
-
action_type: ActionSchema.shape.type,
|
|
8885
|
-
// Mapped from original 'type' field
|
|
8886
|
-
title: zod.z.string(),
|
|
8887
|
-
// Mapped from original 'name' field
|
|
8888
|
-
type: zod.z.literal("action")
|
|
8889
|
-
// Fixed type identifier
|
|
8890
|
-
});
|
|
8891
|
-
|
|
8892
|
-
// src/formatters/action.ts
|
|
8893
|
-
function formatActionItem(item) {
|
|
8894
|
-
const details = [{ text: `Type: ${item.action_type}`, style: "accent" }];
|
|
8895
|
-
if (item.app_key) {
|
|
8896
|
-
details.push({ text: `App: ${item.app_key}`, style: "normal" });
|
|
8897
|
-
}
|
|
8898
|
-
if (item.description) {
|
|
8899
|
-
details.push({ text: item.description, style: "dim" });
|
|
8900
|
-
}
|
|
8901
|
-
return {
|
|
8902
|
-
title: item.title || item.key,
|
|
8903
|
-
// `hint` is the dumb secondary string shown after the title (the action key
|
|
8904
|
-
// and, when present, its id). Replaces the deprecated `key`/`id` fields.
|
|
8905
|
-
hint: [item.key, item.id].filter((v) => Boolean(v)),
|
|
8906
|
-
description: item.description,
|
|
8907
|
-
details
|
|
8908
|
-
};
|
|
8909
|
-
}
|
|
8910
|
-
var actionItemFormatter = defineFormatter({
|
|
8911
|
-
format: ({ item }) => formatActionItem(item)
|
|
8912
|
-
});
|
|
8913
|
-
|
|
8914
|
-
// src/resolvers/appKey.ts
|
|
8915
|
-
var getAppRef = declareMethod({ id: "getApp" });
|
|
8916
|
-
var listAppsRef = declareMethod({ id: "listApps" });
|
|
8917
|
-
var appKeyResolver = defineResolver({
|
|
8918
|
-
imports: [getAppRef, listAppsRef],
|
|
8919
|
-
inputType: "search",
|
|
8920
|
-
placeholder: "e.g., 'slack' or 'SlackCLIAPI' or 'mail'",
|
|
8921
|
-
// Try the typed string as an exact app locator (getApp accepts slug, key, or
|
|
8922
|
-
// implementation id). On a hit, resolve with the input as-is and skip the
|
|
8923
|
-
// picker — every variant the user could type is already a valid value
|
|
8924
|
-
// wherever `app` is required, so no canonicalization is needed. A 404 falls
|
|
8925
|
-
// through to the search list; any other error (auth, network, rate-limit)
|
|
8926
|
-
// propagates. ZapierAppNotFoundError and ZapierNotFoundError are independent
|
|
8927
|
-
// siblings, so both are checked.
|
|
8928
|
-
tryResolveFromSearch: async ({ imports, search }) => {
|
|
8929
|
-
if (!search) return null;
|
|
8930
|
-
try {
|
|
8931
|
-
await imports.getApp({ app: search });
|
|
8932
|
-
return { resolvedValue: search };
|
|
8933
|
-
} catch (err) {
|
|
8934
|
-
if (!isZapierAppNotFoundError(err) && !isZapierNotFoundError(err)) {
|
|
8935
|
-
throw err;
|
|
8936
|
-
}
|
|
8937
|
-
return null;
|
|
8938
|
-
}
|
|
8939
|
-
},
|
|
8940
|
-
listItems: ({
|
|
8941
|
-
imports,
|
|
8942
|
-
search,
|
|
8943
|
-
cursor
|
|
8944
|
-
}) => imports.listApps({ search, cursor }),
|
|
8945
|
-
prompt: ({ items }) => ({
|
|
8946
|
-
type: "list",
|
|
8947
|
-
message: "Select app:",
|
|
8948
|
-
choices: items.map((app) => ({
|
|
8949
|
-
label: app.title || app.key,
|
|
8950
|
-
hint: app.title ? getAppKeyList(app) : void 0,
|
|
8951
|
-
value: app.key
|
|
8952
|
-
}))
|
|
8953
|
-
})
|
|
8954
|
-
});
|
|
8955
|
-
|
|
8956
|
-
// src/resolvers/actionType.ts
|
|
8957
|
-
var listActionsRef = declareMethod({ id: "listActions" });
|
|
8958
|
-
var actionTypeResolver = defineResolver({
|
|
8959
|
-
imports: [listActionsRef],
|
|
8960
|
-
requireParameters: ["app"],
|
|
8961
|
-
listItems: async ({
|
|
8962
|
-
imports,
|
|
8963
|
-
input
|
|
8964
|
-
}) => {
|
|
8965
|
-
const types = /* @__PURE__ */ new Set();
|
|
8966
|
-
for await (const action of imports.listActions({ app: input.app }).items()) {
|
|
8967
|
-
types.add(action.action_type);
|
|
8968
|
-
}
|
|
8969
|
-
return { data: [...types].map((type) => ({ key: type, name: type })) };
|
|
8970
|
-
},
|
|
8971
|
-
prompt: ({ items }) => ({
|
|
8972
|
-
type: "list",
|
|
8973
|
-
message: "Select action type:",
|
|
8974
|
-
choices: items.map((type) => ({ label: type.name, value: type.key }))
|
|
8975
|
-
})
|
|
8976
|
-
});
|
|
8977
|
-
|
|
8978
|
-
// src/resolvers/actionKey.ts
|
|
8979
|
-
var listActionsRef2 = declareMethod({ id: "listActions" });
|
|
8980
|
-
var actionKeyResolver = defineResolver({
|
|
8981
|
-
imports: [listActionsRef2],
|
|
8982
|
-
requireParameters: ["app", "actionType"],
|
|
8983
|
-
listItems: async ({
|
|
8984
|
-
imports,
|
|
8985
|
-
input,
|
|
8986
|
-
cursor
|
|
8987
|
-
}) => {
|
|
8988
|
-
const page = await imports.listActions({ app: input.app, cursor });
|
|
8989
|
-
return {
|
|
8990
|
-
data: page.data.filter(
|
|
8991
|
-
(action) => action.action_type === input.actionType && !action.is_hidden
|
|
8992
|
-
),
|
|
8993
|
-
nextCursor: page.nextCursor
|
|
8994
|
-
};
|
|
8995
|
-
},
|
|
8996
|
-
prompt: ({ items }) => ({
|
|
8997
|
-
type: "list",
|
|
8998
|
-
message: "Select action:",
|
|
8999
|
-
choices: items.map((action) => ({
|
|
9000
|
-
label: action.title || action.name || action.key,
|
|
9001
|
-
hint: action.description || void 0,
|
|
9002
|
-
value: action.key
|
|
9003
|
-
}))
|
|
9004
|
-
})
|
|
9005
|
-
});
|
|
9006
|
-
|
|
9007
|
-
// src/plugins/capabilities/index.ts
|
|
9008
|
-
function toDescription(key) {
|
|
9009
|
-
const words = key.replace(/^can/, "").replace(/([A-Z])/g, " $1").trim().toLowerCase();
|
|
9010
|
-
return `To ${words}`;
|
|
9011
|
-
}
|
|
9012
|
-
function toEnvVar(key) {
|
|
9013
|
-
return "ZAPIER_" + key.replace(/([A-Z])/g, "_$1").toUpperCase();
|
|
9014
|
-
}
|
|
9015
|
-
function toCliFlag(key) {
|
|
9016
|
-
return "--" + key.replace(/([A-Z])/g, "-$1").toLowerCase();
|
|
9017
|
-
}
|
|
9018
|
-
function buildCapabilityMessage(key) {
|
|
9019
|
-
return [
|
|
9020
|
-
`${toDescription(key)}, use ${toCliFlag(key)} in the CLI,`,
|
|
9021
|
-
`set ${key}: true in SDK options or .zapierrc,`,
|
|
9022
|
-
`or set ${toEnvVar(key)}=true.`
|
|
9023
|
-
].join(" ");
|
|
9024
|
-
}
|
|
9025
|
-
var GATED_FLAGS = [
|
|
9026
|
-
"canIncludeSharedConnections",
|
|
9027
|
-
"canIncludeSharedTables",
|
|
9028
|
-
"canDeleteTables"
|
|
9029
|
-
];
|
|
9030
|
-
function isEnabledByEnv(key) {
|
|
9031
|
-
const value = globalThis.process?.env?.[toEnvVar(key)];
|
|
9032
|
-
if (value === void 0) return void 0;
|
|
9033
|
-
if (value === "true" || value === "1") return true;
|
|
9034
|
-
if (value === "false" || value === "0") return false;
|
|
9035
|
-
return void 0;
|
|
9036
|
-
}
|
|
9037
|
-
var CAPABILITIES_ID = "zapier/capabilities";
|
|
9038
|
-
var capabilitiesPluginRef = declareProperty({ id: CAPABILITIES_ID });
|
|
9039
|
-
var capabilitiesPlugin = defineProperty({
|
|
9040
|
-
namespace: "zapier",
|
|
9041
|
-
name: "capabilities",
|
|
9042
|
-
imports: [sdkOptionsPluginRef, manifestPluginRef],
|
|
9043
|
-
setup: ({ imports }) => {
|
|
9044
|
-
const options = imports.sdkOptions ?? {};
|
|
9045
|
-
let cached;
|
|
9046
|
-
async function resolveFlags() {
|
|
9047
|
-
if (cached) return cached;
|
|
9048
|
-
const manifest = await imports.manifest.getResolvedManifest();
|
|
9049
|
-
cached = {};
|
|
9050
|
-
for (const flag of GATED_FLAGS) {
|
|
9051
|
-
cached[flag] = Boolean(
|
|
9052
|
-
options[flag] ?? isEnabledByEnv(flag) ?? manifest?.[flag]
|
|
9053
|
-
);
|
|
9054
|
-
}
|
|
9055
|
-
return cached;
|
|
9056
|
-
}
|
|
9057
|
-
return {
|
|
9058
|
-
checkCapability: async (key) => {
|
|
9059
|
-
const flags = await resolveFlags();
|
|
9060
|
-
if (flags[key]) return;
|
|
9061
|
-
throw new ZapierConfigurationError(
|
|
9062
|
-
buildCapabilityMessage(key) + " (If you are an AI agent, you MUST NOT retry. Ask the user if they want to enable this.)",
|
|
9063
|
-
{ configType: key }
|
|
9064
|
-
);
|
|
9065
|
-
},
|
|
9066
|
-
hasCapability: async (key) => {
|
|
9067
|
-
const flags = await resolveFlags();
|
|
9068
|
-
return flags[key];
|
|
9069
|
-
}
|
|
9070
|
-
};
|
|
9071
|
-
},
|
|
9072
|
-
get: ({ state }) => state
|
|
8648
|
+
|
|
8649
|
+
// src/plugins/capabilities/index.ts
|
|
8650
|
+
function toDescription(key) {
|
|
8651
|
+
const words = key.replace(/^can/, "").replace(/([A-Z])/g, " $1").trim().toLowerCase();
|
|
8652
|
+
return `To ${words}`;
|
|
8653
|
+
}
|
|
8654
|
+
function toEnvVar(key) {
|
|
8655
|
+
return "ZAPIER_" + key.replace(/([A-Z])/g, "_$1").toUpperCase();
|
|
8656
|
+
}
|
|
8657
|
+
function toCliFlag(key) {
|
|
8658
|
+
return "--" + key.replace(/([A-Z])/g, "-$1").toLowerCase();
|
|
8659
|
+
}
|
|
8660
|
+
function buildCapabilityMessage(key) {
|
|
8661
|
+
return [
|
|
8662
|
+
`${toDescription(key)}, use ${toCliFlag(key)} in the CLI,`,
|
|
8663
|
+
`set ${key}: true in SDK options or .zapierrc,`,
|
|
8664
|
+
`or set ${toEnvVar(key)}=true.`
|
|
8665
|
+
].join(" ");
|
|
8666
|
+
}
|
|
8667
|
+
var GATED_FLAGS = [
|
|
8668
|
+
"canIncludeSharedConnections",
|
|
8669
|
+
"canIncludeSharedTables",
|
|
8670
|
+
"canDeleteTables"
|
|
8671
|
+
];
|
|
8672
|
+
function isEnabledByEnv(key) {
|
|
8673
|
+
const value = globalThis.process?.env?.[toEnvVar(key)];
|
|
8674
|
+
if (value === void 0) return void 0;
|
|
8675
|
+
if (value === "true" || value === "1") return true;
|
|
8676
|
+
if (value === "false" || value === "0") return false;
|
|
8677
|
+
return void 0;
|
|
8678
|
+
}
|
|
8679
|
+
var CAPABILITIES_ID = "zapier/capabilities";
|
|
8680
|
+
var capabilitiesPluginRef = declareProperty({ id: CAPABILITIES_ID });
|
|
8681
|
+
var capabilitiesPlugin = defineProperty({
|
|
8682
|
+
namespace: "zapier",
|
|
8683
|
+
name: "capabilities",
|
|
8684
|
+
imports: [sdkOptionsPluginRef, manifestPluginRef],
|
|
8685
|
+
setup: ({ imports }) => {
|
|
8686
|
+
const options = imports.sdkOptions ?? {};
|
|
8687
|
+
let cached;
|
|
8688
|
+
async function resolveFlags() {
|
|
8689
|
+
if (cached) return cached;
|
|
8690
|
+
const manifest = await imports.manifest.getResolvedManifest();
|
|
8691
|
+
cached = {};
|
|
8692
|
+
for (const flag of GATED_FLAGS) {
|
|
8693
|
+
cached[flag] = Boolean(
|
|
8694
|
+
options[flag] ?? isEnabledByEnv(flag) ?? manifest?.[flag]
|
|
8695
|
+
);
|
|
8696
|
+
}
|
|
8697
|
+
return cached;
|
|
8698
|
+
}
|
|
8699
|
+
return {
|
|
8700
|
+
checkCapability: async (key) => {
|
|
8701
|
+
const flags = await resolveFlags();
|
|
8702
|
+
if (flags[key]) return;
|
|
8703
|
+
throw new ZapierConfigurationError(
|
|
8704
|
+
buildCapabilityMessage(key) + " (If you are an AI agent, you MUST NOT retry. Ask the user if they want to enable this.)",
|
|
8705
|
+
{ configType: key }
|
|
8706
|
+
);
|
|
8707
|
+
},
|
|
8708
|
+
hasCapability: async (key) => {
|
|
8709
|
+
const flags = await resolveFlags();
|
|
8710
|
+
return flags[key];
|
|
8711
|
+
}
|
|
8712
|
+
};
|
|
8713
|
+
},
|
|
8714
|
+
get: ({ state }) => state
|
|
9073
8715
|
});
|
|
9074
8716
|
|
|
9075
8717
|
// src/resolvers/connectionId.ts
|
|
@@ -9753,396 +9395,768 @@ async function createFieldKeyTranslator({
|
|
|
9753
9395
|
}
|
|
9754
9396
|
}
|
|
9755
9397
|
}
|
|
9756
|
-
return key;
|
|
9398
|
+
return key;
|
|
9399
|
+
}
|
|
9400
|
+
};
|
|
9401
|
+
}
|
|
9402
|
+
|
|
9403
|
+
// src/resolvers/tableRecordId.ts
|
|
9404
|
+
var listTableRecordsRef = declareMethod({ id: "listTableRecords" });
|
|
9405
|
+
function summarizeRecord(record) {
|
|
9406
|
+
const values = Object.values(record.data);
|
|
9407
|
+
const preview = values.slice(0, 3).map((v) => formatFieldValue(v).replace(/\s+/g, " ").trim()).filter((s) => s.length > 0).join(", ");
|
|
9408
|
+
if (!preview) return void 0;
|
|
9409
|
+
return preview.length > 60 ? preview.slice(0, 57) + "..." : preview;
|
|
9410
|
+
}
|
|
9411
|
+
function recordChoices(records) {
|
|
9412
|
+
return records.map((record) => ({
|
|
9413
|
+
label: summarizeRecord(record) || record.id,
|
|
9414
|
+
value: record.id
|
|
9415
|
+
}));
|
|
9416
|
+
}
|
|
9417
|
+
var tableRecordIdResolver = defineResolver({
|
|
9418
|
+
imports: [listTableRecordsRef],
|
|
9419
|
+
requireParameters: ["table"],
|
|
9420
|
+
listItems: ({ imports, input, cursor }) => imports.listTableRecords({
|
|
9421
|
+
table: input.table,
|
|
9422
|
+
keyMode: "names",
|
|
9423
|
+
cursor
|
|
9424
|
+
}),
|
|
9425
|
+
prompt: ({ items }) => ({
|
|
9426
|
+
type: "list",
|
|
9427
|
+
message: "Select a record:",
|
|
9428
|
+
choices: recordChoices(items)
|
|
9429
|
+
})
|
|
9430
|
+
});
|
|
9431
|
+
var tableRecordIdsResolver = defineResolver({
|
|
9432
|
+
imports: [listTableRecordsRef],
|
|
9433
|
+
requireParameters: ["table"],
|
|
9434
|
+
listItems: ({ imports, input, cursor }) => imports.listTableRecords({
|
|
9435
|
+
table: input.table,
|
|
9436
|
+
keyMode: "names",
|
|
9437
|
+
cursor
|
|
9438
|
+
}),
|
|
9439
|
+
prompt: ({ items }) => ({
|
|
9440
|
+
type: "checkbox",
|
|
9441
|
+
message: "Select records to delete:",
|
|
9442
|
+
choices: recordChoices(items)
|
|
9443
|
+
}),
|
|
9444
|
+
validate: ({ value }) => Array.isArray(value) && value.length > 0 ? true : "Select at least one record"
|
|
9445
|
+
});
|
|
9446
|
+
|
|
9447
|
+
// src/resolvers/tableFieldIds.ts
|
|
9448
|
+
var listTableFieldsRef = declareMethod({ id: "listTableFields" });
|
|
9449
|
+
var tableFieldIdsResolver = defineResolver({
|
|
9450
|
+
imports: [listTableFieldsRef],
|
|
9451
|
+
requireParameters: ["table"],
|
|
9452
|
+
// No cursor forwarding: the fields API is unpaginated (no cursor on the
|
|
9453
|
+
// response), so the listing is always exhausted after one page.
|
|
9454
|
+
listItems: ({ imports, input }) => imports.listTableFields({ table: input.table }),
|
|
9455
|
+
prompt: ({ items }) => ({
|
|
9456
|
+
type: "checkbox",
|
|
9457
|
+
message: "Select fields:",
|
|
9458
|
+
choices: items.map((field) => ({
|
|
9459
|
+
label: field.name,
|
|
9460
|
+
hint: [field.id, field.type],
|
|
9461
|
+
value: field.id
|
|
9462
|
+
}))
|
|
9463
|
+
}),
|
|
9464
|
+
validate: ({ value }) => Array.isArray(value) && value.length > 0 ? true : "Select at least one field"
|
|
9465
|
+
});
|
|
9466
|
+
|
|
9467
|
+
// src/resolvers/tableName.ts
|
|
9468
|
+
var tableNameResolver = defineResolver({
|
|
9469
|
+
type: "static",
|
|
9470
|
+
inputType: "text",
|
|
9471
|
+
placeholder: "Enter a name for the table"
|
|
9472
|
+
});
|
|
9473
|
+
var FieldTypeSchema = zod.z.enum([
|
|
9474
|
+
"string",
|
|
9475
|
+
"multiple_string",
|
|
9476
|
+
"labeled_string",
|
|
9477
|
+
"multiple_labeled_string",
|
|
9478
|
+
"text",
|
|
9479
|
+
"multiple_text",
|
|
9480
|
+
"boolean",
|
|
9481
|
+
"multiple_boolean",
|
|
9482
|
+
"number",
|
|
9483
|
+
"multiple_number",
|
|
9484
|
+
"decimal",
|
|
9485
|
+
"multiple_decimal",
|
|
9486
|
+
"datetime",
|
|
9487
|
+
"multiple_datetime",
|
|
9488
|
+
"uuid",
|
|
9489
|
+
"multiple_uuid",
|
|
9490
|
+
"json",
|
|
9491
|
+
"multiple_json",
|
|
9492
|
+
"formula",
|
|
9493
|
+
"button_trigger_zap",
|
|
9494
|
+
"button_continue_zap",
|
|
9495
|
+
"email",
|
|
9496
|
+
"multiple_email",
|
|
9497
|
+
"link",
|
|
9498
|
+
"multiple_link",
|
|
9499
|
+
"currency",
|
|
9500
|
+
"phone_number",
|
|
9501
|
+
"ai_formula",
|
|
9502
|
+
"linked_record",
|
|
9503
|
+
"multiple_linked_record"
|
|
9504
|
+
]);
|
|
9505
|
+
var FieldApiItemSchema = zod.z.object({
|
|
9506
|
+
id: zod.z.number(),
|
|
9507
|
+
type: FieldTypeSchema,
|
|
9508
|
+
name: zod.z.string(),
|
|
9509
|
+
created_at: zod.z.string().optional(),
|
|
9510
|
+
edited_at: zod.z.string().optional(),
|
|
9511
|
+
options: zod.z.record(zod.z.string(), zod.z.unknown()).optional(),
|
|
9512
|
+
config: zod.z.record(zod.z.string(), zod.z.unknown()).optional(),
|
|
9513
|
+
is_order_field: zod.z.boolean().optional(),
|
|
9514
|
+
is_filter_field: zod.z.boolean().optional(),
|
|
9515
|
+
is_selected_field: zod.z.boolean().optional(),
|
|
9516
|
+
deleted_at: zod.z.string().nullable().optional()
|
|
9517
|
+
});
|
|
9518
|
+
var ListTableFieldsApiResponseSchema = zod.z.object({
|
|
9519
|
+
data: zod.z.array(FieldApiItemSchema)
|
|
9520
|
+
});
|
|
9521
|
+
var FieldItemSchema = zod.z.object({
|
|
9522
|
+
id: zod.z.string(),
|
|
9523
|
+
type: FieldTypeSchema,
|
|
9524
|
+
name: zod.z.string(),
|
|
9525
|
+
created_at: zod.z.string().optional(),
|
|
9526
|
+
edited_at: zod.z.string().optional(),
|
|
9527
|
+
options: zod.z.record(zod.z.string(), zod.z.unknown()).optional(),
|
|
9528
|
+
config: zod.z.record(zod.z.string(), zod.z.unknown()).optional(),
|
|
9529
|
+
deleted_at: zod.z.string().nullable().optional()
|
|
9530
|
+
});
|
|
9531
|
+
var ListTableFieldsDescription = "List fields for a table";
|
|
9532
|
+
var ListTableFieldsOptionsBaseSchema = zod.z.object({
|
|
9533
|
+
fields: FieldsPropertySchema.optional(),
|
|
9534
|
+
fieldKeys: zod.z.array(zod.z.union([zod.z.string(), zod.z.number()])).optional().describe(
|
|
9535
|
+
'Filter by specific fields. Accepts field names (e.g., "Email") or IDs (e.g., "f6", "6", or 6).'
|
|
9536
|
+
).meta({ deprecated: true }),
|
|
9537
|
+
trash: TrashSchema
|
|
9538
|
+
});
|
|
9539
|
+
var ListTableFieldsOptionsSchema = zod.z.object({
|
|
9540
|
+
table: TablePropertySchema
|
|
9541
|
+
}).merge(ListTableFieldsOptionsBaseSchema).describe(ListTableFieldsDescription).meta({ aliases: { tableId: "table", fieldKeys: "fields" } });
|
|
9542
|
+
var ListTableFieldsOptionsSchemaDeprecated = zod.z.object({
|
|
9543
|
+
tableId: zod.z.string().regex(/^[A-Z0-9]{26}$/, "Table ID must be a valid ULID").describe("The unique identifier of the table")
|
|
9544
|
+
}).merge(ListTableFieldsOptionsBaseSchema);
|
|
9545
|
+
var ListTableFieldsOptionsInputSchema = zod.z.union([ListTableFieldsOptionsSchema, ListTableFieldsOptionsSchemaDeprecated]).describe(ListTableFieldsDescription);
|
|
9546
|
+
|
|
9547
|
+
// src/resolvers/tableFields.ts
|
|
9548
|
+
var fieldTypeChoices = FieldTypeSchema.options.map((type) => ({
|
|
9549
|
+
label: type,
|
|
9550
|
+
value: type
|
|
9551
|
+
}));
|
|
9552
|
+
var singleFieldResolver = defineResolver({
|
|
9553
|
+
type: "object",
|
|
9554
|
+
properties: {
|
|
9555
|
+
type: {
|
|
9556
|
+
label: "Field type",
|
|
9557
|
+
required: true,
|
|
9558
|
+
resolver: defineResolver({
|
|
9559
|
+
listItems: () => ({ data: fieldTypeChoices }),
|
|
9560
|
+
prompt: ({ items }) => ({
|
|
9561
|
+
type: "list",
|
|
9562
|
+
message: "Select field type:",
|
|
9563
|
+
choices: items
|
|
9564
|
+
})
|
|
9565
|
+
})
|
|
9566
|
+
},
|
|
9567
|
+
name: {
|
|
9568
|
+
label: "Field name",
|
|
9569
|
+
required: true,
|
|
9570
|
+
resolver: defineResolver({ type: "static", inputType: "text" })
|
|
9571
|
+
}
|
|
9572
|
+
}
|
|
9573
|
+
});
|
|
9574
|
+
var tableFieldsResolver = defineResolver({
|
|
9575
|
+
type: "array",
|
|
9576
|
+
items: singleFieldResolver,
|
|
9577
|
+
minItems: 1
|
|
9578
|
+
});
|
|
9579
|
+
|
|
9580
|
+
// src/resolvers/tableRecords.ts
|
|
9581
|
+
var listTableFieldsRef2 = declareMethod({ id: "listTableFields" });
|
|
9582
|
+
function tableFieldValueType(fieldType) {
|
|
9583
|
+
if (fieldType.startsWith("multiple_")) return "array";
|
|
9584
|
+
switch (fieldType) {
|
|
9585
|
+
case "number":
|
|
9586
|
+
case "decimal":
|
|
9587
|
+
case "currency":
|
|
9588
|
+
return "number";
|
|
9589
|
+
case "boolean":
|
|
9590
|
+
return "boolean";
|
|
9591
|
+
default:
|
|
9592
|
+
return void 0;
|
|
9593
|
+
}
|
|
9594
|
+
}
|
|
9595
|
+
function buildDataFields(fields) {
|
|
9596
|
+
const props = {};
|
|
9597
|
+
for (const field of fields) {
|
|
9598
|
+
const valueType = tableFieldValueType(field.type);
|
|
9599
|
+
props[field.id] = {
|
|
9600
|
+
label: field.name,
|
|
9601
|
+
required: false,
|
|
9602
|
+
...valueType ? { valueType } : {},
|
|
9603
|
+
resolver: { type: "static", inputType: "text" }
|
|
9604
|
+
};
|
|
9605
|
+
}
|
|
9606
|
+
return props;
|
|
9607
|
+
}
|
|
9608
|
+
function makeRecordsResolver(includeRecordId) {
|
|
9609
|
+
const singleRecordResolver = defineResolver({
|
|
9610
|
+
type: "object",
|
|
9611
|
+
imports: [listTableFieldsRef2],
|
|
9612
|
+
requireParameters: ["table"],
|
|
9613
|
+
// The record-id resolver is import-bearing, so it lives in `definitions` and
|
|
9614
|
+
// is reached by `{ ref }` from the built `id` field (updates only).
|
|
9615
|
+
definitions: includeRecordId ? { recordId: tableRecordIdResolver } : {},
|
|
9616
|
+
getProperties: async ({ imports, input }) => {
|
|
9617
|
+
const { data: fields } = await imports.listTableFields({
|
|
9618
|
+
table: input.table
|
|
9619
|
+
});
|
|
9620
|
+
const props = {
|
|
9621
|
+
data: {
|
|
9622
|
+
label: "Field values",
|
|
9623
|
+
resolver: { type: "object", properties: buildDataFields(fields) }
|
|
9624
|
+
}
|
|
9625
|
+
};
|
|
9626
|
+
if (includeRecordId) {
|
|
9627
|
+
props.id = {
|
|
9628
|
+
label: "Record",
|
|
9629
|
+
required: true,
|
|
9630
|
+
resolver: { ref: "recordId" }
|
|
9631
|
+
};
|
|
9632
|
+
}
|
|
9633
|
+
return props;
|
|
9757
9634
|
}
|
|
9758
|
-
};
|
|
9635
|
+
});
|
|
9636
|
+
return defineResolver({
|
|
9637
|
+
type: "array",
|
|
9638
|
+
requireParameters: ["table"],
|
|
9639
|
+
minItems: 1,
|
|
9640
|
+
items: singleRecordResolver
|
|
9641
|
+
});
|
|
9759
9642
|
}
|
|
9643
|
+
var tableRecordsResolver = makeRecordsResolver(false);
|
|
9644
|
+
var tableUpdateRecordsResolver = makeRecordsResolver(true);
|
|
9760
9645
|
|
|
9761
|
-
// src/resolvers/
|
|
9762
|
-
var
|
|
9763
|
-
|
|
9764
|
-
|
|
9765
|
-
|
|
9766
|
-
|
|
9767
|
-
|
|
9646
|
+
// src/resolvers/tableFilters.ts
|
|
9647
|
+
var listTableFieldsRef3 = declareMethod({ id: "listTableFields" });
|
|
9648
|
+
var FILTER_OPERATORS = [
|
|
9649
|
+
{ label: "equals", value: "exact" },
|
|
9650
|
+
{ label: "not equals", value: "different" },
|
|
9651
|
+
{ label: "contains", value: "contains" },
|
|
9652
|
+
{ label: "contains (case-insensitive)", value: "icontains" },
|
|
9653
|
+
{ label: "starts with", value: "startswith" },
|
|
9654
|
+
{ label: "search", value: "search" },
|
|
9655
|
+
{ label: "greater than", value: "gt" },
|
|
9656
|
+
{ label: "greater than or equal", value: "gte" },
|
|
9657
|
+
{ label: "less than", value: "lt" },
|
|
9658
|
+
{ label: "less than or equal", value: "lte" },
|
|
9659
|
+
{ label: "in range", value: "range" },
|
|
9660
|
+
{ label: "in list", value: "in" },
|
|
9661
|
+
{ label: "is empty", value: "isnull" },
|
|
9662
|
+
{ label: "is within (date)", value: "is_within" }
|
|
9663
|
+
];
|
|
9664
|
+
function fieldKeyChoices(fields) {
|
|
9665
|
+
return fields.flatMap((field) => {
|
|
9666
|
+
const components = NESTED_COMPONENTS[field.type];
|
|
9667
|
+
if (components && components.size > 1) {
|
|
9668
|
+
return [...components].map((component) => ({
|
|
9669
|
+
label: `${field.name}__${component} (${field.id}, ${field.type})`,
|
|
9670
|
+
value: `${field.name}__${component}`
|
|
9671
|
+
}));
|
|
9672
|
+
}
|
|
9673
|
+
return {
|
|
9674
|
+
label: `${field.name} (${field.id}${components ? `, ${field.type}` : ""})`,
|
|
9675
|
+
value: components ? `${field.name}__${[...components][0]}` : field.name
|
|
9676
|
+
};
|
|
9677
|
+
});
|
|
9768
9678
|
}
|
|
9769
|
-
|
|
9770
|
-
|
|
9771
|
-
|
|
9772
|
-
|
|
9773
|
-
})
|
|
9679
|
+
var singleFilterResolver = defineResolver({
|
|
9680
|
+
type: "object",
|
|
9681
|
+
imports: [listTableFieldsRef3],
|
|
9682
|
+
requireParameters: ["table"],
|
|
9683
|
+
getProperties: async ({ imports, input }) => {
|
|
9684
|
+
const { data: fields } = await imports.listTableFields({
|
|
9685
|
+
table: input.table
|
|
9686
|
+
});
|
|
9687
|
+
const choices = fieldKeyChoices(fields);
|
|
9688
|
+
const props = {
|
|
9689
|
+
fieldKey: {
|
|
9690
|
+
label: "Field",
|
|
9691
|
+
required: true,
|
|
9692
|
+
resolver: {
|
|
9693
|
+
type: "dynamic",
|
|
9694
|
+
listItems: () => ({ data: choices }),
|
|
9695
|
+
prompt: () => ({
|
|
9696
|
+
type: "list",
|
|
9697
|
+
message: "Select field:",
|
|
9698
|
+
choices
|
|
9699
|
+
})
|
|
9700
|
+
}
|
|
9701
|
+
},
|
|
9702
|
+
operator: {
|
|
9703
|
+
label: "Operator",
|
|
9704
|
+
required: true,
|
|
9705
|
+
resolver: {
|
|
9706
|
+
type: "dynamic",
|
|
9707
|
+
listItems: () => ({ data: FILTER_OPERATORS }),
|
|
9708
|
+
prompt: () => ({
|
|
9709
|
+
type: "list",
|
|
9710
|
+
message: "Select operator:",
|
|
9711
|
+
choices: FILTER_OPERATORS
|
|
9712
|
+
})
|
|
9713
|
+
}
|
|
9714
|
+
},
|
|
9715
|
+
value: {
|
|
9716
|
+
label: "Value",
|
|
9717
|
+
required: false,
|
|
9718
|
+
resolver: { type: "static", inputType: "text" }
|
|
9719
|
+
}
|
|
9720
|
+
};
|
|
9721
|
+
return props;
|
|
9722
|
+
}
|
|
9723
|
+
});
|
|
9724
|
+
var tableFiltersResolver = defineResolver({
|
|
9725
|
+
type: "array",
|
|
9726
|
+
requireParameters: ["table"],
|
|
9727
|
+
minItems: 0,
|
|
9728
|
+
items: singleFilterResolver
|
|
9729
|
+
});
|
|
9730
|
+
|
|
9731
|
+
// src/resolvers/tableSort.ts
|
|
9732
|
+
var listTableFieldsRef4 = declareMethod({ id: "listTableFields" });
|
|
9733
|
+
function fieldKeyChoices2(fields) {
|
|
9734
|
+
return fields.flatMap((field) => {
|
|
9735
|
+
const components = NESTED_COMPONENTS[field.type];
|
|
9736
|
+
if (components) {
|
|
9737
|
+
return [...components].map((component) => ({
|
|
9738
|
+
label: `${field.name}__${component} (${field.id}, ${field.type})`,
|
|
9739
|
+
value: `${field.name}__${component}`
|
|
9740
|
+
}));
|
|
9741
|
+
}
|
|
9742
|
+
return { label: `${field.name} (${field.id})`, value: field.name };
|
|
9743
|
+
});
|
|
9774
9744
|
}
|
|
9775
|
-
var
|
|
9776
|
-
|
|
9745
|
+
var DIRECTION_CHOICES = [
|
|
9746
|
+
{ label: "Ascending", value: "asc" },
|
|
9747
|
+
{ label: "Descending", value: "desc" }
|
|
9748
|
+
];
|
|
9749
|
+
var tableSortResolver = defineResolver({
|
|
9750
|
+
type: "object",
|
|
9751
|
+
imports: [listTableFieldsRef4],
|
|
9777
9752
|
requireParameters: ["table"],
|
|
9778
|
-
|
|
9779
|
-
|
|
9780
|
-
|
|
9781
|
-
|
|
9782
|
-
|
|
9783
|
-
|
|
9784
|
-
|
|
9785
|
-
|
|
9786
|
-
|
|
9787
|
-
|
|
9753
|
+
getProperties: async ({ imports, input }) => {
|
|
9754
|
+
const { data: fields } = await imports.listTableFields({
|
|
9755
|
+
table: input.table
|
|
9756
|
+
});
|
|
9757
|
+
const choices = fieldKeyChoices2(fields);
|
|
9758
|
+
const props = {
|
|
9759
|
+
fieldKey: {
|
|
9760
|
+
label: "Field",
|
|
9761
|
+
required: true,
|
|
9762
|
+
resolver: {
|
|
9763
|
+
type: "dynamic",
|
|
9764
|
+
listItems: () => ({ data: choices }),
|
|
9765
|
+
prompt: () => ({
|
|
9766
|
+
type: "list",
|
|
9767
|
+
message: "Select field:",
|
|
9768
|
+
choices
|
|
9769
|
+
})
|
|
9770
|
+
}
|
|
9771
|
+
},
|
|
9772
|
+
direction: {
|
|
9773
|
+
label: "Direction",
|
|
9774
|
+
required: true,
|
|
9775
|
+
resolver: {
|
|
9776
|
+
type: "dynamic",
|
|
9777
|
+
listItems: () => ({ data: DIRECTION_CHOICES }),
|
|
9778
|
+
prompt: () => ({
|
|
9779
|
+
type: "list",
|
|
9780
|
+
message: "Select direction:",
|
|
9781
|
+
choices: DIRECTION_CHOICES
|
|
9782
|
+
})
|
|
9783
|
+
}
|
|
9784
|
+
}
|
|
9785
|
+
};
|
|
9786
|
+
return props;
|
|
9787
|
+
}
|
|
9788
|
+
});
|
|
9789
|
+
var GetActionDescription = "Get detailed information about a specific action";
|
|
9790
|
+
var GetActionSchema = zod.z.object({
|
|
9791
|
+
app: AppPropertySchema,
|
|
9792
|
+
actionType: ActionTypePropertySchema,
|
|
9793
|
+
action: ActionPropertySchema
|
|
9794
|
+
}).describe(GetActionDescription).meta({ aliases: { appKey: "app", actionKey: "action" } });
|
|
9795
|
+
var GetActionSchemaDeprecated = zod.z.object({
|
|
9796
|
+
appKey: AppKeyPropertySchema,
|
|
9797
|
+
actionType: ActionTypePropertySchema,
|
|
9798
|
+
actionKey: ActionKeyPropertySchema
|
|
9799
|
+
});
|
|
9800
|
+
var GetActionInputSchema = zod.z.union([GetActionSchema, GetActionSchemaDeprecated]).describe(GetActionDescription);
|
|
9801
|
+
var ListActionsDescription = "List all actions for a specific app";
|
|
9802
|
+
var ListActionsBaseSchema = zod.z.object({
|
|
9803
|
+
pageSize: zod.z.number().min(1).optional().describe("Number of actions per page"),
|
|
9804
|
+
maxItems: zod.z.number().min(1).optional().describe("Maximum total items to return across all pages"),
|
|
9805
|
+
cursor: zod.z.string().optional().describe("Cursor to start from")
|
|
9806
|
+
});
|
|
9807
|
+
var ListActionsSchema = zod.z.object({
|
|
9808
|
+
app: AppPropertySchema.describe(
|
|
9809
|
+
"App key of actions to list (e.g., 'SlackCLIAPI' or slug like 'github')"
|
|
9810
|
+
),
|
|
9811
|
+
actionType: ActionTypePropertySchema.optional().describe(
|
|
9812
|
+
"Filter actions by type"
|
|
9813
|
+
)
|
|
9814
|
+
}).merge(ListActionsBaseSchema).describe(ListActionsDescription).meta({ aliases: { appKey: "app" } });
|
|
9815
|
+
var ListActionsSchemaDeprecated = zod.z.object({
|
|
9816
|
+
appKey: AppKeyPropertySchema.describe(
|
|
9817
|
+
"App key of actions to list (e.g., 'SlackCLIAPI' or slug like 'github')"
|
|
9818
|
+
),
|
|
9819
|
+
actionType: ActionTypePropertySchema.optional().describe(
|
|
9820
|
+
"Filter actions by type"
|
|
9821
|
+
)
|
|
9822
|
+
}).merge(ListActionsBaseSchema);
|
|
9823
|
+
var ListActionsInputSchema = zod.z.union([ListActionsSchema, ListActionsSchemaDeprecated]).describe(ListActionsDescription);
|
|
9824
|
+
var NeedChoicesSchema = zod.z.object({
|
|
9825
|
+
key: zod.z.string().optional(),
|
|
9826
|
+
label: zod.z.string().optional(),
|
|
9827
|
+
sample: zod.z.string().optional(),
|
|
9828
|
+
value: zod.z.string().optional()
|
|
9829
|
+
});
|
|
9830
|
+
var NeedSchema = zod.z.object({
|
|
9831
|
+
key: zod.z.string(),
|
|
9832
|
+
alters_custom_fields: zod.z.boolean().nullable().optional(),
|
|
9833
|
+
capabilities: zod.z.array(zod.z.string()).optional(),
|
|
9834
|
+
choices: zod.z.array(NeedChoicesSchema).optional(),
|
|
9835
|
+
computed: zod.z.boolean().nullable().optional(),
|
|
9836
|
+
custom_field: zod.z.boolean().optional(),
|
|
9837
|
+
default: zod.z.string().optional(),
|
|
9838
|
+
depends_on: zod.z.array(zod.z.string()).optional(),
|
|
9839
|
+
format: zod.z.literal("SELECT").optional(),
|
|
9840
|
+
from_search: zod.z.boolean().optional(),
|
|
9841
|
+
from_write: zod.z.boolean().optional(),
|
|
9842
|
+
help_text: zod.z.string().optional(),
|
|
9843
|
+
help_text_html: zod.z.string().optional(),
|
|
9844
|
+
input_format: zod.z.array(zod.z.string()).optional(),
|
|
9845
|
+
label: zod.z.string().optional(),
|
|
9846
|
+
language: zod.z.string().optional(),
|
|
9847
|
+
parent_key: zod.z.string().optional(),
|
|
9848
|
+
placeholder: zod.z.string().optional(),
|
|
9849
|
+
prefill: zod.z.string().optional(),
|
|
9850
|
+
required: zod.z.boolean().optional(),
|
|
9851
|
+
searchfill: zod.z.string().optional(),
|
|
9852
|
+
send_in_json: zod.z.boolean().optional(),
|
|
9853
|
+
regex: zod.z.string().optional(),
|
|
9854
|
+
type: zod.z.enum([
|
|
9855
|
+
"integer",
|
|
9856
|
+
"string",
|
|
9857
|
+
"text",
|
|
9858
|
+
"datetime",
|
|
9859
|
+
"boolean",
|
|
9860
|
+
"file",
|
|
9861
|
+
"decimal",
|
|
9862
|
+
"copy",
|
|
9863
|
+
"password",
|
|
9864
|
+
"dict",
|
|
9865
|
+
"code",
|
|
9866
|
+
"filter",
|
|
9867
|
+
"json"
|
|
9868
|
+
]).optional(),
|
|
9869
|
+
list: zod.z.boolean().optional()
|
|
9788
9870
|
});
|
|
9789
|
-
|
|
9790
|
-
|
|
9791
|
-
requireParameters: ["table"],
|
|
9792
|
-
listItems: ({ imports, input, cursor }) => imports.listTableRecords({
|
|
9793
|
-
table: input.table,
|
|
9794
|
-
keyMode: "names",
|
|
9795
|
-
cursor
|
|
9796
|
-
}),
|
|
9797
|
-
prompt: ({ items }) => ({
|
|
9798
|
-
type: "checkbox",
|
|
9799
|
-
message: "Select records to delete:",
|
|
9800
|
-
choices: recordChoices(items)
|
|
9801
|
-
}),
|
|
9802
|
-
validate: ({ value }) => Array.isArray(value) && value.length > 0 ? true : "Select at least one record"
|
|
9871
|
+
zod.z.object({
|
|
9872
|
+
action_url: zod.z.string().optional()
|
|
9803
9873
|
});
|
|
9804
|
-
|
|
9805
|
-
|
|
9806
|
-
var listTableFieldsRef = declareMethod({ id: "listTableFields" });
|
|
9807
|
-
var tableFieldIdsResolver = defineResolver({
|
|
9808
|
-
imports: [listTableFieldsRef],
|
|
9809
|
-
requireParameters: ["table"],
|
|
9810
|
-
// No cursor forwarding: the fields API is unpaginated (no cursor on the
|
|
9811
|
-
// response), so the listing is always exhausted after one page.
|
|
9812
|
-
listItems: ({ imports, input }) => imports.listTableFields({ table: input.table }),
|
|
9813
|
-
prompt: ({ items }) => ({
|
|
9814
|
-
type: "checkbox",
|
|
9815
|
-
message: "Select fields:",
|
|
9816
|
-
choices: items.map((field) => ({
|
|
9817
|
-
label: field.name,
|
|
9818
|
-
hint: [field.id, field.type],
|
|
9819
|
-
value: field.id
|
|
9820
|
-
}))
|
|
9821
|
-
}),
|
|
9822
|
-
validate: ({ value }) => Array.isArray(value) && value.length > 0 ? true : "Select at least one field"
|
|
9874
|
+
zod.z.object({
|
|
9875
|
+
can_use: zod.z.boolean().optional()
|
|
9823
9876
|
});
|
|
9824
|
-
|
|
9825
|
-
|
|
9826
|
-
|
|
9827
|
-
|
|
9828
|
-
|
|
9829
|
-
|
|
9877
|
+
var ActionSchema = zod.z.object({
|
|
9878
|
+
id: zod.z.string().optional(),
|
|
9879
|
+
type: zod.z.enum([
|
|
9880
|
+
"filter",
|
|
9881
|
+
"read",
|
|
9882
|
+
"read_bulk",
|
|
9883
|
+
"run",
|
|
9884
|
+
"search",
|
|
9885
|
+
"search_and_write",
|
|
9886
|
+
"search_or_write",
|
|
9887
|
+
"write"
|
|
9888
|
+
]),
|
|
9889
|
+
key: zod.z.string(),
|
|
9890
|
+
name: zod.z.string(),
|
|
9891
|
+
description: zod.z.string(),
|
|
9892
|
+
is_important: zod.z.boolean().optional(),
|
|
9893
|
+
is_hidden: zod.z.boolean().optional(),
|
|
9894
|
+
selected_api: zod.z.string().optional()
|
|
9830
9895
|
});
|
|
9831
|
-
var
|
|
9832
|
-
|
|
9833
|
-
|
|
9834
|
-
|
|
9835
|
-
|
|
9836
|
-
|
|
9837
|
-
|
|
9838
|
-
|
|
9839
|
-
|
|
9840
|
-
|
|
9841
|
-
|
|
9842
|
-
|
|
9843
|
-
|
|
9844
|
-
|
|
9845
|
-
|
|
9846
|
-
|
|
9847
|
-
|
|
9848
|
-
|
|
9849
|
-
|
|
9850
|
-
|
|
9851
|
-
|
|
9852
|
-
|
|
9853
|
-
|
|
9854
|
-
|
|
9855
|
-
|
|
9856
|
-
|
|
9857
|
-
|
|
9858
|
-
|
|
9859
|
-
|
|
9860
|
-
|
|
9861
|
-
|
|
9862
|
-
|
|
9863
|
-
|
|
9896
|
+
var ChoiceSchema = zod.z.object({
|
|
9897
|
+
value: zod.z.union([zod.z.string(), zod.z.number()]),
|
|
9898
|
+
label: zod.z.string()
|
|
9899
|
+
});
|
|
9900
|
+
zod.z.object({
|
|
9901
|
+
key: zod.z.string(),
|
|
9902
|
+
label: zod.z.string(),
|
|
9903
|
+
type: zod.z.enum([
|
|
9904
|
+
"string",
|
|
9905
|
+
"number",
|
|
9906
|
+
"boolean",
|
|
9907
|
+
"datetime",
|
|
9908
|
+
"file",
|
|
9909
|
+
"object",
|
|
9910
|
+
"array"
|
|
9911
|
+
]),
|
|
9912
|
+
required: zod.z.boolean(),
|
|
9913
|
+
description: zod.z.string().optional(),
|
|
9914
|
+
choices: zod.z.array(ChoiceSchema).optional()
|
|
9915
|
+
});
|
|
9916
|
+
zod.z.object({
|
|
9917
|
+
data: zod.z.array(zod.z.unknown())
|
|
9918
|
+
});
|
|
9919
|
+
var ActionFieldChoiceSchema = zod.z.object({
|
|
9920
|
+
value: zod.z.union([zod.z.string(), zod.z.number()]),
|
|
9921
|
+
label: zod.z.string()
|
|
9922
|
+
});
|
|
9923
|
+
zod.z.object({
|
|
9924
|
+
key: zod.z.string(),
|
|
9925
|
+
label: zod.z.string().optional(),
|
|
9926
|
+
required: zod.z.boolean(),
|
|
9927
|
+
type: zod.z.string().optional(),
|
|
9928
|
+
helpText: zod.z.string().optional(),
|
|
9929
|
+
helpTextHtml: zod.z.string().optional(),
|
|
9930
|
+
choices: zod.z.array(ActionFieldChoiceSchema).optional(),
|
|
9931
|
+
default: zod.z.string().optional(),
|
|
9932
|
+
placeholder: zod.z.string().optional(),
|
|
9933
|
+
computed: zod.z.boolean().optional(),
|
|
9934
|
+
customField: zod.z.boolean().optional(),
|
|
9935
|
+
dependsOn: zod.z.array(zod.z.string()).optional(),
|
|
9936
|
+
format: zod.z.string().optional(),
|
|
9937
|
+
inputFormat: zod.z.array(zod.z.string()).optional()
|
|
9938
|
+
});
|
|
9939
|
+
zod.z.object({
|
|
9864
9940
|
id: zod.z.number(),
|
|
9865
|
-
|
|
9941
|
+
public_id: zod.z.string().optional(),
|
|
9942
|
+
code: zod.z.string(),
|
|
9943
|
+
user_id: zod.z.number(),
|
|
9944
|
+
auto_provisioned: zod.z.boolean(),
|
|
9945
|
+
first_name: zod.z.string(),
|
|
9946
|
+
last_name: zod.z.string(),
|
|
9947
|
+
username: zod.z.string(),
|
|
9948
|
+
personas: zod.z.string(),
|
|
9949
|
+
user_generated_personas: zod.z.string(),
|
|
9950
|
+
last_login: zod.z.string(),
|
|
9951
|
+
email: zod.z.string(),
|
|
9952
|
+
email_hash: zod.z.string(),
|
|
9953
|
+
email_confirmed: zod.z.boolean(),
|
|
9954
|
+
timezone: zod.z.string(),
|
|
9955
|
+
photo_url: zod.z.string(),
|
|
9956
|
+
has_seen_notifications: zod.z.record(zod.z.string(), zod.z.boolean().nullable()),
|
|
9957
|
+
signup: zod.z.string(),
|
|
9958
|
+
since_signup: zod.z.string(),
|
|
9959
|
+
has_activated: zod.z.boolean(),
|
|
9960
|
+
enable_gz_creator: zod.z.boolean(),
|
|
9961
|
+
should_see_nps_survey: zod.z.boolean(),
|
|
9962
|
+
is_developer: zod.z.boolean(),
|
|
9963
|
+
is_expert: zod.z.boolean(),
|
|
9964
|
+
tos_agreement: zod.z.boolean(),
|
|
9965
|
+
should_renew_tos: zod.z.boolean(),
|
|
9966
|
+
is_gdpr_consented: zod.z.boolean(),
|
|
9967
|
+
disable_ssl_check: zod.z.boolean(),
|
|
9968
|
+
identity: zod.z.number(),
|
|
9969
|
+
summary_schedule: zod.z.string(),
|
|
9970
|
+
alert_triggers: zod.z.string(),
|
|
9971
|
+
alert_actions: zod.z.string(),
|
|
9972
|
+
is_staff: zod.z.boolean(),
|
|
9973
|
+
is_zt_reviewer: zod.z.boolean(),
|
|
9974
|
+
is_high_value: zod.z.boolean(),
|
|
9975
|
+
is_temporary: zod.z.boolean(),
|
|
9976
|
+
banner_message: zod.z.string(),
|
|
9977
|
+
enable_totp_2fa: zod.z.boolean(),
|
|
9978
|
+
viewed_help: zod.z.record(zod.z.string(), zod.z.boolean()),
|
|
9979
|
+
show_editor_migration_mesaging: zod.z.boolean(),
|
|
9980
|
+
switches: zod.z.record(zod.z.string(), zod.z.unknown()),
|
|
9981
|
+
organizations: zod.z.array(zod.z.record(zod.z.string(), zod.z.unknown()).nullable()),
|
|
9982
|
+
primary_organization: zod.z.record(zod.z.string(), zod.z.unknown()).nullable(),
|
|
9983
|
+
has_active_zaps: zod.z.boolean(),
|
|
9984
|
+
has_google_sso: zod.z.boolean(),
|
|
9985
|
+
auth_realm: zod.z.string(),
|
|
9986
|
+
roles: zod.z.array(
|
|
9987
|
+
zod.z.object({
|
|
9988
|
+
account_id: zod.z.number(),
|
|
9989
|
+
role: zod.z.string()
|
|
9990
|
+
})
|
|
9991
|
+
)
|
|
9992
|
+
});
|
|
9993
|
+
zod.z.object({
|
|
9994
|
+
age_in_days: zod.z.string().optional(),
|
|
9995
|
+
api_docs_url: zod.z.string().nullable().optional(),
|
|
9996
|
+
app_profile_url: zod.z.string(),
|
|
9997
|
+
banner: zod.z.string().optional(),
|
|
9998
|
+
categories: zod.z.array(zod.z.string()).optional(),
|
|
9999
|
+
// Service category names
|
|
10000
|
+
canonical_id: zod.z.string().optional(),
|
|
10001
|
+
current_implementation_id: zod.z.string(),
|
|
10002
|
+
days_since_last_update: zod.z.string().optional(),
|
|
10003
|
+
description: zod.z.string(),
|
|
10004
|
+
external_url: zod.z.string(),
|
|
10005
|
+
hashtag: zod.z.string().optional(),
|
|
10006
|
+
id: zod.z.number().optional(),
|
|
10007
|
+
image: zod.z.string().optional(),
|
|
10008
|
+
images: zod.z.string().optional(),
|
|
10009
|
+
integration_overview_html: zod.z.string().nullable().optional(),
|
|
10010
|
+
internal_id: zod.z.string(),
|
|
10011
|
+
invite_url: zod.z.string().nullable().optional(),
|
|
10012
|
+
is_beta: zod.z.string().optional(),
|
|
10013
|
+
is_built_in: zod.z.string().optional(),
|
|
10014
|
+
is_featured: zod.z.string().optional(),
|
|
10015
|
+
is_premium: zod.z.boolean().optional(),
|
|
10016
|
+
is_public: zod.z.string().optional(),
|
|
10017
|
+
is_upcoming: zod.z.string().optional(),
|
|
10018
|
+
learn_more_url: zod.z.string(),
|
|
9866
10019
|
name: zod.z.string(),
|
|
9867
|
-
|
|
9868
|
-
|
|
9869
|
-
|
|
9870
|
-
|
|
9871
|
-
|
|
9872
|
-
|
|
9873
|
-
|
|
9874
|
-
|
|
10020
|
+
popularity: zod.z.number(),
|
|
10021
|
+
primary_color: zod.z.string(),
|
|
10022
|
+
request_count: zod.z.string().optional(),
|
|
10023
|
+
slug: zod.z.string(),
|
|
10024
|
+
zap_usage_count: zod.z.number().nullable().optional()
|
|
10025
|
+
});
|
|
10026
|
+
var ServiceSchema = zod.z.object({
|
|
10027
|
+
id: zod.z.number().optional(),
|
|
10028
|
+
canonical_id: zod.z.string().optional(),
|
|
10029
|
+
current_implementation_id: zod.z.string(),
|
|
10030
|
+
name: zod.z.string(),
|
|
10031
|
+
slug: zod.z.string(),
|
|
10032
|
+
app_url: zod.z.string().optional(),
|
|
10033
|
+
learn_more_url: zod.z.string().optional(),
|
|
10034
|
+
description: zod.z.string(),
|
|
10035
|
+
primary_color: zod.z.string(),
|
|
10036
|
+
popularity: zod.z.number(),
|
|
10037
|
+
image: zod.z.string().optional(),
|
|
10038
|
+
images: zod.z.string().optional()
|
|
9875
10039
|
});
|
|
9876
|
-
|
|
9877
|
-
|
|
10040
|
+
zod.z.object({
|
|
10041
|
+
results: zod.z.array(ServiceSchema),
|
|
10042
|
+
next: zod.z.string().nullable().optional(),
|
|
10043
|
+
previous: zod.z.string().nullable().optional()
|
|
9878
10044
|
});
|
|
9879
|
-
|
|
9880
|
-
|
|
9881
|
-
|
|
9882
|
-
|
|
9883
|
-
|
|
9884
|
-
|
|
9885
|
-
options: zod.z.record(zod.z.string(), zod.z.unknown()).optional(),
|
|
9886
|
-
config: zod.z.record(zod.z.string(), zod.z.unknown()).optional(),
|
|
9887
|
-
deleted_at: zod.z.string().nullable().optional()
|
|
10045
|
+
zod.z.object({
|
|
10046
|
+
selected_api: zod.z.string(),
|
|
10047
|
+
action: zod.z.string(),
|
|
10048
|
+
type_of: zod.z.string(),
|
|
10049
|
+
authentication_id: zod.z.union([zod.z.string(), zod.z.number()]).optional(),
|
|
10050
|
+
params: zod.z.record(zod.z.string(), zod.z.unknown()).optional()
|
|
9888
10051
|
});
|
|
9889
|
-
|
|
9890
|
-
|
|
9891
|
-
|
|
9892
|
-
|
|
9893
|
-
|
|
9894
|
-
).
|
|
9895
|
-
trash: TrashSchema
|
|
10052
|
+
zod.z.object({
|
|
10053
|
+
success: zod.z.boolean(),
|
|
10054
|
+
needs: zod.z.array(NeedSchema).optional(),
|
|
10055
|
+
errors: zod.z.array(zod.z.string()).optional(),
|
|
10056
|
+
last_fetched_at: zod.z.string().optional(),
|
|
10057
|
+
schema: zod.z.record(zod.z.string(), zod.z.unknown()).optional()
|
|
9896
10058
|
});
|
|
9897
|
-
var
|
|
9898
|
-
|
|
9899
|
-
|
|
9900
|
-
|
|
9901
|
-
|
|
9902
|
-
|
|
9903
|
-
|
|
9904
|
-
|
|
9905
|
-
|
|
9906
|
-
|
|
9907
|
-
|
|
9908
|
-
|
|
9909
|
-
|
|
9910
|
-
|
|
9911
|
-
|
|
9912
|
-
|
|
9913
|
-
|
|
9914
|
-
|
|
9915
|
-
|
|
9916
|
-
resolver: defineResolver({
|
|
9917
|
-
listItems: () => ({ data: fieldTypeChoices }),
|
|
9918
|
-
prompt: ({ items }) => ({
|
|
9919
|
-
type: "list",
|
|
9920
|
-
message: "Select field type:",
|
|
9921
|
-
choices: items
|
|
9922
|
-
})
|
|
9923
|
-
})
|
|
9924
|
-
},
|
|
9925
|
-
name: {
|
|
9926
|
-
label: "Field name",
|
|
9927
|
-
required: true,
|
|
9928
|
-
resolver: defineResolver({ type: "static", inputType: "text" })
|
|
9929
|
-
}
|
|
9930
|
-
}
|
|
10059
|
+
var ImplementationSchema = zod.z.object({
|
|
10060
|
+
selected_api: zod.z.string(),
|
|
10061
|
+
app_id: zod.z.number().optional(),
|
|
10062
|
+
auth_type: zod.z.string().optional(),
|
|
10063
|
+
auth_fields: zod.z.string().optional(),
|
|
10064
|
+
actions: zod.z.array(ActionSchema).optional(),
|
|
10065
|
+
is_deprecated: zod.z.boolean().optional(),
|
|
10066
|
+
is_private_only: zod.z.boolean().optional(),
|
|
10067
|
+
is_invite_only: zod.z.boolean().optional(),
|
|
10068
|
+
is_beta: zod.z.boolean().optional().default(false),
|
|
10069
|
+
is_premium: zod.z.boolean().optional().default(false),
|
|
10070
|
+
is_hidden: zod.z.string().optional(),
|
|
10071
|
+
name: zod.z.string().optional(),
|
|
10072
|
+
slug: zod.z.string().optional(),
|
|
10073
|
+
images: zod.z.record(zod.z.string(), zod.z.string().nullable()).optional(),
|
|
10074
|
+
primary_color: zod.z.string().optional(),
|
|
10075
|
+
secondary_color: zod.z.string().optional(),
|
|
10076
|
+
current_implementation: zod.z.string().optional(),
|
|
10077
|
+
other_implementations: zod.z.string().optional()
|
|
9931
10078
|
});
|
|
9932
|
-
|
|
9933
|
-
|
|
9934
|
-
|
|
9935
|
-
|
|
10079
|
+
zod.z.object({
|
|
10080
|
+
count: zod.z.number(),
|
|
10081
|
+
next: zod.z.string().nullable().optional(),
|
|
10082
|
+
previous: zod.z.string().nullable().optional(),
|
|
10083
|
+
results: zod.z.array(ImplementationSchema)
|
|
9936
10084
|
});
|
|
9937
|
-
|
|
9938
|
-
|
|
9939
|
-
|
|
9940
|
-
|
|
9941
|
-
|
|
9942
|
-
|
|
9943
|
-
|
|
9944
|
-
|
|
9945
|
-
|
|
9946
|
-
|
|
9947
|
-
|
|
9948
|
-
|
|
9949
|
-
|
|
9950
|
-
|
|
9951
|
-
|
|
9952
|
-
|
|
9953
|
-
|
|
9954
|
-
|
|
9955
|
-
|
|
9956
|
-
|
|
9957
|
-
|
|
9958
|
-
|
|
9959
|
-
|
|
9960
|
-
|
|
9961
|
-
|
|
9962
|
-
|
|
9963
|
-
|
|
9964
|
-
return props;
|
|
9965
|
-
}
|
|
9966
|
-
function makeRecordsResolver(includeRecordId) {
|
|
9967
|
-
const singleRecordResolver = defineResolver({
|
|
9968
|
-
type: "object",
|
|
9969
|
-
imports: [listTableFieldsRef2],
|
|
9970
|
-
requireParameters: ["table"],
|
|
9971
|
-
// The record-id resolver is import-bearing, so it lives in `definitions` and
|
|
9972
|
-
// is reached by `{ ref }` from the built `id` field (updates only).
|
|
9973
|
-
definitions: includeRecordId ? { recordId: tableRecordIdResolver } : {},
|
|
9974
|
-
getProperties: async ({ imports, input }) => {
|
|
9975
|
-
const { data: fields } = await imports.listTableFields({
|
|
9976
|
-
table: input.table
|
|
9977
|
-
});
|
|
9978
|
-
const props = {
|
|
9979
|
-
data: {
|
|
9980
|
-
label: "Field values",
|
|
9981
|
-
resolver: { type: "object", properties: buildDataFields(fields) }
|
|
9982
|
-
}
|
|
9983
|
-
};
|
|
9984
|
-
if (includeRecordId) {
|
|
9985
|
-
props.id = {
|
|
9986
|
-
label: "Record",
|
|
9987
|
-
required: true,
|
|
9988
|
-
resolver: { ref: "recordId" }
|
|
9989
|
-
};
|
|
9990
|
-
}
|
|
9991
|
-
return props;
|
|
9992
|
-
}
|
|
9993
|
-
});
|
|
9994
|
-
return defineResolver({
|
|
9995
|
-
type: "array",
|
|
9996
|
-
requireParameters: ["table"],
|
|
9997
|
-
minItems: 1,
|
|
9998
|
-
items: singleRecordResolver
|
|
9999
|
-
});
|
|
10000
|
-
}
|
|
10001
|
-
var tableRecordsResolver = makeRecordsResolver(false);
|
|
10002
|
-
var tableUpdateRecordsResolver = makeRecordsResolver(true);
|
|
10003
|
-
|
|
10004
|
-
// src/resolvers/tableFilters.ts
|
|
10005
|
-
var listTableFieldsRef3 = declareMethod({ id: "listTableFields" });
|
|
10006
|
-
var FILTER_OPERATORS = [
|
|
10007
|
-
{ label: "equals", value: "exact" },
|
|
10008
|
-
{ label: "not equals", value: "different" },
|
|
10009
|
-
{ label: "contains", value: "contains" },
|
|
10010
|
-
{ label: "contains (case-insensitive)", value: "icontains" },
|
|
10011
|
-
{ label: "starts with", value: "startswith" },
|
|
10012
|
-
{ label: "search", value: "search" },
|
|
10013
|
-
{ label: "greater than", value: "gt" },
|
|
10014
|
-
{ label: "greater than or equal", value: "gte" },
|
|
10015
|
-
{ label: "less than", value: "lt" },
|
|
10016
|
-
{ label: "less than or equal", value: "lte" },
|
|
10017
|
-
{ label: "in range", value: "range" },
|
|
10018
|
-
{ label: "in list", value: "in" },
|
|
10019
|
-
{ label: "is empty", value: "isnull" },
|
|
10020
|
-
{ label: "is within (date)", value: "is_within" }
|
|
10021
|
-
];
|
|
10022
|
-
function fieldKeyChoices(fields) {
|
|
10023
|
-
return fields.flatMap((field) => {
|
|
10024
|
-
const components = NESTED_COMPONENTS[field.type];
|
|
10025
|
-
if (components && components.size > 1) {
|
|
10026
|
-
return [...components].map((component) => ({
|
|
10027
|
-
label: `${field.name}__${component} (${field.id}, ${field.type})`,
|
|
10028
|
-
value: `${field.name}__${component}`
|
|
10029
|
-
}));
|
|
10030
|
-
}
|
|
10031
|
-
return {
|
|
10032
|
-
label: `${field.name} (${field.id}${components ? `, ${field.type}` : ""})`,
|
|
10033
|
-
value: components ? `${field.name}__${[...components][0]}` : field.name
|
|
10034
|
-
};
|
|
10035
|
-
});
|
|
10036
|
-
}
|
|
10037
|
-
var singleFilterResolver = defineResolver({
|
|
10038
|
-
type: "object",
|
|
10039
|
-
imports: [listTableFieldsRef3],
|
|
10040
|
-
requireParameters: ["table"],
|
|
10041
|
-
getProperties: async ({ imports, input }) => {
|
|
10042
|
-
const { data: fields } = await imports.listTableFields({
|
|
10043
|
-
table: input.table
|
|
10044
|
-
});
|
|
10045
|
-
const choices = fieldKeyChoices(fields);
|
|
10046
|
-
const props = {
|
|
10047
|
-
fieldKey: {
|
|
10048
|
-
label: "Field",
|
|
10049
|
-
required: true,
|
|
10050
|
-
resolver: {
|
|
10051
|
-
type: "dynamic",
|
|
10052
|
-
listItems: () => ({ data: choices }),
|
|
10053
|
-
prompt: () => ({
|
|
10054
|
-
type: "list",
|
|
10055
|
-
message: "Select field:",
|
|
10056
|
-
choices
|
|
10057
|
-
})
|
|
10058
|
-
}
|
|
10059
|
-
},
|
|
10060
|
-
operator: {
|
|
10061
|
-
label: "Operator",
|
|
10062
|
-
required: true,
|
|
10063
|
-
resolver: {
|
|
10064
|
-
type: "dynamic",
|
|
10065
|
-
listItems: () => ({ data: FILTER_OPERATORS }),
|
|
10066
|
-
prompt: () => ({
|
|
10067
|
-
type: "list",
|
|
10068
|
-
message: "Select operator:",
|
|
10069
|
-
choices: FILTER_OPERATORS
|
|
10070
|
-
})
|
|
10071
|
-
}
|
|
10072
|
-
},
|
|
10073
|
-
value: {
|
|
10074
|
-
label: "Value",
|
|
10075
|
-
required: false,
|
|
10076
|
-
resolver: { type: "static", inputType: "text" }
|
|
10077
|
-
}
|
|
10078
|
-
};
|
|
10079
|
-
return props;
|
|
10080
|
-
}
|
|
10085
|
+
var NeedChoicesResponseMetaSchema = zod.z.object({
|
|
10086
|
+
page: zod.z.string().nullable().optional()
|
|
10087
|
+
});
|
|
10088
|
+
var NeedChoicesResponseLinksSchema = zod.z.object({
|
|
10089
|
+
next: zod.z.string().nullable().optional(),
|
|
10090
|
+
prev: zod.z.string().nullable().optional()
|
|
10091
|
+
});
|
|
10092
|
+
zod.z.object({
|
|
10093
|
+
selected_api: zod.z.string().optional().describe(
|
|
10094
|
+
"Something like `SlackAPI` (for Python apps) or `SplitwiseCLIAPI@1.0.0` (for CLI apps). Non-public apps are fine as long as the authed user can access them."
|
|
10095
|
+
),
|
|
10096
|
+
authentication_id: zod.z.union([zod.z.string(), zod.z.number()]).optional().describe(
|
|
10097
|
+
"If the app needs auth, provide an `authentication_id` that has the `selected_api` of the app you want to run. Can be any auth visible to the user (including shared)."
|
|
10098
|
+
),
|
|
10099
|
+
params: zod.z.record(zod.z.string(), zod.z.unknown()).optional().describe(
|
|
10100
|
+
"Object that matches the input the node would normally get. Has all the same keys/types as the `needs` of the action."
|
|
10101
|
+
),
|
|
10102
|
+
page: zod.z.number().optional().default(0),
|
|
10103
|
+
prefill: zod.z.string().optional().describe(
|
|
10104
|
+
"The prefill string to indicate what we're fetching choices for. Likely something like `spreadsheet.id.title`. Must be provided alongside `selected_api` if both `action_id` and `input_field_id` are not."
|
|
10105
|
+
),
|
|
10106
|
+
action_id: zod.z.string().optional().describe(
|
|
10107
|
+
"The id that will be used to lookup the Action for prefill lookup. If provided, `input_field_id` is required, else `prefill` must be provided."
|
|
10108
|
+
),
|
|
10109
|
+
input_field_id: zod.z.string().optional().describe(
|
|
10110
|
+
"The id (key) of the input field (Need) that dynamic choices are being retrieved for. If provided, `action_id` is required, else `prefill` must be provided."
|
|
10111
|
+
)
|
|
10081
10112
|
});
|
|
10082
|
-
|
|
10083
|
-
|
|
10084
|
-
|
|
10085
|
-
|
|
10086
|
-
|
|
10113
|
+
zod.z.object({
|
|
10114
|
+
success: zod.z.boolean(),
|
|
10115
|
+
choices: zod.z.array(NeedChoicesSchema).optional(),
|
|
10116
|
+
next_page: zod.z.number().optional(),
|
|
10117
|
+
errors: zod.z.array(zod.z.string()).optional(),
|
|
10118
|
+
meta: NeedChoicesResponseMetaSchema.optional(),
|
|
10119
|
+
links: NeedChoicesResponseLinksSchema.optional()
|
|
10087
10120
|
});
|
|
10088
10121
|
|
|
10089
|
-
// src/
|
|
10090
|
-
var
|
|
10091
|
-
|
|
10092
|
-
|
|
10093
|
-
|
|
10094
|
-
|
|
10095
|
-
|
|
10096
|
-
|
|
10097
|
-
|
|
10098
|
-
|
|
10099
|
-
|
|
10100
|
-
|
|
10101
|
-
|
|
10102
|
-
|
|
10103
|
-
|
|
10104
|
-
|
|
10105
|
-
|
|
10106
|
-
|
|
10107
|
-
|
|
10108
|
-
|
|
10109
|
-
|
|
10110
|
-
|
|
10111
|
-
|
|
10112
|
-
|
|
10113
|
-
|
|
10114
|
-
});
|
|
10115
|
-
const choices = fieldKeyChoices2(fields);
|
|
10116
|
-
const props = {
|
|
10117
|
-
fieldKey: {
|
|
10118
|
-
label: "Field",
|
|
10119
|
-
required: true,
|
|
10120
|
-
resolver: {
|
|
10121
|
-
type: "dynamic",
|
|
10122
|
-
listItems: () => ({ data: choices }),
|
|
10123
|
-
prompt: () => ({
|
|
10124
|
-
type: "list",
|
|
10125
|
-
message: "Select field:",
|
|
10126
|
-
choices
|
|
10127
|
-
})
|
|
10128
|
-
}
|
|
10129
|
-
},
|
|
10130
|
-
direction: {
|
|
10131
|
-
label: "Direction",
|
|
10132
|
-
required: true,
|
|
10133
|
-
resolver: {
|
|
10134
|
-
type: "dynamic",
|
|
10135
|
-
listItems: () => ({ data: DIRECTION_CHOICES }),
|
|
10136
|
-
prompt: () => ({
|
|
10137
|
-
type: "list",
|
|
10138
|
-
message: "Select direction:",
|
|
10139
|
-
choices: DIRECTION_CHOICES
|
|
10140
|
-
})
|
|
10141
|
-
}
|
|
10142
|
-
}
|
|
10143
|
-
};
|
|
10144
|
-
return props;
|
|
10122
|
+
// src/schemas/Action.ts
|
|
10123
|
+
var ActionItemSchema = ActionSchema.omit({
|
|
10124
|
+
type: true,
|
|
10125
|
+
name: true,
|
|
10126
|
+
selected_api: true
|
|
10127
|
+
}).extend({
|
|
10128
|
+
app_key: zod.z.string(),
|
|
10129
|
+
// App key without version (extracted from selected_api)
|
|
10130
|
+
app_version: zod.z.string().optional(),
|
|
10131
|
+
// Version extracted from selected_api
|
|
10132
|
+
action_type: ActionSchema.shape.type,
|
|
10133
|
+
// Mapped from original 'type' field
|
|
10134
|
+
title: zod.z.string(),
|
|
10135
|
+
// Mapped from original 'name' field
|
|
10136
|
+
type: zod.z.literal("action")
|
|
10137
|
+
// Fixed type identifier
|
|
10138
|
+
});
|
|
10139
|
+
|
|
10140
|
+
// src/formatters/action.ts
|
|
10141
|
+
function formatActionItem(item) {
|
|
10142
|
+
const details = [{ text: `Type: ${item.action_type}`, style: "accent" }];
|
|
10143
|
+
if (item.app_key) {
|
|
10144
|
+
details.push({ text: `App: ${item.app_key}`, style: "normal" });
|
|
10145
|
+
}
|
|
10146
|
+
if (item.description) {
|
|
10147
|
+
details.push({ text: item.description, style: "dim" });
|
|
10145
10148
|
}
|
|
10149
|
+
return {
|
|
10150
|
+
title: item.title || item.key,
|
|
10151
|
+
// `hint` is the dumb secondary string shown after the title (the action key
|
|
10152
|
+
// and, when present, its id). Replaces the deprecated `key`/`id` fields.
|
|
10153
|
+
hint: [item.key, item.id].filter((v) => Boolean(v)),
|
|
10154
|
+
description: item.description,
|
|
10155
|
+
details
|
|
10156
|
+
};
|
|
10157
|
+
}
|
|
10158
|
+
var actionItemFormatter = defineFormatter({
|
|
10159
|
+
format: ({ item }) => formatActionItem(item)
|
|
10146
10160
|
});
|
|
10147
10161
|
|
|
10148
10162
|
// src/plugins/listActions/index.ts
|
|
@@ -10241,65 +10255,37 @@ var getActionPlugin = defineMethod({
|
|
|
10241
10255
|
);
|
|
10242
10256
|
}
|
|
10243
10257
|
});
|
|
10244
|
-
|
|
10245
|
-
|
|
10246
|
-
|
|
10247
|
-
|
|
10248
|
-
|
|
10249
|
-
|
|
10250
|
-
|
|
10251
|
-
|
|
10252
|
-
|
|
10253
|
-
|
|
10254
|
-
|
|
10255
|
-
|
|
10256
|
-
|
|
10257
|
-
|
|
10258
|
-
|
|
10259
|
-
|
|
10260
|
-
|
|
10261
|
-
|
|
10262
|
-
|
|
10263
|
-
|
|
10264
|
-
|
|
10265
|
-
|
|
10266
|
-
|
|
10267
|
-
|
|
10268
|
-
|
|
10269
|
-
|
|
10270
|
-
|
|
10271
|
-
"/zapier/api/actions/v1/runs",
|
|
10272
|
-
runRequest,
|
|
10273
|
-
{
|
|
10274
|
-
approvalContext: () => policyContext.buildActionRunContext({
|
|
10275
|
-
selected_api: selectedApi,
|
|
10276
|
-
action_type: actionType,
|
|
10277
|
-
action_key: actionKey,
|
|
10278
|
-
connection_id: connectionId != null ? String(connectionId) : void 0,
|
|
10279
|
-
// Cast: inputs is Record<string, unknown> at the SDK surface;
|
|
10280
|
-
// buildActionRunContext validates it as JSON at runtime via zod
|
|
10281
|
-
// (non-JSON values like Date/undefined are rejected there).
|
|
10282
|
-
inputs: executionOptions.inputs ?? {}
|
|
10283
|
-
})
|
|
10284
|
-
}
|
|
10285
|
-
);
|
|
10286
|
-
const runId = runData.data.id;
|
|
10287
|
-
return await api.poll(`/zapier/api/actions/v1/runs/${runId}`, {
|
|
10288
|
-
successStatus: 200,
|
|
10289
|
-
pendingStatus: 202,
|
|
10290
|
-
timeoutMilliseconds: timeoutMilliseconds ?? DEFAULT_ACTION_TIMEOUT_MILLISECONDS,
|
|
10291
|
-
resource: { type: "run", id: runId },
|
|
10292
|
-
isPending: (result) => {
|
|
10293
|
-
const data = result?.data;
|
|
10294
|
-
return data?.status === "waiting";
|
|
10295
|
-
},
|
|
10296
|
-
resultExtractor: (result) => result.data
|
|
10297
|
-
});
|
|
10298
|
-
}
|
|
10258
|
+
var CreateActionRunSchema = zod.z.object({
|
|
10259
|
+
app: AppPropertySchema,
|
|
10260
|
+
actionType: ActionTypePropertySchema,
|
|
10261
|
+
action: ActionPropertySchema,
|
|
10262
|
+
connection: ConnectionPropertySchema.optional().describe(
|
|
10263
|
+
"Connection alias or connection ID (UUID or positive integer). Required if the action needs a connection to authenticate and interact with the service. Strings that match a key in the connections map are resolved against it; otherwise the value is used as a connection ID directly."
|
|
10264
|
+
),
|
|
10265
|
+
inputs: InputsPropertySchema.optional().describe(
|
|
10266
|
+
"Input parameters for the action"
|
|
10267
|
+
),
|
|
10268
|
+
page: zod.z.string().optional().describe(
|
|
10269
|
+
"Page to fetch for bulk read actions. Pass the `next_page` a previous run returned to fetch the following page."
|
|
10270
|
+
),
|
|
10271
|
+
callbackUrl: zod.z.string().url().optional().describe(
|
|
10272
|
+
"URL Zapier posts the finished run to, so you do not have to poll for it. Must use HTTPS and resolve to a public host, so a local receiver needs a tunnel. The body matches what `getActionRun` returns. Verify the `Zapier-Callback-Signature` header, and expect the same run to arrive more than once."
|
|
10273
|
+
).meta({ valueHint: "url" })
|
|
10274
|
+
}).describe(
|
|
10275
|
+
"Start an action run and return its ID without waiting for the result. Running an action is asynchronous: this hands back a run ID immediately, and `getActionRun` fetches the outcome. Reach for this pair when you want to start work and collect it later (fan out many runs, hand the ID to another process, survive a restart). `runAction` is the one-call form that starts a run and waits for its result."
|
|
10276
|
+
);
|
|
10277
|
+
var ActionRunStartedItemSchema = zod.z.object({
|
|
10278
|
+
id: zod.z.string().describe(
|
|
10279
|
+
"Action run ID. Pass it as the `run` for `getActionRun` to fetch the run's result."
|
|
10280
|
+
),
|
|
10281
|
+
implementation_id: zod.z.string().describe(
|
|
10282
|
+
"Versioned implementation ID the run was started against (e.g. 'SlackCLIAPI@1.21.1'). The versionless app key is the part before the `@`."
|
|
10283
|
+
)
|
|
10284
|
+
});
|
|
10299
10285
|
var CONTEXT_CACHE_TTL_MILLISECONDS = 6e4;
|
|
10300
10286
|
var CONTEXT_CACHE_MAX_SIZE = 500;
|
|
10301
|
-
var
|
|
10302
|
-
name: "
|
|
10287
|
+
var createActionRunPlugin = defineMethod({
|
|
10288
|
+
name: "createActionRun",
|
|
10303
10289
|
imports: [
|
|
10304
10290
|
connectionsPluginRef,
|
|
10305
10291
|
manifestPluginRef,
|
|
@@ -10307,14 +10293,11 @@ var runActionPlugin = defineMethod({
|
|
|
10307
10293
|
getActionPlugin
|
|
10308
10294
|
],
|
|
10309
10295
|
categories: ["action"],
|
|
10310
|
-
|
|
10311
|
-
|
|
10312
|
-
|
|
10313
|
-
|
|
10314
|
-
|
|
10315
|
-
// No defaultPageSize — leave the default to the Actions API rather than
|
|
10316
|
-
// eagerly running more actions than the user intends (avoids app rate limits).
|
|
10317
|
-
output: "list",
|
|
10296
|
+
type: "create",
|
|
10297
|
+
itemType: "StartedActionRun",
|
|
10298
|
+
inputSchema: CreateActionRunSchema,
|
|
10299
|
+
outputSchema: ActionRunStartedItemSchema,
|
|
10300
|
+
output: "item",
|
|
10318
10301
|
resolvers: {
|
|
10319
10302
|
app: appKeyResolver,
|
|
10320
10303
|
actionType: actionTypeResolver,
|
|
@@ -10322,14 +10305,12 @@ var runActionPlugin = defineMethod({
|
|
|
10322
10305
|
connection: connectionIdResolver,
|
|
10323
10306
|
inputs: inputsResolver
|
|
10324
10307
|
},
|
|
10325
|
-
// A per-SDK-instance TTL cache of resolved (selectedApi, actionId), built once
|
|
10326
|
-
// in setup so it persists across calls. The imports it resolves through
|
|
10327
|
-
// (`manifest.getVersionedImplementationId`, `getAction`) are threaded in per
|
|
10328
|
-
// call from `run`, not captured here.
|
|
10329
10308
|
setup: () => {
|
|
10330
10309
|
const cache = /* @__PURE__ */ new Map();
|
|
10331
10310
|
function evictIfNeeded() {
|
|
10332
|
-
if (cache.size < CONTEXT_CACHE_MAX_SIZE)
|
|
10311
|
+
if (cache.size < CONTEXT_CACHE_MAX_SIZE) {
|
|
10312
|
+
return;
|
|
10313
|
+
}
|
|
10333
10314
|
const now = Date.now();
|
|
10334
10315
|
let oldestKey;
|
|
10335
10316
|
let oldestExpiry = Infinity;
|
|
@@ -10343,13 +10324,15 @@ var runActionPlugin = defineMethod({
|
|
|
10343
10324
|
oldestKey = key;
|
|
10344
10325
|
}
|
|
10345
10326
|
}
|
|
10346
|
-
if (!evictedAny && oldestKey)
|
|
10327
|
+
if (!evictedAny && oldestKey) {
|
|
10328
|
+
cache.delete(oldestKey);
|
|
10329
|
+
}
|
|
10347
10330
|
}
|
|
10348
|
-
async function
|
|
10331
|
+
async function resolveActionRunContext(options) {
|
|
10349
10332
|
const { imports, appKey, actionKey, actionType } = options;
|
|
10350
10333
|
const getVersionedImplementationId = imports.manifest.getVersionedImplementationId;
|
|
10351
|
-
const
|
|
10352
|
-
if (!
|
|
10334
|
+
const implementationId = await getVersionedImplementationId(appKey);
|
|
10335
|
+
if (!implementationId) {
|
|
10353
10336
|
throw new ZapierConfigurationError(
|
|
10354
10337
|
"No current_implementation_id found for app",
|
|
10355
10338
|
{ configType: "current_implementation_id" }
|
|
@@ -10365,15 +10348,19 @@ var runActionPlugin = defineMethod({
|
|
|
10365
10348
|
`Action type mismatch: expected ${actionType}, got ${actionData.data.action_type}`
|
|
10366
10349
|
);
|
|
10367
10350
|
}
|
|
10368
|
-
return {
|
|
10351
|
+
return { implementationId, actionId: actionData.data.id };
|
|
10369
10352
|
}
|
|
10370
|
-
function
|
|
10353
|
+
function getActionRunContext(options) {
|
|
10371
10354
|
const contextKey = `${options.appKey}:${options.actionKey}:${options.actionType}`;
|
|
10372
10355
|
const cached = cache.get(contextKey);
|
|
10373
|
-
if (cached && Date.now() < cached.expiresAt)
|
|
10374
|
-
|
|
10356
|
+
if (cached && Date.now() < cached.expiresAt) {
|
|
10357
|
+
return cached.promise;
|
|
10358
|
+
}
|
|
10359
|
+
const pending = resolveActionRunContext(options).catch((error) => {
|
|
10375
10360
|
const current = cache.get(contextKey);
|
|
10376
|
-
if (current?.promise === pending)
|
|
10361
|
+
if (current?.promise === pending) {
|
|
10362
|
+
cache.delete(contextKey);
|
|
10363
|
+
}
|
|
10377
10364
|
throw error;
|
|
10378
10365
|
});
|
|
10379
10366
|
evictIfNeeded();
|
|
@@ -10383,11 +10370,105 @@ var runActionPlugin = defineMethod({
|
|
|
10383
10370
|
});
|
|
10384
10371
|
return pending;
|
|
10385
10372
|
}
|
|
10386
|
-
return {
|
|
10373
|
+
return { getActionRunContext };
|
|
10387
10374
|
},
|
|
10388
10375
|
run: async ({ imports, input, state, annotate }) => {
|
|
10389
10376
|
const api = imports.api;
|
|
10390
|
-
const
|
|
10377
|
+
const {
|
|
10378
|
+
app: appKey,
|
|
10379
|
+
action: actionKey,
|
|
10380
|
+
actionType,
|
|
10381
|
+
connection,
|
|
10382
|
+
inputs = {},
|
|
10383
|
+
page,
|
|
10384
|
+
callbackUrl
|
|
10385
|
+
} = input;
|
|
10386
|
+
const connectionId = await resolveConnectionId({
|
|
10387
|
+
connection,
|
|
10388
|
+
resolveConnection: imports.connections.resolveConnection
|
|
10389
|
+
});
|
|
10390
|
+
const { implementationId, actionId } = await state.getActionRunContext({
|
|
10391
|
+
imports,
|
|
10392
|
+
appKey,
|
|
10393
|
+
actionKey,
|
|
10394
|
+
actionType
|
|
10395
|
+
});
|
|
10396
|
+
annotate({ selectedApi: implementationId });
|
|
10397
|
+
const runRequestData = {
|
|
10398
|
+
selected_api: implementationId,
|
|
10399
|
+
// Some actions require the action ID, but it's not guaranteed available
|
|
10400
|
+
// at retrieval time (legacy), so pass everything through.
|
|
10401
|
+
action_id: actionId,
|
|
10402
|
+
action_key: actionKey,
|
|
10403
|
+
action_type: actionType,
|
|
10404
|
+
inputs
|
|
10405
|
+
};
|
|
10406
|
+
if (connectionId != null) {
|
|
10407
|
+
runRequestData.authentication_id = connectionId;
|
|
10408
|
+
}
|
|
10409
|
+
if (page) {
|
|
10410
|
+
runRequestData.page = page;
|
|
10411
|
+
}
|
|
10412
|
+
if (callbackUrl) {
|
|
10413
|
+
runRequestData.callback_url = callbackUrl;
|
|
10414
|
+
}
|
|
10415
|
+
const runData = await api.post(
|
|
10416
|
+
ACTION_RUNS_PATH,
|
|
10417
|
+
{ data: runRequestData },
|
|
10418
|
+
{
|
|
10419
|
+
approvalContext: () => policyContext.buildActionRunContext({
|
|
10420
|
+
selected_api: implementationId,
|
|
10421
|
+
action_type: actionType,
|
|
10422
|
+
action_key: actionKey,
|
|
10423
|
+
connection_id: connectionId != null ? String(connectionId) : void 0,
|
|
10424
|
+
// `inputs` is `Record<string, unknown>` at the SDK surface;
|
|
10425
|
+
// buildActionRunContext validates it as JSON at runtime via zod
|
|
10426
|
+
// (non-JSON values like Date/undefined are rejected there).
|
|
10427
|
+
inputs
|
|
10428
|
+
})
|
|
10429
|
+
}
|
|
10430
|
+
);
|
|
10431
|
+
return {
|
|
10432
|
+
data: {
|
|
10433
|
+
id: runData.data.id,
|
|
10434
|
+
implementation_id: implementationId
|
|
10435
|
+
}
|
|
10436
|
+
};
|
|
10437
|
+
}
|
|
10438
|
+
});
|
|
10439
|
+
|
|
10440
|
+
// src/utils/action-run-wire.ts
|
|
10441
|
+
function actionRunPath(run) {
|
|
10442
|
+
return `${ACTION_RUNS_PATH}/${encodeURIComponent(run)}`;
|
|
10443
|
+
}
|
|
10444
|
+
function actionRunPayload(body) {
|
|
10445
|
+
return body?.data;
|
|
10446
|
+
}
|
|
10447
|
+
function isActionRunPending(body) {
|
|
10448
|
+
return actionRunPayload(body)?.status === "waiting";
|
|
10449
|
+
}
|
|
10450
|
+
|
|
10451
|
+
// src/plugins/runAction/index.ts
|
|
10452
|
+
var runActionPlugin = defineMethod({
|
|
10453
|
+
name: "runAction",
|
|
10454
|
+
imports: [apiPluginRef, connectionsPluginRef, createActionRunPlugin],
|
|
10455
|
+
categories: ["action"],
|
|
10456
|
+
itemType: "ActionResult",
|
|
10457
|
+
inputSchema: RunActionInputSchema,
|
|
10458
|
+
outputSchema: ActionResultItemSchema,
|
|
10459
|
+
skipOutputValidation: true,
|
|
10460
|
+
formatter: actionResultItemFormatter,
|
|
10461
|
+
// No defaultPageSize — leave the default to the Actions API rather than
|
|
10462
|
+
// eagerly running more actions than the user intends (avoids app rate limits).
|
|
10463
|
+
output: "list",
|
|
10464
|
+
resolvers: {
|
|
10465
|
+
app: appKeyResolver,
|
|
10466
|
+
actionType: actionTypeResolver,
|
|
10467
|
+
action: actionKeyResolver,
|
|
10468
|
+
connection: connectionIdResolver,
|
|
10469
|
+
inputs: inputsResolver
|
|
10470
|
+
},
|
|
10471
|
+
run: async ({ imports, input, annotate }) => {
|
|
10391
10472
|
const appKey = "app" in input ? input.app : input.appKey;
|
|
10392
10473
|
const actionKey = "action" in input ? input.action : input.actionKey;
|
|
10393
10474
|
const {
|
|
@@ -10398,39 +10479,40 @@ var runActionPlugin = defineMethod({
|
|
|
10398
10479
|
inputs = {},
|
|
10399
10480
|
cursor
|
|
10400
10481
|
} = input;
|
|
10401
|
-
const timeoutMilliseconds = input.timeoutSeconds != null ? input.timeoutSeconds * 1e3 : input.timeoutMs;
|
|
10482
|
+
const timeoutMilliseconds = (input.timeoutSeconds != null ? input.timeoutSeconds * 1e3 : input.timeoutMs) ?? DEFAULT_ACTION_TIMEOUT_MILLISECONDS;
|
|
10402
10483
|
const resolvedConnectionId = await resolveConnectionId({
|
|
10403
10484
|
connectionId,
|
|
10404
10485
|
connection,
|
|
10405
10486
|
authenticationId,
|
|
10406
|
-
resolveConnection
|
|
10407
|
-
});
|
|
10408
|
-
const { selectedApi, actionId } = await state.getRunActionContext({
|
|
10409
|
-
imports,
|
|
10410
|
-
appKey,
|
|
10411
|
-
actionKey,
|
|
10412
|
-
actionType
|
|
10487
|
+
resolveConnection: imports.connections.resolveConnection
|
|
10413
10488
|
});
|
|
10414
|
-
|
|
10415
|
-
|
|
10416
|
-
api,
|
|
10417
|
-
selectedApi,
|
|
10418
|
-
// Some actions require the action ID, but it's not guaranteed available at
|
|
10419
|
-
// retrieval time (legacy), so pass everything through.
|
|
10420
|
-
actionId,
|
|
10421
|
-
actionKey,
|
|
10489
|
+
const { data: started } = await imports.createActionRun({
|
|
10490
|
+
app: appKey,
|
|
10422
10491
|
actionType,
|
|
10423
|
-
|
|
10424
|
-
|
|
10425
|
-
|
|
10426
|
-
|
|
10492
|
+
action: actionKey,
|
|
10493
|
+
connection: resolvedConnectionId,
|
|
10494
|
+
inputs,
|
|
10495
|
+
page: cursor
|
|
10427
10496
|
});
|
|
10428
|
-
|
|
10429
|
-
|
|
10497
|
+
annotate({ selectedApi: started.implementation_id });
|
|
10498
|
+
const run = await imports.api.poll(
|
|
10499
|
+
actionRunPath(started.id),
|
|
10500
|
+
{
|
|
10501
|
+
resource: { type: "run", id: started.id },
|
|
10502
|
+
successStatus: 200,
|
|
10503
|
+
pendingStatus: 202,
|
|
10504
|
+
timeoutMilliseconds,
|
|
10505
|
+
isPending: isActionRunPending,
|
|
10506
|
+
resultExtractor: (body) => actionRunPayload(body) ?? {}
|
|
10507
|
+
}
|
|
10508
|
+
);
|
|
10509
|
+
const errors = run.errors ?? [];
|
|
10510
|
+
if (errors.length > 0) {
|
|
10511
|
+
const errorMessage2 = errors.map((error) => error.detail || error.title || "Unknown error").join("; ");
|
|
10430
10512
|
throw new ZapierActionError(`Action execution failed: ${errorMessage2}`, {
|
|
10431
10513
|
appKey,
|
|
10432
10514
|
actionKey,
|
|
10433
|
-
errors:
|
|
10515
|
+
errors: errors.map(
|
|
10434
10516
|
(error) => ({
|
|
10435
10517
|
status: 200,
|
|
10436
10518
|
code: error.code ?? "unknown",
|
|
@@ -10441,10 +10523,10 @@ var runActionPlugin = defineMethod({
|
|
|
10441
10523
|
});
|
|
10442
10524
|
}
|
|
10443
10525
|
return {
|
|
10444
|
-
data:
|
|
10526
|
+
data: run.results ?? [],
|
|
10445
10527
|
// Coerce to a string: the API returns a numeric page index, but
|
|
10446
10528
|
// `SdkPage.nextCursor` is a string (and the page guard enforces it).
|
|
10447
|
-
nextCursor:
|
|
10529
|
+
nextCursor: run.next_page != null ? String(run.next_page) : void 0
|
|
10448
10530
|
};
|
|
10449
10531
|
}
|
|
10450
10532
|
});
|
|
@@ -11875,6 +11957,65 @@ var findUniqueConnectionPlugin = defineMethod({
|
|
|
11875
11957
|
return { data: connectionsResponse.data[0] };
|
|
11876
11958
|
}
|
|
11877
11959
|
});
|
|
11960
|
+
var GetActionRunSchema = zod.z.object({
|
|
11961
|
+
run: zod.z.string().min(1).describe("Action run ID returned by `createActionRun`")
|
|
11962
|
+
}).describe(
|
|
11963
|
+
"Fetch the current state of an action run started by `createActionRun`. This is a point-in-time read that returns immediately: a run Zapier has not finished executing comes back with status `waiting`, so call again to check for a result. `runAction` starts a run and waits for its result in one call. Results are stored for seven days after the run was created."
|
|
11964
|
+
);
|
|
11965
|
+
var ActionRunStatusSchema = openEnum(
|
|
11966
|
+
["waiting", "success", "error", "unknown"],
|
|
11967
|
+
"Where the run is in its lifecycle. `waiting` means Zapier is still executing it; `error` means the app returned a failure (details in `errors`). `unknown` means the response carried no status, so the outcome could not be determined \u2014 treat it as inconclusive rather than as success."
|
|
11968
|
+
);
|
|
11969
|
+
var ActionRunErrorSchema = zod.z.object({
|
|
11970
|
+
code: zod.z.string().optional().describe("Machine-readable error category"),
|
|
11971
|
+
title: zod.z.string().nullable().optional().describe("Short error label"),
|
|
11972
|
+
detail: zod.z.string().optional().describe("Human-readable error detail")
|
|
11973
|
+
});
|
|
11974
|
+
var ActionRunItemSchema = zod.z.object({
|
|
11975
|
+
id: zod.z.string().describe("Action run ID"),
|
|
11976
|
+
status: ActionRunStatusSchema,
|
|
11977
|
+
results: zod.z.array(zod.z.unknown()).describe(
|
|
11978
|
+
"Records the action produced. Can be empty even on a successful run."
|
|
11979
|
+
),
|
|
11980
|
+
next_page: zod.z.string().optional().describe(
|
|
11981
|
+
"For bulk read actions, the following page. Pass it back as the `page` for `createActionRun` to fetch that page."
|
|
11982
|
+
),
|
|
11983
|
+
errors: zod.z.array(ActionRunErrorSchema).describe("Errors the app returned while running the action")
|
|
11984
|
+
});
|
|
11985
|
+
|
|
11986
|
+
// src/plugins/getActionRun/index.ts
|
|
11987
|
+
function toActionRun(runId, payload) {
|
|
11988
|
+
if (!payload) {
|
|
11989
|
+
return { id: runId, status: "waiting", results: [], errors: [] };
|
|
11990
|
+
}
|
|
11991
|
+
return {
|
|
11992
|
+
id: payload.id ?? runId,
|
|
11993
|
+
// Never infer success from an absent status.
|
|
11994
|
+
status: payload.status ?? "unknown",
|
|
11995
|
+
results: payload.results ?? [],
|
|
11996
|
+
// The API answers with either a page token or a numeric page index, but
|
|
11997
|
+
// `createActionRun` takes `page` as a string, so normalize to one type the
|
|
11998
|
+
// caller can hand straight back.
|
|
11999
|
+
...payload.next_page != null ? { next_page: String(payload.next_page) } : {},
|
|
12000
|
+
errors: payload.errors ?? []
|
|
12001
|
+
};
|
|
12002
|
+
}
|
|
12003
|
+
var getActionRunPlugin = defineMethod({
|
|
12004
|
+
name: "getActionRun",
|
|
12005
|
+
imports: [apiPluginRef],
|
|
12006
|
+
categories: ["action"],
|
|
12007
|
+
itemType: "ActionRun",
|
|
12008
|
+
inputSchema: GetActionRunSchema,
|
|
12009
|
+
outputSchema: ActionRunItemSchema,
|
|
12010
|
+
output: "item",
|
|
12011
|
+
run: async ({ imports, input }) => {
|
|
12012
|
+
const body = await imports.api.get(
|
|
12013
|
+
actionRunPath(input.run),
|
|
12014
|
+
{ resource: { type: "run", id: input.run } }
|
|
12015
|
+
);
|
|
12016
|
+
return { data: toActionRun(input.run, actionRunPayload(body)) };
|
|
12017
|
+
}
|
|
12018
|
+
});
|
|
11878
12019
|
var RelayRequestSchema = zod.z.object({
|
|
11879
12020
|
url: zod.z.string().url().describe("The URL to request (will be proxied through Relay)"),
|
|
11880
12021
|
method: zod.z.enum(["GET", "POST", "PUT", "DELETE", "PATCH", "HEAD", "OPTIONS"]).optional().describe("HTTP method"),
|
|
@@ -15701,6 +15842,8 @@ var zapierSdkPlugin = definePlugin({
|
|
|
15701
15842
|
listInputFieldsDeprecatedPlugin,
|
|
15702
15843
|
getInputFieldsSchemaDeprecatedPlugin,
|
|
15703
15844
|
listInputFieldChoicesDeprecatedPlugin,
|
|
15845
|
+
createActionRunPlugin,
|
|
15846
|
+
getActionRunPlugin,
|
|
15704
15847
|
runActionPlugin,
|
|
15705
15848
|
fetchPlugin,
|
|
15706
15849
|
requestPlugin,
|
|
@@ -15915,6 +16058,7 @@ var registryPlugin = (_sdk) => {
|
|
|
15915
16058
|
return {};
|
|
15916
16059
|
};
|
|
15917
16060
|
|
|
16061
|
+
exports.ACTION_RUNS_PATH = ACTION_RUNS_PATH;
|
|
15918
16062
|
exports.API_ID = API_ID;
|
|
15919
16063
|
exports.ActionKeyPropertySchema = ActionKeyPropertySchema;
|
|
15920
16064
|
exports.ActionPropertySchema = ActionPropertySchema;
|
|
@@ -16028,6 +16172,7 @@ exports.connectionIdGenericResolver = connectionIdGenericResolver;
|
|
|
16028
16172
|
exports.connectionIdResolver = connectionIdResolver;
|
|
16029
16173
|
exports.connectionsPlugin = connectionsPlugin;
|
|
16030
16174
|
exports.connectionsPluginRef = connectionsPluginRef;
|
|
16175
|
+
exports.createActionRunPlugin = createActionRunPlugin;
|
|
16031
16176
|
exports.createBaseEvent = createBaseEvent;
|
|
16032
16177
|
exports.createClientCredentialsPlugin = createClientCredentialsPlugin;
|
|
16033
16178
|
exports.createController = createController;
|
|
@@ -16075,6 +16220,7 @@ exports.fromFunctionPlugin = fromFunctionPlugin;
|
|
|
16075
16220
|
exports.generateEventId = generateEventId;
|
|
16076
16221
|
exports.getActionInputFieldsSchemaPlugin = getActionInputFieldsSchemaPlugin;
|
|
16077
16222
|
exports.getActionPlugin = getActionPlugin;
|
|
16223
|
+
exports.getActionRunPlugin = getActionRunPlugin;
|
|
16078
16224
|
exports.getAgent = getAgent;
|
|
16079
16225
|
exports.getAppPlugin = getAppPlugin;
|
|
16080
16226
|
exports.getBaseUrlFromCredentials = getBaseUrlFromCredentials;
|