@tool-bridge/server 0.21.1 → 0.22.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/dist/admin.js +170 -0
- package/dist/airtable-ML2GIGCH.js +790 -0
- package/dist/{alt_text_generator_ai-W7O34SNG.js → alt_text_generator_ai-FGYQAF2A.js} +12 -11
- package/dist/{amap-VOX4T2AW.js → amap-G7V65NGK.js} +221 -220
- package/dist/anthropic-6ZK24TBB.js +203 -0
- package/dist/apify-VDGYHP6W.js +248 -0
- package/dist/brave_search-TAATLZOS.js +302 -0
- package/dist/chunk-2IAI3XQM.js +302 -0
- package/dist/chunk-7ISGFRC6.js +161 -0
- package/dist/{chunk-E6JCVKW6.js → chunk-BNMLA2RC.js} +3 -3
- package/dist/chunk-HA4BGL6C.js +8429 -0
- package/dist/{chunk-KMTT3I6D.js → chunk-RMAWSG7E.js} +19172 -25717
- package/dist/{chunk-XYBU3WZH.js → chunk-RTW5VRTK.js} +3 -3
- package/dist/chunk-U7PTOA3U.js +7320 -0
- package/dist/chunk-UY6ANCOY.js +378 -0
- package/dist/{chunk-ATK45BXV.js → chunk-X7ZUTKHR.js} +4 -2
- package/dist/circleci-BQ2UWXL2.js +389 -0
- package/dist/clerk-2JYWQNOI.js +1019 -0
- package/dist/cohere-6MI7AQM4.js +185 -0
- package/dist/{confluence-B3EWPZVE.js → confluence-6Y6GDETF.js} +105 -104
- package/dist/{convertapi-EUWSQYPF.js → convertapi-HBZCSWOX.js} +32 -31
- package/dist/{currencyapi-KVTIK3GL.js → currencyapi-337U5TGI.js} +71 -71
- package/dist/deepseek-OSPASO7O.js +210 -0
- package/dist/docker_hub-3ATQOY5L.js +933 -0
- package/dist/dropbox-LSA4GM2Y.js +1305 -0
- package/dist/dub-VZPJSPI6.js +680 -0
- package/dist/e2b-6SDYQZL2.js +278 -0
- package/dist/exa-B6EUYDVP.js +332 -0
- package/dist/{fal_ai-23E7JPNT.js → fal_ai-K4Q27IME.js} +81 -80
- package/dist/{feishu-7QRIDUV6.js → feishu-4TKXG4SU.js} +528 -572
- package/dist/{feishu_custom_bot-TJ4K7QNJ.js → feishu_custom_bot-7CTEAKRB.js} +57 -53
- package/dist/figma-OUKSZLD5.js +777 -0
- package/dist/firehydrant-7MOYL7QH.js +563 -0
- package/dist/{fixer-BWON27UO.js → fixer-H2BV2NO4.js} +34 -33
- package/dist/fly-PXKY6PNH.js +469 -0
- package/dist/{front-QCGXYEDJ.js → front-UZYIV5DW.js} +104 -104
- package/dist/geocodio-NSYO7TFP.js +213 -0
- package/dist/ghost-QBKKQQMF.js +338 -0
- package/dist/github-ENLSJ4CL.js +5421 -0
- package/dist/gmail-KQSDEB47.js +1887 -0
- package/dist/googlecalendar-5YCX4SZF.js +2524 -0
- package/dist/{googledocs-BUHL4J2H.js → googledocs-SSWIVFKA.js} +341 -340
- package/dist/{grafana-GLU2DWF2.js → grafana-TF2LXDQA.js} +221 -220
- package/dist/graphhopper-CURBVHYK.js +325 -0
- package/dist/index.d.ts +1132 -332
- package/dist/index.js +31 -14
- package/dist/{ip2proxy-EZ64Y4ZH.js → ip2proxy-YNVMTZEM.js} +28 -27
- package/dist/ipgeolocation_io-NAU7VJ4J.js +315 -0
- package/dist/ipqualityscore-OT63L4TI.js +279 -0
- package/dist/{jina_ai-EFBHTBXL.js → jina_ai-6WBMBGWM.js} +23 -23
- package/dist/{jira-HQSHAA5K.js → jira-DVDVTHNO.js} +118 -117
- package/dist/langsmith-IM5N4YAU.js +593 -0
- package/dist/lemlist-277SHUQF.js +289 -0
- package/dist/{linear-K7RYFYAD.js → linear-AEPH7B5V.js} +327 -326
- package/dist/logsnag-VEWRAGBG.js +150 -0
- package/dist/main.js +57 -280
- package/dist/{mattermost-S2BRCWLQ.js → mattermost-Q3A2BIZA.js} +59 -58
- package/dist/mem0-AXS7GZGI.js +544 -0
- package/dist/memos-7TXG4ZTU.js +744 -0
- package/dist/{metabase-MMSEPCOF.js → metabase-NSVACWQM.js} +90 -89
- package/dist/mistral_ai-YZ52RGD4.js +1196 -0
- package/dist/{mother_duck-H7PCQNZ2.js → mother_duck-XLLL6FVL.js} +94 -93
- package/dist/ngrok-4O4W3WZW.js +356 -0
- package/dist/{notes-PFMKRO33.js → notes-YTB3TJOO.js} +11 -9
- package/dist/notion-4W4O7J7V.js +940 -0
- package/dist/open_exchange_rates-23QJXVO5.js +215 -0
- package/dist/openai-ZS7GLSLH.js +800 -0
- package/dist/opengraph_io-PMVH7OYI.js +362 -0
- package/dist/openrouter-ONRGFNB6.js +441 -0
- package/dist/outline-UCUYZZ7J.js +599 -0
- package/dist/paddle-35HTKTUL.js +454 -0
- package/dist/perplexity-NVOBYN24.js +220 -0
- package/dist/pinecone-55CJY73C.js +571 -0
- package/dist/{pipedrive-Y2O7QGFF.js → pipedrive-WMCAKS72.js} +99 -98
- package/dist/polar-SM4ZM53B.js +395 -0
- package/dist/posthog-NWCXVXNJ.js +3464 -0
- package/dist/postmark-QJV5PHUQ.js +427 -0
- package/dist/{prerender-MENYM2TY.js → prerender-2W7UT4SC.js} +31 -30
- package/dist/{pubmed-GOXUVVH5.js → pubmed-VVV7XYLU.js} +239 -238
- package/dist/{railway-V2SID4WV.js → railway-KGI57S3O.js} +118 -117
- package/dist/readwise-AGHTQB42.js +470 -0
- package/dist/render-O4HBROCK.js +461 -0
- package/dist/{replicate-756MXPYX.js → replicate-KWBOMX7D.js} +81 -80
- package/dist/{resend-ZKH3BTBI.js → resend-DRH6Y6I4.js} +20 -16
- package/dist/rootly-XGCUDW6X.js +336 -0
- package/dist/{scrapfly-NSRHFDIQ.js → scrapfly-OIQ3OY6L.js} +62 -61
- package/dist/{scrapingbee-OQHLAVEY.js → scrapingbee-OCZO4FHX.js} +56 -56
- package/dist/{screenshot_fyi-DVWG3AXC.js → screenshot_fyi-CUNGFZOC.js} +16 -16
- package/dist/semantic_scholar-3UJRLKES.js +611 -0
- package/dist/{sentry-546MNDJG.js → sentry-5BWVZFJV.js} +208 -207
- package/dist/{shodan-C3OON3Z3.js → shodan-HI37CTEW.js} +62 -61
- package/dist/shopify-LJ2EV2HH.js +610 -0
- package/dist/stripe-3LHMV55K.js +585 -0
- package/dist/{supabase-U2SL4D63.js → supabase-H2KPX3Q2.js} +245 -244
- package/dist/tavily-FBEWGH3Z.js +326 -0
- package/dist/telegram-MYYO3JND.js +1767 -0
- package/dist/{telnyx-CXQ4EZUX.js → telnyx-H4ALEGAX.js} +57 -56
- package/dist/todoist-OBWICA5Q.js +664 -0
- package/dist/trello-GUFUJRWO.js +1080 -0
- package/dist/turso-NIAK4UMS.js +416 -0
- package/dist/{twilio-4PDBJKWX.js → twilio-K6SLK2CX.js} +70 -69
- package/dist/umami-42RS2EPS.js +389 -0
- package/dist/unsplash-V7TOTETT.js +351 -0
- package/dist/{upstash_redis-G4LQBYHA.js → upstash_redis-AWQMB6Y3.js} +51 -50
- package/dist/uptimerobot-AZC2DHOT.js +483 -0
- package/dist/v2ex-4TVRNMLS.js +667 -0
- package/dist/vercel-DPHTJ3XR.js +1076 -0
- package/dist/{wolfram_alpha_api-3G4PUJWB.js → wolfram_alpha_api-XAG7IXBW.js} +36 -35
- package/dist/wordpress-KMPKVGUX.js +812 -0
- package/dist/workos-PKB2YR7S.js +664 -0
- package/dist/zhihu-Y4H4XYPB.js +254 -0
- package/package.json +18 -9
- package/dist/airtable-LLZDFN7M.js +0 -789
- package/dist/anthropic-G23NN3X5.js +0 -202
- package/dist/apify-Y3SS734K.js +0 -247
- package/dist/brave_search-ZC7OAPSZ.js +0 -301
- package/dist/chunk-R6P4XAE5.js +0 -248
- package/dist/chunk-U7B6DS2O.js +0 -977
- package/dist/chunk-UZM2RXZH.js +0 -23436
- package/dist/circleci-3BAX5FCG.js +0 -388
- package/dist/clerk-6LEM6TNU.js +0 -1019
- package/dist/cloudflare_dns-KINYTJUD.js +0 -588
- package/dist/cohere-XCJ5AJ6B.js +0 -185
- package/dist/deepseek-PC5YGNC5.js +0 -209
- package/dist/docker_hub-C3MA5FU6.js +0 -932
- package/dist/dropbox-XBV7Z2IR.js +0 -1304
- package/dist/dub-LDOFG3HC.js +0 -679
- package/dist/e2b-JMCPSVBW.js +0 -277
- package/dist/exa-RAK7O7RD.js +0 -331
- package/dist/figma-E6IX5DTH.js +0 -773
- package/dist/firehydrant-ZBLPQREE.js +0 -562
- package/dist/fly-ZH3HFCZJ.js +0 -468
- package/dist/geocodio-YGNI7DA4.js +0 -212
- package/dist/ghost-EVSGKH2Q.js +0 -337
- package/dist/github-MA2BGRCJ.js +0 -5420
- package/dist/gmail-E5E6AADE.js +0 -1886
- package/dist/googlecalendar-BTLFPXTD.js +0 -2523
- package/dist/graphhopper-WSMB3TCD.js +0 -324
- package/dist/ipgeolocation_io-AA7HAS22.js +0 -315
- package/dist/ipqualityscore-BHJXVTJT.js +0 -277
- package/dist/langsmith-5W6SCT6F.js +0 -592
- package/dist/lemlist-HJWH6UMK.js +0 -288
- package/dist/logsnag-4KFOHL37.js +0 -150
- package/dist/mem0-CAW43CIC.js +0 -543
- package/dist/memos-TWEGPKFM.js +0 -740
- package/dist/mistral_ai-64BGZQHP.js +0 -1195
- package/dist/ngrok-GQCUGZKJ.js +0 -356
- package/dist/notion-DQWZWP4N.js +0 -936
- package/dist/open_exchange_rates-QMMD735E.js +0 -214
- package/dist/openai-W6PX32NZ.js +0 -799
- package/dist/opengraph_io-HNDBXYNW.js +0 -361
- package/dist/openrouter-JJYMEAUL.js +0 -437
- package/dist/outline-MCBNQZYY.js +0 -595
- package/dist/paddle-D2SKLUDN.js +0 -453
- package/dist/perplexity-XIFMKUAE.js +0 -219
- package/dist/pinecone-HUFTALV2.js +0 -570
- package/dist/polar-TYTOMOSR.js +0 -394
- package/dist/posthog-43JAR3VW.js +0 -3463
- package/dist/postmark-KL2QJYSG.js +0 -426
- package/dist/readwise-CI4GIMMJ.js +0 -469
- package/dist/render-SUBJ6YRZ.js +0 -460
- package/dist/rootly-CD2LJHPI.js +0 -336
- package/dist/semantic_scholar-T4A252KW.js +0 -610
- package/dist/shopify-Y2HN2MCQ.js +0 -609
- package/dist/stripe-VE3CD3AY.js +0 -584
- package/dist/tavily-KCZHK6HE.js +0 -326
- package/dist/telegram-3URFBCMY.js +0 -1766
- package/dist/todoist-HNPWNYTD.js +0 -663
- package/dist/trello-3W2MIXRP.js +0 -1079
- package/dist/turso-2EQF7C2Z.js +0 -415
- package/dist/umami-5REN7TGP.js +0 -388
- package/dist/unsplash-EIXL424F.js +0 -350
- package/dist/uptimerobot-KNJ3EYLY.js +0 -482
- package/dist/v2ex-RHJ234PZ.js +0 -666
- package/dist/vercel-AS6NCIC7.js +0 -1075
- package/dist/wordpress-KNDAAUV7.js +0 -811
- package/dist/workos-R6UITSJ7.js +0 -663
- package/dist/zhihu-AGK4HILK.js +0 -253
|
@@ -0,0 +1,790 @@
|
|
|
1
|
+
import {
|
|
2
|
+
createAuthedClient
|
|
3
|
+
} from "./chunk-RTW5VRTK.js";
|
|
4
|
+
import "./chunk-BNMLA2RC.js";
|
|
5
|
+
import {
|
|
6
|
+
asJsonObject,
|
|
7
|
+
booleanValue,
|
|
8
|
+
compactDefined,
|
|
9
|
+
integerValue,
|
|
10
|
+
trimmedText
|
|
11
|
+
} from "./chunk-JXHMDBAY.js";
|
|
12
|
+
import {
|
|
13
|
+
createProviderPlugin,
|
|
14
|
+
upstreamError
|
|
15
|
+
} from "./chunk-X7ZUTKHR.js";
|
|
16
|
+
import "./chunk-7ISGFRC6.js";
|
|
17
|
+
import "./chunk-UY6ANCOY.js";
|
|
18
|
+
import {
|
|
19
|
+
TBError
|
|
20
|
+
} from "./chunk-HA4BGL6C.js";
|
|
21
|
+
import "./chunk-U67V476Y.js";
|
|
22
|
+
|
|
23
|
+
// ../plugins/src/airtable/api.ts
|
|
24
|
+
var SERVICE = "airtable";
|
|
25
|
+
var API_BASE = "https://api.airtable.com";
|
|
26
|
+
var BASES_PATH = "/v0/meta/bases";
|
|
27
|
+
var GET_URL_LENGTH_SOFT_LIMIT = 15e3;
|
|
28
|
+
function requireText(value, field) {
|
|
29
|
+
const result = trimmedText(value);
|
|
30
|
+
if (result === void 0) throw new TBError("invalid_argument", `${field} is required`);
|
|
31
|
+
return result;
|
|
32
|
+
}
|
|
33
|
+
function requireObject(value, label) {
|
|
34
|
+
const fields = asJsonObject(value);
|
|
35
|
+
if (fields === void 0) throw upstreamError(502, `${label} must be a plain object`);
|
|
36
|
+
return fields;
|
|
37
|
+
}
|
|
38
|
+
function objectArray(value, label) {
|
|
39
|
+
if (!Array.isArray(value)) return [];
|
|
40
|
+
return value.map((item, index) => requireObject(item, `${label}[${index}]`));
|
|
41
|
+
}
|
|
42
|
+
function inputObject(value, label) {
|
|
43
|
+
const fields = asJsonObject(value);
|
|
44
|
+
if (fields === void 0) throw new TBError("invalid_argument", `${label} must be an object`);
|
|
45
|
+
return fields;
|
|
46
|
+
}
|
|
47
|
+
function buildUrl(path, query) {
|
|
48
|
+
const url = new URL(path, API_BASE);
|
|
49
|
+
for (const [key, value] of query ?? []) url.searchParams.append(key, value);
|
|
50
|
+
return url.toString();
|
|
51
|
+
}
|
|
52
|
+
function errorMessage(payload, status) {
|
|
53
|
+
if (typeof payload === "string" && payload !== "") return payload;
|
|
54
|
+
const error = asJsonObject(asJsonObject(payload)?.error);
|
|
55
|
+
const message = trimmedText(error?.message);
|
|
56
|
+
const type = trimmedText(error?.type);
|
|
57
|
+
if (message !== void 0 && type !== void 0) return `${message} (${type})`;
|
|
58
|
+
return message ?? type ?? `airtable request failed with ${status}`;
|
|
59
|
+
}
|
|
60
|
+
function responsePayload(result) {
|
|
61
|
+
const contentType = result.headers.get("content-type") ?? "";
|
|
62
|
+
if (contentType.includes("application/json")) {
|
|
63
|
+
if (result.bodyKind === "json") return result.data;
|
|
64
|
+
if (result.bodyKind === "empty" && (result.status === 204 || result.status === 205)) return null;
|
|
65
|
+
throw upstreamError(502, "airtable response parsing failed: invalid JSON");
|
|
66
|
+
}
|
|
67
|
+
if (result.bodyKind === "empty") return null;
|
|
68
|
+
if (result.bodyKind === "text") {
|
|
69
|
+
try {
|
|
70
|
+
return JSON.parse(String(result.data));
|
|
71
|
+
} catch {
|
|
72
|
+
return result.data;
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
return result.data;
|
|
76
|
+
}
|
|
77
|
+
function mapAirtableError(context) {
|
|
78
|
+
try {
|
|
79
|
+
return upstreamError(context.status, errorMessage(responsePayload(context), context.status));
|
|
80
|
+
} catch {
|
|
81
|
+
return upstreamError(502, "airtable response parsing failed: invalid JSON");
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
var http = createAuthedClient({
|
|
85
|
+
baseUrl: API_BASE,
|
|
86
|
+
service: SERVICE,
|
|
87
|
+
auth: { kind: "bearer" },
|
|
88
|
+
headers: { accept: "application/json" },
|
|
89
|
+
mapError: mapAirtableError,
|
|
90
|
+
mapTransportError: ({ message }) => upstreamError(
|
|
91
|
+
502,
|
|
92
|
+
`airtable request failed: ${message ?? "unknown request error"}`
|
|
93
|
+
)
|
|
94
|
+
});
|
|
95
|
+
async function request(ctx, input) {
|
|
96
|
+
const result = await http.request(ctx, {
|
|
97
|
+
path: input.path,
|
|
98
|
+
method: input.method ?? "GET",
|
|
99
|
+
query: input.query,
|
|
100
|
+
...input.body === void 0 ? {} : { json: input.body },
|
|
101
|
+
invalidJson: "text",
|
|
102
|
+
responseType: "auto"
|
|
103
|
+
});
|
|
104
|
+
return responsePayload(result);
|
|
105
|
+
}
|
|
106
|
+
function recordCollectionPath(input) {
|
|
107
|
+
const baseId = encodeURIComponent(requireText(input.baseId, "baseId"));
|
|
108
|
+
const table = encodeURIComponent(requireText(input.tableIdOrName, "tableIdOrName"));
|
|
109
|
+
return `/v0/${baseId}/${table}`;
|
|
110
|
+
}
|
|
111
|
+
function includeQuery(include) {
|
|
112
|
+
return (include ?? []).map((item) => ["include[]", requireText(item, "include item")]);
|
|
113
|
+
}
|
|
114
|
+
function commonReadQuery(input) {
|
|
115
|
+
const query = [];
|
|
116
|
+
for (const field of input.fields ?? []) query.push(["fields[]", requireText(field, "fields item")]);
|
|
117
|
+
const cellFormat = trimmedText(input.cellFormat);
|
|
118
|
+
const timeZone = trimmedText(input.timeZone);
|
|
119
|
+
const userLocale = trimmedText(input.userLocale);
|
|
120
|
+
const returnFieldsByFieldId = booleanValue(input.returnFieldsByFieldId);
|
|
121
|
+
const includeDateDependencyMetadata = booleanValue(input.includeDateDependencyMetadata);
|
|
122
|
+
if (cellFormat !== void 0) query.push(["cellFormat", cellFormat]);
|
|
123
|
+
if (timeZone !== void 0) query.push(["timeZone", timeZone]);
|
|
124
|
+
if (userLocale !== void 0) query.push(["userLocale", userLocale]);
|
|
125
|
+
if (returnFieldsByFieldId !== void 0) query.push(["returnFieldsByFieldId", String(returnFieldsByFieldId)]);
|
|
126
|
+
if (includeDateDependencyMetadata !== void 0) {
|
|
127
|
+
query.push(["includeDateDependencyMetadata", String(includeDateDependencyMetadata)]);
|
|
128
|
+
}
|
|
129
|
+
return query;
|
|
130
|
+
}
|
|
131
|
+
function listRecordsQuery(input) {
|
|
132
|
+
const query = commonReadQuery(input);
|
|
133
|
+
const offset = trimmedText(input.offset);
|
|
134
|
+
const pageSize = integerValue(input.pageSize);
|
|
135
|
+
const maxRecords = integerValue(input.maxRecords);
|
|
136
|
+
const view = trimmedText(input.view);
|
|
137
|
+
const filterByFormula = trimmedText(input.filterByFormula);
|
|
138
|
+
if (offset !== void 0) query.push(["offset", offset]);
|
|
139
|
+
if (pageSize !== void 0) query.push(["pageSize", String(pageSize)]);
|
|
140
|
+
if (maxRecords !== void 0) query.push(["maxRecords", String(maxRecords)]);
|
|
141
|
+
if (view !== void 0) query.push(["view", view]);
|
|
142
|
+
if (filterByFormula !== void 0) query.push(["filterByFormula", filterByFormula]);
|
|
143
|
+
for (const [index, item] of (input.sort ?? []).entries()) {
|
|
144
|
+
const rule = inputObject(item, `sort[${index}]`);
|
|
145
|
+
query.push([`sort[${index}][field]`, requireText(rule.field, `sort[${index}].field`)]);
|
|
146
|
+
const direction = trimmedText(rule.direction);
|
|
147
|
+
if (direction !== void 0) query.push([`sort[${index}][direction]`, direction]);
|
|
148
|
+
}
|
|
149
|
+
for (const item of input.recordMetadata ?? []) {
|
|
150
|
+
query.push(["recordMetadata[]", requireText(item, "recordMetadata item")]);
|
|
151
|
+
}
|
|
152
|
+
return query;
|
|
153
|
+
}
|
|
154
|
+
function listRecordsPostBody(input) {
|
|
155
|
+
return compactDefined({
|
|
156
|
+
view: trimmedText(input.view),
|
|
157
|
+
fields: input.fields === void 0 ? void 0 : input.fields.map((field) => requireText(field, "fields item")),
|
|
158
|
+
sort: input.sort === void 0 ? void 0 : input.sort.map((item, index) => {
|
|
159
|
+
const rule = inputObject(item, `sort[${index}]`);
|
|
160
|
+
return compactDefined({
|
|
161
|
+
field: requireText(rule.field, `sort[${index}].field`),
|
|
162
|
+
direction: trimmedText(rule.direction)
|
|
163
|
+
});
|
|
164
|
+
}),
|
|
165
|
+
filterByFormula: trimmedText(input.filterByFormula),
|
|
166
|
+
maxRecords: integerValue(input.maxRecords),
|
|
167
|
+
pageSize: integerValue(input.pageSize),
|
|
168
|
+
offset: trimmedText(input.offset),
|
|
169
|
+
cellFormat: trimmedText(input.cellFormat),
|
|
170
|
+
timeZone: trimmedText(input.timeZone),
|
|
171
|
+
userLocale: trimmedText(input.userLocale),
|
|
172
|
+
returnFieldsByFieldId: booleanValue(input.returnFieldsByFieldId),
|
|
173
|
+
includeDateDependencyMetadata: booleanValue(input.includeDateDependencyMetadata),
|
|
174
|
+
recordMetadata: input.recordMetadata === void 0 ? void 0 : input.recordMetadata.map((item) => requireText(item, "recordMetadata item"))
|
|
175
|
+
});
|
|
176
|
+
}
|
|
177
|
+
function fieldConfig(value, label) {
|
|
178
|
+
const field = { ...inputObject(value, label) };
|
|
179
|
+
delete field.baseId;
|
|
180
|
+
delete field.tableId;
|
|
181
|
+
delete field.columnId;
|
|
182
|
+
return compactDefined({
|
|
183
|
+
...field,
|
|
184
|
+
name: requireText(field.name, `${label}.name`),
|
|
185
|
+
type: requireText(field.type, `${label}.type`),
|
|
186
|
+
description: trimmedText(field.description),
|
|
187
|
+
options: asJsonObject(field.options)
|
|
188
|
+
});
|
|
189
|
+
}
|
|
190
|
+
function fieldConfigs(value, label) {
|
|
191
|
+
const fields = Array.isArray(value) ? value : [];
|
|
192
|
+
if (fields.length === 0) throw new TBError("invalid_argument", `${label} is required`);
|
|
193
|
+
return fields.map((field, index) => fieldConfig(field, `${label}[${index}]`));
|
|
194
|
+
}
|
|
195
|
+
function tableConfigs(value) {
|
|
196
|
+
const tables = Array.isArray(value) ? value : [];
|
|
197
|
+
if (tables.length === 0) throw new TBError("invalid_argument", "tables is required");
|
|
198
|
+
return tables.map((table, index) => {
|
|
199
|
+
const config = inputObject(table, `tables[${index}]`);
|
|
200
|
+
return compactDefined({
|
|
201
|
+
...config,
|
|
202
|
+
name: requireText(config.name, `tables[${index}].name`),
|
|
203
|
+
description: trimmedText(config.description),
|
|
204
|
+
fields: fieldConfigs(config.fields, `tables[${index}].fields`)
|
|
205
|
+
});
|
|
206
|
+
});
|
|
207
|
+
}
|
|
208
|
+
function recordFields(value, label) {
|
|
209
|
+
const fields = asJsonObject(value);
|
|
210
|
+
if (fields === void 0) throw new TBError("invalid_argument", `${label} must be an object`);
|
|
211
|
+
return fields;
|
|
212
|
+
}
|
|
213
|
+
async function listBases(input, ctx) {
|
|
214
|
+
const offset = trimmedText(input.offset);
|
|
215
|
+
const payload = requireObject(
|
|
216
|
+
await request(ctx, { path: BASES_PATH, query: offset === void 0 ? [] : [["offset", offset]] }),
|
|
217
|
+
"airtable list bases response"
|
|
218
|
+
);
|
|
219
|
+
return {
|
|
220
|
+
bases: objectArray(payload.bases, "bases"),
|
|
221
|
+
// 翻页靠它:没有下一页时给 null,压成 undefined 会让调用方分不清"到底了"。
|
|
222
|
+
offset: trimmedText(payload.offset) ?? null
|
|
223
|
+
};
|
|
224
|
+
}
|
|
225
|
+
async function getBaseCollaborators(input, ctx) {
|
|
226
|
+
const payload = await request(ctx, {
|
|
227
|
+
path: `${BASES_PATH}/${encodeURIComponent(requireText(input.baseId, "baseId"))}`,
|
|
228
|
+
query: includeQuery(input.include)
|
|
229
|
+
});
|
|
230
|
+
return { base: requireObject(payload, "airtable get base collaborators response") };
|
|
231
|
+
}
|
|
232
|
+
async function getBaseSchema(input, ctx) {
|
|
233
|
+
const payload = requireObject(
|
|
234
|
+
await request(ctx, {
|
|
235
|
+
path: `${BASES_PATH}/${encodeURIComponent(requireText(input.baseId, "baseId"))}/tables`,
|
|
236
|
+
query: includeQuery(input.include)
|
|
237
|
+
}),
|
|
238
|
+
"airtable get base schema response"
|
|
239
|
+
);
|
|
240
|
+
return { tables: Array.isArray(payload.tables) ? payload.tables : [] };
|
|
241
|
+
}
|
|
242
|
+
async function createBase(input, ctx) {
|
|
243
|
+
const payload = await request(ctx, {
|
|
244
|
+
method: "POST",
|
|
245
|
+
path: BASES_PATH,
|
|
246
|
+
body: {
|
|
247
|
+
name: requireText(input.name, "name"),
|
|
248
|
+
workspaceId: requireText(input.workspaceId, "workspaceId"),
|
|
249
|
+
tables: tableConfigs(input.tables)
|
|
250
|
+
}
|
|
251
|
+
});
|
|
252
|
+
return requireObject(payload, "airtable create base response");
|
|
253
|
+
}
|
|
254
|
+
async function deleteBase(input, ctx) {
|
|
255
|
+
const payload = await request(ctx, {
|
|
256
|
+
method: "DELETE",
|
|
257
|
+
path: `${BASES_PATH}/${encodeURIComponent(requireText(input.baseId, "baseId"))}`
|
|
258
|
+
});
|
|
259
|
+
return requireObject(payload, "airtable delete base response");
|
|
260
|
+
}
|
|
261
|
+
async function createTable(input, ctx) {
|
|
262
|
+
const payload = await request(ctx, {
|
|
263
|
+
method: "POST",
|
|
264
|
+
path: `${BASES_PATH}/${encodeURIComponent(requireText(input.baseId, "baseId"))}/tables`,
|
|
265
|
+
body: compactDefined({
|
|
266
|
+
name: requireText(input.name, "name"),
|
|
267
|
+
description: trimmedText(input.description),
|
|
268
|
+
fields: fieldConfigs(input.fields, "fields")
|
|
269
|
+
})
|
|
270
|
+
});
|
|
271
|
+
return requireObject(payload, "airtable create table response");
|
|
272
|
+
}
|
|
273
|
+
async function updateTable(input, ctx) {
|
|
274
|
+
const baseId = encodeURIComponent(requireText(input.baseId, "baseId"));
|
|
275
|
+
const table = encodeURIComponent(requireText(input.tableIdOrName, "tableIdOrName"));
|
|
276
|
+
const payload = await request(ctx, {
|
|
277
|
+
method: "PATCH",
|
|
278
|
+
path: `${BASES_PATH}/${baseId}/tables/${table}`,
|
|
279
|
+
body: compactDefined({
|
|
280
|
+
name: trimmedText(input.name),
|
|
281
|
+
description: trimmedText(input.description),
|
|
282
|
+
dateDependencySettings: asJsonObject(input.dateDependencySettings)
|
|
283
|
+
})
|
|
284
|
+
});
|
|
285
|
+
return requireObject(payload, "airtable update table response");
|
|
286
|
+
}
|
|
287
|
+
async function createField(input, ctx) {
|
|
288
|
+
const baseId = encodeURIComponent(requireText(input.baseId, "baseId"));
|
|
289
|
+
const tableId = encodeURIComponent(requireText(input.tableId, "tableId"));
|
|
290
|
+
const payload = await request(ctx, {
|
|
291
|
+
method: "POST",
|
|
292
|
+
path: `${BASES_PATH}/${baseId}/tables/${tableId}/fields`,
|
|
293
|
+
body: fieldConfig(input, "field")
|
|
294
|
+
});
|
|
295
|
+
return requireObject(payload, "airtable create field response");
|
|
296
|
+
}
|
|
297
|
+
async function updateField(input, ctx) {
|
|
298
|
+
const baseId = encodeURIComponent(requireText(input.baseId, "baseId"));
|
|
299
|
+
const tableId = encodeURIComponent(requireText(input.tableId, "tableId"));
|
|
300
|
+
const columnId = encodeURIComponent(requireText(input.columnId, "columnId"));
|
|
301
|
+
const payload = await request(ctx, {
|
|
302
|
+
method: "PATCH",
|
|
303
|
+
path: `${BASES_PATH}/${baseId}/tables/${tableId}/fields/${columnId}`,
|
|
304
|
+
body: compactDefined({
|
|
305
|
+
name: trimmedText(input.name),
|
|
306
|
+
description: trimmedText(input.description),
|
|
307
|
+
options: asJsonObject(input.options)
|
|
308
|
+
})
|
|
309
|
+
});
|
|
310
|
+
return requireObject(payload, "airtable update field response");
|
|
311
|
+
}
|
|
312
|
+
async function listRecords(input, ctx) {
|
|
313
|
+
const path = recordCollectionPath(input);
|
|
314
|
+
const query = listRecordsQuery(input);
|
|
315
|
+
const usePost = buildUrl(path, query).length >= GET_URL_LENGTH_SOFT_LIMIT;
|
|
316
|
+
const payload = requireObject(
|
|
317
|
+
await request(ctx, usePost ? { method: "POST", path: `${path}/listRecords`, body: listRecordsPostBody(input) } : { path, query }),
|
|
318
|
+
"airtable list records response"
|
|
319
|
+
);
|
|
320
|
+
return {
|
|
321
|
+
records: objectArray(payload.records, "records"),
|
|
322
|
+
offset: trimmedText(payload.offset) ?? null
|
|
323
|
+
};
|
|
324
|
+
}
|
|
325
|
+
async function getRecord(input, ctx) {
|
|
326
|
+
const payload = await request(ctx, {
|
|
327
|
+
path: `${recordCollectionPath(input)}/${encodeURIComponent(requireText(input.recordId, "recordId"))}`,
|
|
328
|
+
query: commonReadQuery(input)
|
|
329
|
+
});
|
|
330
|
+
return { record: requireObject(payload, "airtable get record response") };
|
|
331
|
+
}
|
|
332
|
+
async function createRecords(input, ctx) {
|
|
333
|
+
const records = Array.isArray(input.records) ? input.records : [];
|
|
334
|
+
if (records.length === 0) throw new TBError("invalid_argument", "records is required");
|
|
335
|
+
const payload = requireObject(
|
|
336
|
+
await request(ctx, {
|
|
337
|
+
method: "POST",
|
|
338
|
+
path: recordCollectionPath(input),
|
|
339
|
+
body: compactDefined({
|
|
340
|
+
// 创建时只发 fields:带上 id 会被 Airtable 当成非法字段。
|
|
341
|
+
records: records.map((item, index) => ({
|
|
342
|
+
fields: recordFields(inputObject(item, `records[${index}]`).fields, `records[${index}].fields`)
|
|
343
|
+
})),
|
|
344
|
+
typecast: booleanValue(input.typecast),
|
|
345
|
+
returnFieldsByFieldId: booleanValue(input.returnFieldsByFieldId)
|
|
346
|
+
})
|
|
347
|
+
}),
|
|
348
|
+
"airtable create records response"
|
|
349
|
+
);
|
|
350
|
+
return { records: objectArray(payload.records, "records") };
|
|
351
|
+
}
|
|
352
|
+
async function updateRecords(input, ctx) {
|
|
353
|
+
const records = Array.isArray(input.records) ? input.records : [];
|
|
354
|
+
if (records.length === 0) throw new TBError("invalid_argument", "records is required");
|
|
355
|
+
const payload = requireObject(
|
|
356
|
+
await request(ctx, {
|
|
357
|
+
method: "PATCH",
|
|
358
|
+
path: recordCollectionPath(input),
|
|
359
|
+
body: compactDefined({
|
|
360
|
+
records: records.map((item, index) => {
|
|
361
|
+
const entry = inputObject(item, `records[${index}]`);
|
|
362
|
+
return {
|
|
363
|
+
id: requireText(entry.id, `records[${index}].id`),
|
|
364
|
+
fields: recordFields(entry.fields, `records[${index}].fields`)
|
|
365
|
+
};
|
|
366
|
+
}),
|
|
367
|
+
typecast: booleanValue(input.typecast),
|
|
368
|
+
returnFieldsByFieldId: booleanValue(input.returnFieldsByFieldId)
|
|
369
|
+
})
|
|
370
|
+
}),
|
|
371
|
+
"airtable update records response"
|
|
372
|
+
);
|
|
373
|
+
return { records: objectArray(payload.records, "records") };
|
|
374
|
+
}
|
|
375
|
+
async function deleteRecords(input, ctx) {
|
|
376
|
+
const recordIds = Array.isArray(input.recordIds) ? input.recordIds : [];
|
|
377
|
+
if (recordIds.length === 0) throw new TBError("invalid_argument", "recordIds is required");
|
|
378
|
+
const payload = requireObject(
|
|
379
|
+
await request(ctx, {
|
|
380
|
+
method: "DELETE",
|
|
381
|
+
path: recordCollectionPath(input),
|
|
382
|
+
// 删除的 id 走 query 的重复 `records[]`,不是请求体。
|
|
383
|
+
query: recordIds.map((id) => ["records[]", requireText(id, "recordIds item")])
|
|
384
|
+
}),
|
|
385
|
+
"airtable delete records response"
|
|
386
|
+
);
|
|
387
|
+
return { records: objectArray(payload.records, "records") };
|
|
388
|
+
}
|
|
389
|
+
|
|
390
|
+
// ../plugins/src/airtable/schema.ts
|
|
391
|
+
import { z } from "zod/v4";
|
|
392
|
+
var listBasesInput = z.strictObject({
|
|
393
|
+
offset: z.string().min(1).describe("Opaque pagination cursor returned by a previous Airtable response.").optional()
|
|
394
|
+
}).describe("The input payload for this action.");
|
|
395
|
+
var listBasesOutput = z.strictObject({
|
|
396
|
+
bases: z.array(z.strictObject({
|
|
397
|
+
id: z.string().describe("Base ID."),
|
|
398
|
+
name: z.string().describe("Base name."),
|
|
399
|
+
permissionLevel: z.string().describe("Permission level reported by Airtable for this base.")
|
|
400
|
+
}).describe("Airtable base summary.")).describe("Bases returned by Airtable."),
|
|
401
|
+
offset: z.string().describe("Pagination cursor for the next page of bases, or null when unavailable.").nullable()
|
|
402
|
+
}).describe("Airtable action output.");
|
|
403
|
+
var getBaseCollaboratorsInput = z.strictObject({
|
|
404
|
+
baseId: z.string().min(1).describe("Base ID in the format appXXXXXXXXXXXXXX."),
|
|
405
|
+
include: z.array(z.enum(["collaborators", "inviteLinks", "interfaces", "packages"])).min(1).describe("Optional Airtable base collaboration details to include.").optional()
|
|
406
|
+
}).describe("The input payload for this action.");
|
|
407
|
+
var getBaseCollaboratorsOutput = z.strictObject({
|
|
408
|
+
base: z.looseObject({
|
|
409
|
+
id: z.string().describe("Base ID."),
|
|
410
|
+
createdTime: z.string().describe("Base creation timestamp returned by Airtable."),
|
|
411
|
+
permissionLevel: z.string().describe("Permission level reported by Airtable for the authenticated user."),
|
|
412
|
+
workspaceId: z.string().min(1).describe("Workspace ID in the format wspXXXXXXXXXXXXXX."),
|
|
413
|
+
name: z.string().describe("Base name."),
|
|
414
|
+
interfaces: z.looseObject({}).describe("Interface metadata returned by Airtable.").optional(),
|
|
415
|
+
collaborators: z.looseObject({}).describe("Deprecated collaborator metadata returned by Airtable.").optional(),
|
|
416
|
+
groupCollaborators: z.looseObject({}).describe("Group collaborator metadata returned by Airtable.").optional(),
|
|
417
|
+
individualCollaborators: z.looseObject({}).describe("Individual collaborator metadata returned by Airtable.").optional(),
|
|
418
|
+
inviteLinks: z.looseObject({}).describe("Invite link metadata returned by Airtable.").optional(),
|
|
419
|
+
packages: z.looseObject({}).describe("Package metadata returned by Airtable.").optional()
|
|
420
|
+
}).describe("Airtable base details response.")
|
|
421
|
+
}).describe("Airtable action output.");
|
|
422
|
+
var getBaseSchemaInput = z.strictObject({
|
|
423
|
+
baseId: z.string().min(1).describe("Base ID in the format appXXXXXXXXXXXXXX."),
|
|
424
|
+
include: z.array(z.literal("visibleFieldIds")).min(1).max(1).describe("Optional Airtable schema details to include in table views.").optional()
|
|
425
|
+
}).describe("The input payload for this action.");
|
|
426
|
+
var getBaseSchemaOutput = z.strictObject({
|
|
427
|
+
tables: z.array(z.looseObject({
|
|
428
|
+
id: z.string().describe("Table ID."),
|
|
429
|
+
name: z.string().describe("Table name."),
|
|
430
|
+
description: z.string().describe("Table description when Airtable returns one.").optional(),
|
|
431
|
+
primaryFieldId: z.string().describe("Primary field ID configured for the table.").optional(),
|
|
432
|
+
dateDependencySettings: z.looseObject({}).describe("Date dependency settings returned by Airtable for the table.").optional(),
|
|
433
|
+
fields: z.array(z.looseObject({
|
|
434
|
+
id: z.string().describe("Field ID."),
|
|
435
|
+
name: z.string().describe("Field name."),
|
|
436
|
+
type: z.string().describe("Field type reported by Airtable."),
|
|
437
|
+
description: z.string().describe("Field description when Airtable returns one.").optional(),
|
|
438
|
+
options: z.looseObject({}).describe("Field options reported by Airtable.").optional()
|
|
439
|
+
}).describe("Airtable field definition.")).describe("Fields defined on the Airtable table."),
|
|
440
|
+
views: z.array(z.looseObject({
|
|
441
|
+
id: z.string().describe("View ID."),
|
|
442
|
+
name: z.string().describe("View name."),
|
|
443
|
+
type: z.string().describe("View type reported by Airtable.").optional(),
|
|
444
|
+
visibleFieldIds: z.array(z.string()).describe("Field IDs visible in the Airtable view.").optional()
|
|
445
|
+
}).describe("Airtable view definition.")).describe("Views defined on the Airtable table.").optional()
|
|
446
|
+
}).describe("Airtable table definition.")).describe("Tables returned by Airtable for the base.")
|
|
447
|
+
}).describe("Airtable action output.");
|
|
448
|
+
var createBaseInput = z.strictObject({
|
|
449
|
+
name: z.string().min(1).describe("Name for the Airtable base."),
|
|
450
|
+
workspaceId: z.string().min(1).describe("Workspace ID in the format wspXXXXXXXXXXXXXX."),
|
|
451
|
+
tables: z.array(z.looseObject({
|
|
452
|
+
name: z.string().min(1).describe("Name for the Airtable table."),
|
|
453
|
+
description: z.string().max(2e4).describe("Optional Airtable description, up to 20,000 characters.").optional(),
|
|
454
|
+
fields: z.array(z.looseObject({
|
|
455
|
+
name: z.string().min(1).describe("Name for the Airtable field."),
|
|
456
|
+
type: z.string().min(1).describe("Airtable field type, such as singleLineText."),
|
|
457
|
+
description: z.string().max(2e4).describe("Optional Airtable description, up to 20,000 characters.").optional(),
|
|
458
|
+
options: z.looseObject({}).describe("Type-specific Airtable field options.").optional()
|
|
459
|
+
}).describe("Airtable field configuration accepted by metadata write endpoints.")).min(1).describe("Field configurations to create in the Airtable table.")
|
|
460
|
+
}).describe("Airtable table configuration accepted when creating a base or table.")).min(1).describe("Tables to create along with the new Airtable base.")
|
|
461
|
+
}).describe("The input payload for this action.");
|
|
462
|
+
var createBaseOutput = z.strictObject({
|
|
463
|
+
id: z.string().describe("Base ID."),
|
|
464
|
+
tables: z.array(z.looseObject({
|
|
465
|
+
id: z.string().describe("Table ID."),
|
|
466
|
+
name: z.string().describe("Table name."),
|
|
467
|
+
description: z.string().describe("Table description when Airtable returns one.").optional(),
|
|
468
|
+
primaryFieldId: z.string().describe("Primary field ID configured for the table.").optional(),
|
|
469
|
+
dateDependencySettings: z.looseObject({}).describe("Date dependency settings returned by Airtable for the table.").optional(),
|
|
470
|
+
fields: z.array(z.looseObject({
|
|
471
|
+
id: z.string().describe("Field ID."),
|
|
472
|
+
name: z.string().describe("Field name."),
|
|
473
|
+
type: z.string().describe("Field type reported by Airtable."),
|
|
474
|
+
description: z.string().describe("Field description when Airtable returns one.").optional(),
|
|
475
|
+
options: z.looseObject({}).describe("Field options reported by Airtable.").optional()
|
|
476
|
+
}).describe("Airtable field definition.")).describe("Fields defined on the Airtable table."),
|
|
477
|
+
views: z.array(z.looseObject({
|
|
478
|
+
id: z.string().describe("View ID."),
|
|
479
|
+
name: z.string().describe("View name."),
|
|
480
|
+
type: z.string().describe("View type reported by Airtable.").optional(),
|
|
481
|
+
visibleFieldIds: z.array(z.string()).describe("Field IDs visible in the Airtable view.").optional()
|
|
482
|
+
}).describe("Airtable view definition.")).describe("Views defined on the Airtable table.").optional()
|
|
483
|
+
}).describe("Airtable table definition.")).describe("Tables created with the Airtable base.")
|
|
484
|
+
}).describe("Airtable create base response.");
|
|
485
|
+
var deleteBaseInput = z.strictObject({
|
|
486
|
+
baseId: z.string().min(1).describe("Base ID in the format appXXXXXXXXXXXXXX.")
|
|
487
|
+
}).describe("The input payload for this action.");
|
|
488
|
+
var deleteBaseOutput = z.strictObject({
|
|
489
|
+
id: z.string().describe("Base ID."),
|
|
490
|
+
deleted: z.literal(true).describe("Whether Airtable reports the base as deleted.")
|
|
491
|
+
}).describe("Airtable deleted-base acknowledgement.");
|
|
492
|
+
var createTableInput = z.strictObject({
|
|
493
|
+
baseId: z.string().min(1).describe("Base ID in the format appXXXXXXXXXXXXXX."),
|
|
494
|
+
name: z.string().min(1).describe("Name for the Airtable table."),
|
|
495
|
+
description: z.string().max(2e4).describe("Optional Airtable description, up to 20,000 characters.").optional(),
|
|
496
|
+
fields: z.array(z.looseObject({
|
|
497
|
+
name: z.string().min(1).describe("Name for the Airtable field."),
|
|
498
|
+
type: z.string().min(1).describe("Airtable field type, such as singleLineText."),
|
|
499
|
+
description: z.string().max(2e4).describe("Optional Airtable description, up to 20,000 characters.").optional(),
|
|
500
|
+
options: z.looseObject({}).describe("Type-specific Airtable field options.").optional()
|
|
501
|
+
}).describe("Airtable field configuration accepted by metadata write endpoints.")).min(1).describe("Field configurations to create in the Airtable table.")
|
|
502
|
+
}).describe("The input payload for this action.");
|
|
503
|
+
var createTableOutput = z.looseObject({
|
|
504
|
+
id: z.string().describe("Table ID."),
|
|
505
|
+
name: z.string().describe("Table name."),
|
|
506
|
+
description: z.string().describe("Table description when Airtable returns one.").optional(),
|
|
507
|
+
primaryFieldId: z.string().describe("Primary field ID configured for the table.").optional(),
|
|
508
|
+
dateDependencySettings: z.looseObject({}).describe("Date dependency settings returned by Airtable for the table.").optional(),
|
|
509
|
+
fields: z.array(z.looseObject({
|
|
510
|
+
id: z.string().describe("Field ID."),
|
|
511
|
+
name: z.string().describe("Field name."),
|
|
512
|
+
type: z.string().describe("Field type reported by Airtable."),
|
|
513
|
+
description: z.string().describe("Field description when Airtable returns one.").optional(),
|
|
514
|
+
options: z.looseObject({}).describe("Field options reported by Airtable.").optional()
|
|
515
|
+
}).describe("Airtable field definition.")).describe("Fields defined on the Airtable table."),
|
|
516
|
+
views: z.array(z.looseObject({
|
|
517
|
+
id: z.string().describe("View ID."),
|
|
518
|
+
name: z.string().describe("View name."),
|
|
519
|
+
type: z.string().describe("View type reported by Airtable.").optional(),
|
|
520
|
+
visibleFieldIds: z.array(z.string()).describe("Field IDs visible in the Airtable view.").optional()
|
|
521
|
+
}).describe("Airtable view definition.")).describe("Views defined on the Airtable table.").optional()
|
|
522
|
+
}).describe("Airtable table definition.");
|
|
523
|
+
var updateTableInput = z.strictObject({
|
|
524
|
+
baseId: z.string().min(1).describe("Base ID in the format appXXXXXXXXXXXXXX."),
|
|
525
|
+
tableIdOrName: z.string().min(1).describe("Table ID or table name accepted by the Airtable path parameter."),
|
|
526
|
+
name: z.string().min(1).describe("Name for the Airtable table.").optional(),
|
|
527
|
+
description: z.string().max(2e4).describe("Optional Airtable description, up to 20,000 characters.").optional(),
|
|
528
|
+
dateDependencySettings: z.looseObject({}).describe("Airtable date dependency settings for a table.").optional()
|
|
529
|
+
}).describe("The input payload for this action.");
|
|
530
|
+
var updateTableOutput = z.looseObject({
|
|
531
|
+
id: z.string().describe("Table ID."),
|
|
532
|
+
name: z.string().describe("Table name."),
|
|
533
|
+
description: z.string().describe("Table description when Airtable returns one.").optional(),
|
|
534
|
+
primaryFieldId: z.string().describe("Primary field ID configured for the table.").optional(),
|
|
535
|
+
dateDependencySettings: z.looseObject({}).describe("Date dependency settings returned by Airtable for the table.").optional(),
|
|
536
|
+
fields: z.array(z.looseObject({
|
|
537
|
+
id: z.string().describe("Field ID."),
|
|
538
|
+
name: z.string().describe("Field name."),
|
|
539
|
+
type: z.string().describe("Field type reported by Airtable."),
|
|
540
|
+
description: z.string().describe("Field description when Airtable returns one.").optional(),
|
|
541
|
+
options: z.looseObject({}).describe("Field options reported by Airtable.").optional()
|
|
542
|
+
}).describe("Airtable field definition.")).describe("Fields defined on the Airtable table."),
|
|
543
|
+
views: z.array(z.looseObject({
|
|
544
|
+
id: z.string().describe("View ID."),
|
|
545
|
+
name: z.string().describe("View name."),
|
|
546
|
+
type: z.string().describe("View type reported by Airtable.").optional(),
|
|
547
|
+
visibleFieldIds: z.array(z.string()).describe("Field IDs visible in the Airtable view.").optional()
|
|
548
|
+
}).describe("Airtable view definition.")).describe("Views defined on the Airtable table.").optional()
|
|
549
|
+
}).describe("Airtable table definition.");
|
|
550
|
+
var createFieldInput = z.strictObject({
|
|
551
|
+
baseId: z.string().min(1).describe("Base ID in the format appXXXXXXXXXXXXXX."),
|
|
552
|
+
tableId: z.string().min(1).describe("Table ID in the format tblXXXXXXXXXXXXXX."),
|
|
553
|
+
name: z.string().min(1).describe("Name for the Airtable field."),
|
|
554
|
+
type: z.string().min(1).describe("Airtable field type, such as singleLineText."),
|
|
555
|
+
description: z.string().max(2e4).describe("Optional Airtable description, up to 20,000 characters.").optional(),
|
|
556
|
+
options: z.looseObject({}).describe("Type-specific Airtable field options.").optional()
|
|
557
|
+
}).describe("The input payload for this action.");
|
|
558
|
+
var createFieldOutput = z.looseObject({
|
|
559
|
+
id: z.string().describe("Field ID."),
|
|
560
|
+
name: z.string().describe("Field name."),
|
|
561
|
+
type: z.string().describe("Field type reported by Airtable."),
|
|
562
|
+
description: z.string().describe("Field description when Airtable returns one.").optional(),
|
|
563
|
+
options: z.looseObject({}).describe("Field options reported by Airtable.").optional()
|
|
564
|
+
}).describe("Airtable field definition.");
|
|
565
|
+
var updateFieldInput = z.strictObject({
|
|
566
|
+
baseId: z.string().min(1).describe("Base ID in the format appXXXXXXXXXXXXXX."),
|
|
567
|
+
tableId: z.string().min(1).describe("Table ID in the format tblXXXXXXXXXXXXXX."),
|
|
568
|
+
columnId: z.string().min(1).describe("Field ID in the format fldXXXXXXXXXXXXXX."),
|
|
569
|
+
name: z.string().min(1).describe("Name for the Airtable field.").optional(),
|
|
570
|
+
description: z.string().max(2e4).describe("Optional Airtable description, up to 20,000 characters.").optional(),
|
|
571
|
+
options: z.looseObject({}).describe("Type-specific Airtable field options.").optional()
|
|
572
|
+
}).describe("The input payload for this action.");
|
|
573
|
+
var updateFieldOutput = z.looseObject({
|
|
574
|
+
id: z.string().describe("Field ID."),
|
|
575
|
+
name: z.string().describe("Field name."),
|
|
576
|
+
type: z.string().describe("Field type reported by Airtable."),
|
|
577
|
+
description: z.string().describe("Field description when Airtable returns one.").optional(),
|
|
578
|
+
options: z.looseObject({}).describe("Field options reported by Airtable.").optional()
|
|
579
|
+
}).describe("Airtable field definition.");
|
|
580
|
+
var listRecordsInput = z.strictObject({
|
|
581
|
+
baseId: z.string().min(1).describe("Base ID in the format appXXXXXXXXXXXXXX."),
|
|
582
|
+
tableIdOrName: z.string().min(1).describe("Table ID or table name accepted by the Airtable path parameter."),
|
|
583
|
+
cellFormat: z.enum(["json", "string"]).describe("Cell format accepted by Airtable for read operations.").optional(),
|
|
584
|
+
timeZone: z.string().min(1).describe("Timezone string sent to Airtable when cellFormat is string.").optional(),
|
|
585
|
+
userLocale: z.string().min(1).describe("User locale sent to Airtable when cellFormat is string.").optional(),
|
|
586
|
+
returnFieldsByFieldId: z.boolean().describe("Whether Airtable should return field IDs instead of field names in record objects.").optional(),
|
|
587
|
+
includeDateDependencyMetadata: z.boolean().describe("Whether Airtable should return date dependency metadata for linked record fields.").optional(),
|
|
588
|
+
view: z.string().min(1).describe("View name or view ID used by Airtable to filter and sort results.").optional(),
|
|
589
|
+
fields: z.array(z.string().min(1)).min(1).describe("Field names or field IDs to include in the Airtable response.").optional(),
|
|
590
|
+
sort: z.array(z.strictObject({
|
|
591
|
+
field: z.string().min(1).describe("Field name or field ID used by Airtable for sorting."),
|
|
592
|
+
direction: z.enum(["asc", "desc"]).describe("Sort direction accepted by Airtable.").optional()
|
|
593
|
+
}).describe("Sort rule accepted by the Airtable list records endpoint.")).min(1).describe("Sort rules applied by Airtable in order.").optional(),
|
|
594
|
+
filterByFormula: z.string().min(1).describe("Formula string evaluated by Airtable to filter matching records.").optional(),
|
|
595
|
+
maxRecords: z.int().min(1).describe("Maximum total number of records to return before Airtable stops pagination.").optional(),
|
|
596
|
+
pageSize: z.int().min(1).max(100).describe("Number of records to return per page.").optional(),
|
|
597
|
+
offset: z.string().min(1).describe("Opaque pagination cursor returned by a previous Airtable response.").optional(),
|
|
598
|
+
recordMetadata: z.array(z.literal("commentCount")).min(1).describe("Record metadata fields to include in Airtable list records responses.").optional()
|
|
599
|
+
}).describe("The input payload for this action.");
|
|
600
|
+
var listRecordsOutput = z.strictObject({
|
|
601
|
+
records: z.array(z.looseObject({
|
|
602
|
+
id: z.string().describe("Record ID."),
|
|
603
|
+
createdTime: z.string().describe("Record creation timestamp returned by Airtable.").optional(),
|
|
604
|
+
fields: z.looseObject({}).describe("Record fields keyed by field name or field ID."),
|
|
605
|
+
commentCount: z.int().describe("Comment count returned by Airtable when enabled on the endpoint.").optional()
|
|
606
|
+
}).describe("Airtable record.")).describe("Records returned by Airtable."),
|
|
607
|
+
offset: z.string().describe("Pagination cursor for the next page of records, or null when unavailable.").nullable()
|
|
608
|
+
}).describe("Airtable action output.");
|
|
609
|
+
var getRecordInput = z.strictObject({
|
|
610
|
+
baseId: z.string().min(1).describe("Base ID in the format appXXXXXXXXXXXXXX."),
|
|
611
|
+
tableIdOrName: z.string().min(1).describe("Table ID or table name accepted by the Airtable path parameter."),
|
|
612
|
+
cellFormat: z.enum(["json", "string"]).describe("Cell format accepted by Airtable for read operations.").optional(),
|
|
613
|
+
timeZone: z.string().min(1).describe("Timezone string sent to Airtable when cellFormat is string.").optional(),
|
|
614
|
+
userLocale: z.string().min(1).describe("User locale sent to Airtable when cellFormat is string.").optional(),
|
|
615
|
+
returnFieldsByFieldId: z.boolean().describe("Whether Airtable should return field IDs instead of field names in record objects.").optional(),
|
|
616
|
+
includeDateDependencyMetadata: z.boolean().describe("Whether Airtable should return date dependency metadata for linked record fields.").optional(),
|
|
617
|
+
recordId: z.string().min(1).describe("Record ID in the format recXXXXXXXXXXXXXX.")
|
|
618
|
+
}).describe("The input payload for this action.");
|
|
619
|
+
var getRecordOutput = z.strictObject({
|
|
620
|
+
record: z.looseObject({
|
|
621
|
+
id: z.string().describe("Record ID."),
|
|
622
|
+
createdTime: z.string().describe("Record creation timestamp returned by Airtable.").optional(),
|
|
623
|
+
fields: z.looseObject({}).describe("Record fields keyed by field name or field ID."),
|
|
624
|
+
commentCount: z.int().describe("Comment count returned by Airtable when enabled on the endpoint.").optional()
|
|
625
|
+
}).describe("Airtable record.")
|
|
626
|
+
}).describe("Airtable action output.");
|
|
627
|
+
var createRecordsInput = z.strictObject({
|
|
628
|
+
baseId: z.string().min(1).describe("Base ID in the format appXXXXXXXXXXXXXX."),
|
|
629
|
+
tableIdOrName: z.string().min(1).describe("Table ID or table name accepted by the Airtable path parameter."),
|
|
630
|
+
records: z.array(z.strictObject({
|
|
631
|
+
fields: z.looseObject({}).describe("Record fields keyed by field name or field ID.")
|
|
632
|
+
}).describe("Record payload used when creating Airtable records.")).min(1).max(10).describe("Records to create in the Airtable table."),
|
|
633
|
+
typecast: z.boolean().describe("Whether Airtable should coerce incoming values to compatible field types.").optional(),
|
|
634
|
+
returnFieldsByFieldId: z.boolean().describe("Whether Airtable should return field IDs instead of field names in record objects.").optional()
|
|
635
|
+
}).describe("The input payload for this action.");
|
|
636
|
+
var createRecordsOutput = z.strictObject({
|
|
637
|
+
records: z.array(z.looseObject({
|
|
638
|
+
id: z.string().describe("Record ID."),
|
|
639
|
+
createdTime: z.string().describe("Record creation timestamp returned by Airtable.").optional(),
|
|
640
|
+
fields: z.looseObject({}).describe("Record fields keyed by field name or field ID."),
|
|
641
|
+
commentCount: z.int().describe("Comment count returned by Airtable when enabled on the endpoint.").optional()
|
|
642
|
+
}).describe("Airtable record.")).describe("Records created by Airtable.")
|
|
643
|
+
}).describe("Airtable action output.");
|
|
644
|
+
var updateRecordsInput = z.strictObject({
|
|
645
|
+
baseId: z.string().min(1).describe("Base ID in the format appXXXXXXXXXXXXXX."),
|
|
646
|
+
tableIdOrName: z.string().min(1).describe("Table ID or table name accepted by the Airtable path parameter."),
|
|
647
|
+
records: z.array(z.strictObject({
|
|
648
|
+
id: z.string().min(1).describe("Record ID in the format recXXXXXXXXXXXXXX."),
|
|
649
|
+
fields: z.looseObject({}).describe("Record fields keyed by field name or field ID.")
|
|
650
|
+
}).describe("Record payload used when updating Airtable records.")).min(1).max(10).describe("Records to update in the Airtable table."),
|
|
651
|
+
typecast: z.boolean().describe("Whether Airtable should coerce incoming values to compatible field types.").optional(),
|
|
652
|
+
returnFieldsByFieldId: z.boolean().describe("Whether Airtable should return field IDs instead of field names in record objects.").optional()
|
|
653
|
+
}).describe("The input payload for this action.");
|
|
654
|
+
var updateRecordsOutput = z.strictObject({
|
|
655
|
+
records: z.array(z.looseObject({
|
|
656
|
+
id: z.string().describe("Record ID."),
|
|
657
|
+
createdTime: z.string().describe("Record creation timestamp returned by Airtable.").optional(),
|
|
658
|
+
fields: z.looseObject({}).describe("Record fields keyed by field name or field ID."),
|
|
659
|
+
commentCount: z.int().describe("Comment count returned by Airtable when enabled on the endpoint.").optional()
|
|
660
|
+
}).describe("Airtable record.")).describe("Records returned by Airtable after update.")
|
|
661
|
+
}).describe("Airtable action output.");
|
|
662
|
+
var deleteRecordsInput = z.strictObject({
|
|
663
|
+
baseId: z.string().min(1).describe("Base ID in the format appXXXXXXXXXXXXXX."),
|
|
664
|
+
tableIdOrName: z.string().min(1).describe("Table ID or table name accepted by the Airtable path parameter."),
|
|
665
|
+
recordIds: z.array(z.string().min(1).describe("Record ID in the format recXXXXXXXXXXXXXX.")).min(1).max(10).describe("Record IDs to delete from the Airtable table.")
|
|
666
|
+
}).describe("The input payload for this action.");
|
|
667
|
+
var deleteRecordsOutput = z.strictObject({
|
|
668
|
+
records: z.array(z.strictObject({
|
|
669
|
+
id: z.string().describe("Record ID."),
|
|
670
|
+
deleted: z.boolean().describe("Whether Airtable reports the record as deleted.")
|
|
671
|
+
}).describe("Airtable deleted-record acknowledgement.")).describe("Deleted-record acknowledgements returned by Airtable.")
|
|
672
|
+
}).describe("Airtable action output.");
|
|
673
|
+
var airtableActions = {
|
|
674
|
+
list_bases: {
|
|
675
|
+
description: "List Airtable bases accessible to the authenticated personal access token.",
|
|
676
|
+
effect: "read",
|
|
677
|
+
inputSchema: listBasesInput,
|
|
678
|
+
outputSchema: z.toJSONSchema(listBasesOutput, { io: "output", unrepresentable: "any" })
|
|
679
|
+
},
|
|
680
|
+
get_base_collaborators: {
|
|
681
|
+
description: "Read Airtable base metadata, including workspaceId and optional collaborator details.",
|
|
682
|
+
effect: "read",
|
|
683
|
+
inputSchema: getBaseCollaboratorsInput,
|
|
684
|
+
outputSchema: z.toJSONSchema(getBaseCollaboratorsOutput, { io: "output", unrepresentable: "any" })
|
|
685
|
+
},
|
|
686
|
+
get_base_schema: {
|
|
687
|
+
description: "Read Airtable table, field, and view schema for a specific base.",
|
|
688
|
+
effect: "read",
|
|
689
|
+
inputSchema: getBaseSchemaInput,
|
|
690
|
+
outputSchema: z.toJSONSchema(getBaseSchemaOutput, { io: "output", unrepresentable: "any" })
|
|
691
|
+
},
|
|
692
|
+
create_base: {
|
|
693
|
+
description: "Create an Airtable base in a workspace with the provided initial table and field schema.",
|
|
694
|
+
effect: "write",
|
|
695
|
+
inputSchema: createBaseInput,
|
|
696
|
+
outputSchema: z.toJSONSchema(createBaseOutput, { io: "output", unrepresentable: "any" })
|
|
697
|
+
},
|
|
698
|
+
delete_base: {
|
|
699
|
+
description: "Delete an Airtable base. Airtable restricts this endpoint to enterprise admins.",
|
|
700
|
+
effect: "destructive",
|
|
701
|
+
inputSchema: deleteBaseInput,
|
|
702
|
+
outputSchema: z.toJSONSchema(deleteBaseOutput, { io: "output", unrepresentable: "any" })
|
|
703
|
+
},
|
|
704
|
+
create_table: {
|
|
705
|
+
description: "Create a table in an Airtable base with the provided field schema.",
|
|
706
|
+
effect: "write",
|
|
707
|
+
inputSchema: createTableInput,
|
|
708
|
+
outputSchema: z.toJSONSchema(createTableOutput, { io: "output", unrepresentable: "any" })
|
|
709
|
+
},
|
|
710
|
+
update_table: {
|
|
711
|
+
description: "Update an Airtable table name, description, or date dependency settings.",
|
|
712
|
+
effect: "write",
|
|
713
|
+
inputSchema: updateTableInput,
|
|
714
|
+
outputSchema: z.toJSONSchema(updateTableOutput, { io: "output", unrepresentable: "any" })
|
|
715
|
+
},
|
|
716
|
+
create_field: {
|
|
717
|
+
description: "Create a field in an Airtable table.",
|
|
718
|
+
effect: "write",
|
|
719
|
+
inputSchema: createFieldInput,
|
|
720
|
+
outputSchema: z.toJSONSchema(createFieldOutput, { io: "output", unrepresentable: "any" })
|
|
721
|
+
},
|
|
722
|
+
update_field: {
|
|
723
|
+
description: "Update an Airtable field name, description, or type-specific options.",
|
|
724
|
+
effect: "write",
|
|
725
|
+
inputSchema: updateFieldInput,
|
|
726
|
+
outputSchema: z.toJSONSchema(updateFieldOutput, { io: "output", unrepresentable: "any" })
|
|
727
|
+
},
|
|
728
|
+
list_records: {
|
|
729
|
+
description: "List Airtable records from a table with optional fields, sorting, view filters, formula filters, and pagination.",
|
|
730
|
+
effect: "read",
|
|
731
|
+
inputSchema: listRecordsInput,
|
|
732
|
+
outputSchema: z.toJSONSchema(listRecordsOutput, { io: "output", unrepresentable: "any" })
|
|
733
|
+
},
|
|
734
|
+
get_record: {
|
|
735
|
+
description: "Read a single Airtable record by record ID.",
|
|
736
|
+
effect: "read",
|
|
737
|
+
inputSchema: getRecordInput,
|
|
738
|
+
outputSchema: z.toJSONSchema(getRecordOutput, { io: "output", unrepresentable: "any" })
|
|
739
|
+
},
|
|
740
|
+
create_records: {
|
|
741
|
+
description: "Create one or more Airtable records in a table.",
|
|
742
|
+
effect: "write",
|
|
743
|
+
inputSchema: createRecordsInput,
|
|
744
|
+
outputSchema: z.toJSONSchema(createRecordsOutput, { io: "output", unrepresentable: "any" })
|
|
745
|
+
},
|
|
746
|
+
update_records: {
|
|
747
|
+
description: "Update one or more existing Airtable records by record ID.",
|
|
748
|
+
effect: "write",
|
|
749
|
+
inputSchema: updateRecordsInput,
|
|
750
|
+
outputSchema: z.toJSONSchema(updateRecordsOutput, { io: "output", unrepresentable: "any" })
|
|
751
|
+
},
|
|
752
|
+
delete_records: {
|
|
753
|
+
description: "Delete one or more Airtable records by record ID.",
|
|
754
|
+
effect: "destructive",
|
|
755
|
+
inputSchema: deleteRecordsInput,
|
|
756
|
+
outputSchema: z.toJSONSchema(deleteRecordsOutput, { io: "output", unrepresentable: "any" })
|
|
757
|
+
}
|
|
758
|
+
};
|
|
759
|
+
|
|
760
|
+
// ../plugins/src/airtable/index.ts
|
|
761
|
+
function createAirtablePlugin() {
|
|
762
|
+
return createProviderPlugin({
|
|
763
|
+
description: "Airtable",
|
|
764
|
+
actions: airtableActions,
|
|
765
|
+
// 上游 credentialValidators 也打 /v0/meta/bases —— 只读、无必填入参,
|
|
766
|
+
// 正好当挂载时的凭证探针。
|
|
767
|
+
credentialProbe: "list_bases",
|
|
768
|
+
handlers: {
|
|
769
|
+
list_bases: listBases,
|
|
770
|
+
get_base_collaborators: getBaseCollaborators,
|
|
771
|
+
get_base_schema: getBaseSchema,
|
|
772
|
+
create_base: createBase,
|
|
773
|
+
delete_base: deleteBase,
|
|
774
|
+
create_table: createTable,
|
|
775
|
+
update_table: updateTable,
|
|
776
|
+
create_field: createField,
|
|
777
|
+
update_field: updateField,
|
|
778
|
+
list_records: listRecords,
|
|
779
|
+
get_record: getRecord,
|
|
780
|
+
create_records: createRecords,
|
|
781
|
+
update_records: updateRecords,
|
|
782
|
+
delete_records: deleteRecords
|
|
783
|
+
}
|
|
784
|
+
});
|
|
785
|
+
}
|
|
786
|
+
var airtable_default = createAirtablePlugin();
|
|
787
|
+
export {
|
|
788
|
+
createAirtablePlugin,
|
|
789
|
+
airtable_default as default
|
|
790
|
+
};
|