@tool-bridge/server 0.15.0 → 0.17.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{airtable-QYTOPRFV.js → airtable-NOSOMOVB.js} +106 -114
- package/dist/{alt_text_generator_ai-2CFYNSZV.js → alt_text_generator_ai-BHIJ4LW5.js} +25 -16
- package/dist/{amap-HGOBOHSZ.js → amap-QRLP4TWZ.js} +114 -123
- package/dist/{anthropic-3OXOQNSR.js → anthropic-IEOI36EV.js} +34 -56
- package/dist/{apify-PUV2QGKL.js → apify-3CCYTQVK.js} +31 -49
- package/dist/{brave_search-DG75AVKA.js → brave_search-PZNYDQG7.js} +52 -77
- package/dist/chunk-JXHMDBAY.js +45 -0
- package/dist/chunk-LMLX3DJF.js +50 -0
- package/dist/{chunk-DXXYNIXV.js → chunk-RVWZN3CI.js} +3337 -1440
- package/dist/{chunk-NLPTB3IL.js → chunk-TLNUIPFZ.js} +1475 -277
- package/dist/chunk-U5UHT7CX.js +977 -0
- package/dist/chunk-U67V476Y.js +35 -0
- package/dist/chunk-WW2IMPQK.js +283 -0
- package/dist/{chunk-NQ67PIIS.js → chunk-YASUMV2K.js} +4 -6
- package/dist/{circleci-EFNLX5AW.js → circleci-VSJ4O5FC.js} +36 -55
- package/dist/{clerk-UWDLMZVM.js → clerk-CC2JZBZI.js} +60 -80
- package/dist/{cloudflare_dns-WQXVDSPU.js → cloudflare_dns-PJEBSEYQ.js} +90 -113
- package/dist/{cohere-VPDIKUDP.js → cohere-KBACYSPF.js} +33 -49
- package/dist/{confluence-NBOOQNTR.js → confluence-2PX3O7G5.js} +79 -115
- package/dist/{convertapi-6Z6OP25T.js → convertapi-BVOTD2PJ.js} +13 -16
- package/dist/{currencyapi-CAMUWCTV.js → currencyapi-6ZQ2VNQ7.js} +30 -53
- package/dist/{deepseek-GRALXYXR.js → deepseek-MB3WVVTB.js} +30 -38
- package/dist/{docker_hub-5AASF3TJ.js → docker_hub-7CLQL2IJ.js} +141 -157
- package/dist/{dropbox-HS3VGRD3.js → dropbox-VFYDVUNK.js} +134 -141
- package/dist/{dub-KHERUTW6.js → dub-QN3EETJY.js} +61 -93
- package/dist/{e2b-4MGHPFXY.js → e2b-NKC3Y776.js} +39 -69
- package/dist/{exa-O77PKTBT.js → exa-KKZ6F25K.js} +49 -77
- package/dist/{fal_ai-TX2TZFMP.js → fal_ai-25LYJD2O.js} +37 -44
- package/dist/{feishu-I7VPWO3C.js → feishu-NRT55B3Q.js} +4 -6
- package/dist/{feishu_custom_bot-D4XZDLES.js → feishu_custom_bot-3W3XXUG4.js} +4 -5
- package/dist/{figma-SW3HZCZ5.js → figma-4FLP35TC.js} +56 -81
- package/dist/{firehydrant-ND5DEW3L.js → firehydrant-BLXPLZ3X.js} +40 -53
- package/dist/{fixer-ZTSV7ZK3.js → fixer-4OR62TGE.js} +31 -43
- package/dist/{fly-RZ7SZKFT.js → fly-MYCKOZZK.js} +50 -66
- package/dist/{front-Q5MZVUGX.js → front-3DFYVMF3.js} +43 -66
- package/dist/{geocodio-QPHHODHG.js → geocodio-CXMD6VKA.js} +37 -63
- package/dist/{ghost-3Q6O7EWZ.js → ghost-4UUE737W.js} +51 -57
- package/dist/{github-LDMGJHXV.js → github-WFS2ON2N.js} +48 -41
- package/dist/{gmail-6QBCI3TT.js → gmail-KW7FXA7A.js} +26 -36
- package/dist/{googlecalendar-LLSYY4ZJ.js → googlecalendar-AMH5JQMC.js} +57 -78
- package/dist/{googledocs-KRGVBGWY.js → googledocs-R5VA6CKD.js} +14 -22
- package/dist/{grafana-OHPZMRHT.js → grafana-IT6DWIVB.js} +95 -122
- package/dist/{graphhopper-2PBY7OX4.js → graphhopper-TYFDJZWC.js} +32 -46
- package/dist/index.d.ts +199 -106
- package/dist/index.js +4 -3
- package/dist/{ip2proxy-GPBQZKKG.js → ip2proxy-GJ4HXVXO.js} +35 -42
- package/dist/{ipgeolocation_io-YNTOLOFH.js → ipgeolocation_io-OAGR6PRF.js} +40 -60
- package/dist/{ipqualityscore-CZLQUAQ7.js → ipqualityscore-BCKAMDGL.js} +30 -42
- package/dist/{jina_ai-JIFEYH5C.js → jina_ai-N3NXRVIZ.js} +32 -58
- package/dist/{jira-2DKTIWHK.js → jira-CHLBKWLO.js} +116 -126
- package/dist/{langsmith-UCX7NHKP.js → langsmith-OIKOTPY3.js} +101 -121
- package/dist/{lemlist-IS6K2VJG.js → lemlist-VAKYPKS3.js} +57 -68
- package/dist/{linear-AK6547ZS.js → linear-Q6QTPJ5R.js} +109 -118
- package/dist/{logsnag-EB5LICOH.js → logsnag-SQOQBTES.js} +31 -48
- package/dist/main.js +103 -102
- package/dist/{mattermost-YOSWUA3R.js → mattermost-G2KBEICM.js} +45 -62
- package/dist/{mem0-IICTSHLB.js → mem0-D2FPLYDX.js} +72 -98
- package/dist/{memos-DIV6MZPB.js → memos-76PTWV5V.js} +68 -122
- package/dist/{metabase-ZGHNTCAT.js → metabase-TWSIDVBM.js} +47 -60
- package/dist/{mistral_ai-IAG3WZYO.js → mistral_ai-TP7TQUEJ.js} +35 -40
- package/dist/{mother_duck-PYKG4ZHO.js → mother_duck-UXY5THYU.js} +42 -62
- package/dist/{ngrok-BXN3DGTK.js → ngrok-RZW2ISJK.js} +42 -58
- package/dist/{notes-L2UO36HQ.js → notes-B2I6FWK2.js} +3 -5
- package/dist/{notion-PVHVOV4R.js → notion-QOKRUE6M.js} +83 -97
- package/dist/{open_exchange_rates-DVMOPFNQ.js → open_exchange_rates-ODLFWEJ7.js} +35 -39
- package/dist/{openai-VW6F5YTK.js → openai-ZPBPPPGT.js} +51 -55
- package/dist/{opengraph_io-MQUREYWM.js → opengraph_io-EOI5UJKT.js} +61 -79
- package/dist/{openrouter-5MI3ODCU.js → openrouter-BUWLF3BG.js} +41 -55
- package/dist/{outline-B2U7NIVA.js → outline-NXS3QRXO.js} +89 -104
- package/dist/{paddle-LDZTVYQO.js → paddle-T4MSKQ76.js} +34 -49
- package/dist/{perplexity-P7BNWFMH.js → perplexity-WW5N2LW7.js} +33 -50
- package/dist/{pinecone-3Y67EJYP.js → pinecone-RY5AZPQM.js} +65 -91
- package/dist/{pipedrive-4KFLGCJW.js → pipedrive-OHYQNZTU.js} +37 -59
- package/dist/{polar-NIULQPUD.js → polar-XZIAHXS5.js} +43 -53
- package/dist/{posthog-UXGCIHRP.js → posthog-DTPTWORY.js} +58 -77
- package/dist/{postmark-XT77YNQM.js → postmark-F4UCQKC3.js} +52 -71
- package/dist/{prerender-37E6ZN6Z.js → prerender-P3Y2MLIC.js} +32 -50
- package/dist/{pubmed-BO2W4IR6.js → pubmed-RHU3GXFB.js} +28 -60
- package/dist/{railway-5BACZNYC.js → railway-VB6SRLI6.js} +32 -39
- package/dist/{readwise-DXABSDKY.js → readwise-DIMSKJZR.js} +62 -78
- package/dist/{render-4MCO6RLA.js → render-XCCDCEEK.js} +48 -64
- package/dist/{replicate-IVEPY4EP.js → replicate-IUEOQ4JC.js} +41 -58
- package/dist/{resend-XJBJO46B.js → resend-N5MJZH5E.js} +27 -37
- package/dist/{rootly-R6QDVF3D.js → rootly-25T4NBTU.js} +64 -76
- package/dist/{scrapfly-E24XNN32.js → scrapfly-PK4XFXUA.js} +45 -51
- package/dist/{scrapingbee-QT3O334C.js → scrapingbee-ITPBMWQU.js} +25 -33
- package/dist/{screenshot_fyi-MJNFPUFV.js → screenshot_fyi-5U6ZYPKR.js} +29 -47
- package/dist/{semantic_scholar-BVKWS72R.js → semantic_scholar-BJGCI2MU.js} +37 -56
- package/dist/{sentry-52T5XARK.js → sentry-63IC263P.js} +66 -85
- package/dist/{shodan-RTOTTCX2.js → shodan-2WBIFHFN.js} +42 -53
- package/dist/{shopify-3RVWQDZ6.js → shopify-XLLJRAGM.js} +32 -49
- package/dist/{stripe-M3T2K3EW.js → stripe-WLVCY3UN.js} +4 -5
- package/dist/{supabase-UUUXAEYR.js → supabase-BKNZ35ER.js} +69 -88
- package/dist/{tavily-LVOZQQKJ.js → tavily-YFSDEUTL.js} +37 -62
- package/dist/{telegram-WJQPCKQT.js → telegram-FC35W74G.js} +168 -177
- package/dist/{telnyx-THKSKAI2.js → telnyx-MI32XZUG.js} +30 -50
- package/dist/{todoist-YTRGFFRC.js → todoist-4ZFJKZC6.js} +77 -89
- package/dist/{trello-QBK6WKN2.js → trello-UOGFNMK4.js} +108 -122
- package/dist/{turso-EA44ZKLR.js → turso-YTSTW3ZS.js} +52 -64
- package/dist/{twilio-GSW3V55S.js → twilio-XAJDFUQH.js} +48 -55
- package/dist/{umami-DVZ7XUYC.js → umami-ZVIUBPAI.js} +49 -69
- package/dist/{unsplash-ZWUWQ7OS.js → unsplash-IU3PLDNS.js} +35 -52
- package/dist/{upstash_redis-BQIQB5NM.js → upstash_redis-3EYJW7SY.js} +28 -40
- package/dist/{uptimerobot-2OJHTUPV.js → uptimerobot-PJG2ASRU.js} +11 -12
- package/dist/{v2ex-IZF4BB4O.js → v2ex-KFQWWGFC.js} +36 -61
- package/dist/{vercel-PI3BJENX.js → vercel-I2ZDOQRL.js} +124 -150
- package/dist/{webapi-VLM4IKVB.js → webapi-GW5QXWXE.js} +1 -1
- package/dist/{wolfram_alpha_api-EYQ2QCHH.js → wolfram_alpha_api-BNXOJMB6.js} +26 -34
- package/dist/{wordpress-ETDA6XLX.js → wordpress-36D7BSMP.js} +87 -104
- package/dist/{workos-D7INO4Y4.js → workos-6X4JJRRC.js} +37 -56
- package/dist/{zhihu-Q7FNHEDM.js → zhihu-CIXKCHIU.js} +35 -57
- package/package.json +5 -5
- package/dist/chunk-KH663T3A.js +0 -183
- package/dist/chunk-MLKGABMK.js +0 -9
- package/dist/chunk-UI4E4T5Q.js +0 -378
|
@@ -1,47 +1,38 @@
|
|
|
1
|
+
import {
|
|
2
|
+
createProviderHttpClient
|
|
3
|
+
} from "./chunk-WW2IMPQK.js";
|
|
4
|
+
import {
|
|
5
|
+
asJsonObject,
|
|
6
|
+
booleanValue,
|
|
7
|
+
compactDefined,
|
|
8
|
+
integerValue,
|
|
9
|
+
trimmedText
|
|
10
|
+
} from "./chunk-JXHMDBAY.js";
|
|
1
11
|
import {
|
|
2
12
|
createProviderPlugin,
|
|
3
13
|
requireApiKey,
|
|
4
14
|
upstreamError
|
|
5
|
-
} from "./chunk-
|
|
6
|
-
import
|
|
7
|
-
guardedFetch
|
|
8
|
-
} from "./chunk-KH663T3A.js";
|
|
9
|
-
import "./chunk-UI4E4T5Q.js";
|
|
15
|
+
} from "./chunk-YASUMV2K.js";
|
|
16
|
+
import "./chunk-U5UHT7CX.js";
|
|
10
17
|
import {
|
|
11
18
|
TBError,
|
|
12
19
|
external_exports
|
|
13
|
-
} from "./chunk-
|
|
14
|
-
import "./chunk-
|
|
20
|
+
} from "./chunk-RVWZN3CI.js";
|
|
21
|
+
import "./chunk-U67V476Y.js";
|
|
15
22
|
|
|
16
23
|
// ../plugins/src/airtable/api.ts
|
|
17
24
|
var SERVICE = "airtable";
|
|
18
25
|
var API_BASE = "https://api.airtable.com";
|
|
19
26
|
var BASES_PATH = "/v0/meta/bases";
|
|
27
|
+
var http = createProviderHttpClient({ baseUrl: API_BASE, service: SERVICE });
|
|
20
28
|
var GET_URL_LENGTH_SOFT_LIMIT = 15e3;
|
|
21
|
-
function record(value) {
|
|
22
|
-
return typeof value === "object" && value !== null && !Array.isArray(value) ? value : void 0;
|
|
23
|
-
}
|
|
24
|
-
function text(value) {
|
|
25
|
-
if (typeof value !== "string") return void 0;
|
|
26
|
-
const trimmed = value.trim();
|
|
27
|
-
return trimmed === "" ? void 0 : trimmed;
|
|
28
|
-
}
|
|
29
|
-
function boolean(value) {
|
|
30
|
-
return typeof value === "boolean" ? value : void 0;
|
|
31
|
-
}
|
|
32
|
-
function integer(value) {
|
|
33
|
-
return typeof value === "number" && Number.isInteger(value) ? value : void 0;
|
|
34
|
-
}
|
|
35
29
|
function requireText(value, field) {
|
|
36
|
-
const result =
|
|
30
|
+
const result = trimmedText(value);
|
|
37
31
|
if (result === void 0) throw new TBError("invalid_argument", `${field} is required`);
|
|
38
32
|
return result;
|
|
39
33
|
}
|
|
40
|
-
function compact(input) {
|
|
41
|
-
return Object.fromEntries(Object.entries(input).filter(([, value]) => value !== void 0));
|
|
42
|
-
}
|
|
43
34
|
function requireObject(value, label) {
|
|
44
|
-
const fields =
|
|
35
|
+
const fields = asJsonObject(value);
|
|
45
36
|
if (fields === void 0) throw upstreamError(502, `${label} must be a plain object`);
|
|
46
37
|
return fields;
|
|
47
38
|
}
|
|
@@ -50,7 +41,7 @@ function objectArray(value, label) {
|
|
|
50
41
|
return value.map((item, index) => requireObject(item, `${label}[${index}]`));
|
|
51
42
|
}
|
|
52
43
|
function inputObject(value, label) {
|
|
53
|
-
const fields =
|
|
44
|
+
const fields = asJsonObject(value);
|
|
54
45
|
if (fields === void 0) throw new TBError("invalid_argument", `${label} must be an object`);
|
|
55
46
|
return fields;
|
|
56
47
|
}
|
|
@@ -59,54 +50,55 @@ function buildUrl(path, query) {
|
|
|
59
50
|
for (const [key, value] of query ?? []) url.searchParams.append(key, value);
|
|
60
51
|
return url.toString();
|
|
61
52
|
}
|
|
62
|
-
function headers(apiKey, hasBody) {
|
|
63
|
-
return {
|
|
64
|
-
accept: "application/json",
|
|
65
|
-
authorization: `Bearer ${apiKey}`,
|
|
66
|
-
...hasBody ? { "content-type": "application/json" } : {}
|
|
67
|
-
};
|
|
68
|
-
}
|
|
69
53
|
function errorMessage(payload, status) {
|
|
70
54
|
if (typeof payload === "string" && payload !== "") return payload;
|
|
71
|
-
const error =
|
|
72
|
-
const message =
|
|
73
|
-
const type =
|
|
55
|
+
const error = asJsonObject(asJsonObject(payload)?.error);
|
|
56
|
+
const message = trimmedText(error?.message);
|
|
57
|
+
const type = trimmedText(error?.type);
|
|
74
58
|
if (message !== void 0 && type !== void 0) return `${message} (${type})`;
|
|
75
59
|
return message ?? type ?? `airtable request failed with ${status}`;
|
|
76
60
|
}
|
|
77
|
-
|
|
78
|
-
const
|
|
79
|
-
let response;
|
|
80
|
-
try {
|
|
81
|
-
response = await guardedFetch(buildUrl(input.path, input.query), {
|
|
82
|
-
method: input.method ?? "GET",
|
|
83
|
-
headers: headers(apiKey, input.body !== void 0),
|
|
84
|
-
body: input.body === void 0 ? void 0 : JSON.stringify(input.body)
|
|
85
|
-
});
|
|
86
|
-
} catch (error) {
|
|
87
|
-
if (error instanceof TBError) throw error;
|
|
88
|
-
const detail = error instanceof Error && error.message !== "" ? error.message : "unknown request error";
|
|
89
|
-
throw upstreamError(502, `airtable request failed: ${detail}`);
|
|
90
|
-
}
|
|
91
|
-
const contentType = response.headers.get("content-type") ?? "";
|
|
92
|
-
const raw = await response.text().catch(() => "");
|
|
93
|
-
let payload = null;
|
|
61
|
+
function responsePayload(result) {
|
|
62
|
+
const contentType = result.headers.get("content-type") ?? "";
|
|
94
63
|
if (contentType.includes("application/json")) {
|
|
64
|
+
if (result.bodyKind === "json") return result.data;
|
|
65
|
+
if (result.bodyKind === "empty" && (result.status === 204 || result.status === 205)) return null;
|
|
66
|
+
throw upstreamError(502, "airtable response parsing failed: invalid JSON");
|
|
67
|
+
}
|
|
68
|
+
if (result.bodyKind === "empty") return null;
|
|
69
|
+
if (result.bodyKind === "text") {
|
|
95
70
|
try {
|
|
96
|
-
|
|
97
|
-
} catch (error) {
|
|
98
|
-
const detail = error instanceof Error && error.message !== "" ? error.message : "unknown parsing error";
|
|
99
|
-
throw upstreamError(502, `airtable response parsing failed: ${detail}`);
|
|
100
|
-
}
|
|
101
|
-
} else if (raw !== "") {
|
|
102
|
-
try {
|
|
103
|
-
payload = JSON.parse(raw);
|
|
71
|
+
return JSON.parse(String(result.data));
|
|
104
72
|
} catch {
|
|
105
|
-
|
|
73
|
+
return result.data;
|
|
106
74
|
}
|
|
107
75
|
}
|
|
108
|
-
|
|
109
|
-
|
|
76
|
+
return result.data;
|
|
77
|
+
}
|
|
78
|
+
function mapAirtableError(context) {
|
|
79
|
+
try {
|
|
80
|
+
return upstreamError(context.status, errorMessage(responsePayload(context), context.status));
|
|
81
|
+
} catch {
|
|
82
|
+
return upstreamError(502, "airtable response parsing failed: invalid JSON");
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
async function request(ctx, input) {
|
|
86
|
+
const apiKey = requireApiKey(ctx, SERVICE);
|
|
87
|
+
const result = await http.request({
|
|
88
|
+
path: input.path,
|
|
89
|
+
method: input.method ?? "GET",
|
|
90
|
+
query: input.query,
|
|
91
|
+
headers: { accept: "application/json", authorization: `Bearer ${apiKey}` },
|
|
92
|
+
...input.body === void 0 ? {} : { json: input.body },
|
|
93
|
+
invalidJson: "text",
|
|
94
|
+
responseType: "auto",
|
|
95
|
+
mapError: mapAirtableError,
|
|
96
|
+
mapTransportError: ({ message }) => upstreamError(
|
|
97
|
+
502,
|
|
98
|
+
`airtable request failed: ${message ?? "unknown request error"}`
|
|
99
|
+
)
|
|
100
|
+
});
|
|
101
|
+
return responsePayload(result);
|
|
110
102
|
}
|
|
111
103
|
function recordCollectionPath(input) {
|
|
112
104
|
const baseId = encodeURIComponent(requireText(input.baseId, "baseId"));
|
|
@@ -119,11 +111,11 @@ function includeQuery(include) {
|
|
|
119
111
|
function commonReadQuery(input) {
|
|
120
112
|
const query = [];
|
|
121
113
|
for (const field of input.fields ?? []) query.push(["fields[]", requireText(field, "fields item")]);
|
|
122
|
-
const cellFormat =
|
|
123
|
-
const timeZone =
|
|
124
|
-
const userLocale =
|
|
125
|
-
const returnFieldsByFieldId =
|
|
126
|
-
const includeDateDependencyMetadata =
|
|
114
|
+
const cellFormat = trimmedText(input.cellFormat);
|
|
115
|
+
const timeZone = trimmedText(input.timeZone);
|
|
116
|
+
const userLocale = trimmedText(input.userLocale);
|
|
117
|
+
const returnFieldsByFieldId = booleanValue(input.returnFieldsByFieldId);
|
|
118
|
+
const includeDateDependencyMetadata = booleanValue(input.includeDateDependencyMetadata);
|
|
127
119
|
if (cellFormat !== void 0) query.push(["cellFormat", cellFormat]);
|
|
128
120
|
if (timeZone !== void 0) query.push(["timeZone", timeZone]);
|
|
129
121
|
if (userLocale !== void 0) query.push(["userLocale", userLocale]);
|
|
@@ -135,11 +127,11 @@ function commonReadQuery(input) {
|
|
|
135
127
|
}
|
|
136
128
|
function listRecordsQuery(input) {
|
|
137
129
|
const query = commonReadQuery(input);
|
|
138
|
-
const offset =
|
|
139
|
-
const pageSize =
|
|
140
|
-
const maxRecords =
|
|
141
|
-
const view =
|
|
142
|
-
const filterByFormula =
|
|
130
|
+
const offset = trimmedText(input.offset);
|
|
131
|
+
const pageSize = integerValue(input.pageSize);
|
|
132
|
+
const maxRecords = integerValue(input.maxRecords);
|
|
133
|
+
const view = trimmedText(input.view);
|
|
134
|
+
const filterByFormula = trimmedText(input.filterByFormula);
|
|
143
135
|
if (offset !== void 0) query.push(["offset", offset]);
|
|
144
136
|
if (pageSize !== void 0) query.push(["pageSize", String(pageSize)]);
|
|
145
137
|
if (maxRecords !== void 0) query.push(["maxRecords", String(maxRecords)]);
|
|
@@ -148,7 +140,7 @@ function listRecordsQuery(input) {
|
|
|
148
140
|
for (const [index, item] of (input.sort ?? []).entries()) {
|
|
149
141
|
const rule = inputObject(item, `sort[${index}]`);
|
|
150
142
|
query.push([`sort[${index}][field]`, requireText(rule.field, `sort[${index}].field`)]);
|
|
151
|
-
const direction =
|
|
143
|
+
const direction = trimmedText(rule.direction);
|
|
152
144
|
if (direction !== void 0) query.push([`sort[${index}][direction]`, direction]);
|
|
153
145
|
}
|
|
154
146
|
for (const item of input.recordMetadata ?? []) {
|
|
@@ -157,25 +149,25 @@ function listRecordsQuery(input) {
|
|
|
157
149
|
return query;
|
|
158
150
|
}
|
|
159
151
|
function listRecordsPostBody(input) {
|
|
160
|
-
return
|
|
161
|
-
view:
|
|
152
|
+
return compactDefined({
|
|
153
|
+
view: trimmedText(input.view),
|
|
162
154
|
fields: input.fields === void 0 ? void 0 : input.fields.map((field) => requireText(field, "fields item")),
|
|
163
155
|
sort: input.sort === void 0 ? void 0 : input.sort.map((item, index) => {
|
|
164
156
|
const rule = inputObject(item, `sort[${index}]`);
|
|
165
|
-
return
|
|
157
|
+
return compactDefined({
|
|
166
158
|
field: requireText(rule.field, `sort[${index}].field`),
|
|
167
|
-
direction:
|
|
159
|
+
direction: trimmedText(rule.direction)
|
|
168
160
|
});
|
|
169
161
|
}),
|
|
170
|
-
filterByFormula:
|
|
171
|
-
maxRecords:
|
|
172
|
-
pageSize:
|
|
173
|
-
offset:
|
|
174
|
-
cellFormat:
|
|
175
|
-
timeZone:
|
|
176
|
-
userLocale:
|
|
177
|
-
returnFieldsByFieldId:
|
|
178
|
-
includeDateDependencyMetadata:
|
|
162
|
+
filterByFormula: trimmedText(input.filterByFormula),
|
|
163
|
+
maxRecords: integerValue(input.maxRecords),
|
|
164
|
+
pageSize: integerValue(input.pageSize),
|
|
165
|
+
offset: trimmedText(input.offset),
|
|
166
|
+
cellFormat: trimmedText(input.cellFormat),
|
|
167
|
+
timeZone: trimmedText(input.timeZone),
|
|
168
|
+
userLocale: trimmedText(input.userLocale),
|
|
169
|
+
returnFieldsByFieldId: booleanValue(input.returnFieldsByFieldId),
|
|
170
|
+
includeDateDependencyMetadata: booleanValue(input.includeDateDependencyMetadata),
|
|
179
171
|
recordMetadata: input.recordMetadata === void 0 ? void 0 : input.recordMetadata.map((item) => requireText(item, "recordMetadata item"))
|
|
180
172
|
});
|
|
181
173
|
}
|
|
@@ -184,12 +176,12 @@ function fieldConfig(value, label) {
|
|
|
184
176
|
delete field.baseId;
|
|
185
177
|
delete field.tableId;
|
|
186
178
|
delete field.columnId;
|
|
187
|
-
return
|
|
179
|
+
return compactDefined({
|
|
188
180
|
...field,
|
|
189
181
|
name: requireText(field.name, `${label}.name`),
|
|
190
182
|
type: requireText(field.type, `${label}.type`),
|
|
191
|
-
description:
|
|
192
|
-
options:
|
|
183
|
+
description: trimmedText(field.description),
|
|
184
|
+
options: asJsonObject(field.options)
|
|
193
185
|
});
|
|
194
186
|
}
|
|
195
187
|
function fieldConfigs(value, label) {
|
|
@@ -202,21 +194,21 @@ function tableConfigs(value) {
|
|
|
202
194
|
if (tables.length === 0) throw new TBError("invalid_argument", "tables is required");
|
|
203
195
|
return tables.map((table, index) => {
|
|
204
196
|
const config = inputObject(table, `tables[${index}]`);
|
|
205
|
-
return
|
|
197
|
+
return compactDefined({
|
|
206
198
|
...config,
|
|
207
199
|
name: requireText(config.name, `tables[${index}].name`),
|
|
208
|
-
description:
|
|
200
|
+
description: trimmedText(config.description),
|
|
209
201
|
fields: fieldConfigs(config.fields, `tables[${index}].fields`)
|
|
210
202
|
});
|
|
211
203
|
});
|
|
212
204
|
}
|
|
213
205
|
function recordFields(value, label) {
|
|
214
|
-
const fields =
|
|
206
|
+
const fields = asJsonObject(value);
|
|
215
207
|
if (fields === void 0) throw new TBError("invalid_argument", `${label} must be an object`);
|
|
216
208
|
return fields;
|
|
217
209
|
}
|
|
218
210
|
async function listBases(input, ctx) {
|
|
219
|
-
const offset =
|
|
211
|
+
const offset = trimmedText(input.offset);
|
|
220
212
|
const payload = requireObject(
|
|
221
213
|
await request(ctx, { path: BASES_PATH, query: offset === void 0 ? [] : [["offset", offset]] }),
|
|
222
214
|
"airtable list bases response"
|
|
@@ -224,7 +216,7 @@ async function listBases(input, ctx) {
|
|
|
224
216
|
return {
|
|
225
217
|
bases: objectArray(payload.bases, "bases"),
|
|
226
218
|
// 翻页靠它:没有下一页时给 null,压成 undefined 会让调用方分不清"到底了"。
|
|
227
|
-
offset:
|
|
219
|
+
offset: trimmedText(payload.offset) ?? null
|
|
228
220
|
};
|
|
229
221
|
}
|
|
230
222
|
async function getBaseCollaborators(input, ctx) {
|
|
@@ -267,9 +259,9 @@ async function createTable(input, ctx) {
|
|
|
267
259
|
const payload = await request(ctx, {
|
|
268
260
|
method: "POST",
|
|
269
261
|
path: `${BASES_PATH}/${encodeURIComponent(requireText(input.baseId, "baseId"))}/tables`,
|
|
270
|
-
body:
|
|
262
|
+
body: compactDefined({
|
|
271
263
|
name: requireText(input.name, "name"),
|
|
272
|
-
description:
|
|
264
|
+
description: trimmedText(input.description),
|
|
273
265
|
fields: fieldConfigs(input.fields, "fields")
|
|
274
266
|
})
|
|
275
267
|
});
|
|
@@ -281,10 +273,10 @@ async function updateTable(input, ctx) {
|
|
|
281
273
|
const payload = await request(ctx, {
|
|
282
274
|
method: "PATCH",
|
|
283
275
|
path: `${BASES_PATH}/${baseId}/tables/${table}`,
|
|
284
|
-
body:
|
|
285
|
-
name:
|
|
286
|
-
description:
|
|
287
|
-
dateDependencySettings:
|
|
276
|
+
body: compactDefined({
|
|
277
|
+
name: trimmedText(input.name),
|
|
278
|
+
description: trimmedText(input.description),
|
|
279
|
+
dateDependencySettings: asJsonObject(input.dateDependencySettings)
|
|
288
280
|
})
|
|
289
281
|
});
|
|
290
282
|
return requireObject(payload, "airtable update table response");
|
|
@@ -306,10 +298,10 @@ async function updateField(input, ctx) {
|
|
|
306
298
|
const payload = await request(ctx, {
|
|
307
299
|
method: "PATCH",
|
|
308
300
|
path: `${BASES_PATH}/${baseId}/tables/${tableId}/fields/${columnId}`,
|
|
309
|
-
body:
|
|
310
|
-
name:
|
|
311
|
-
description:
|
|
312
|
-
options:
|
|
301
|
+
body: compactDefined({
|
|
302
|
+
name: trimmedText(input.name),
|
|
303
|
+
description: trimmedText(input.description),
|
|
304
|
+
options: asJsonObject(input.options)
|
|
313
305
|
})
|
|
314
306
|
});
|
|
315
307
|
return requireObject(payload, "airtable update field response");
|
|
@@ -324,7 +316,7 @@ async function listRecords(input, ctx) {
|
|
|
324
316
|
);
|
|
325
317
|
return {
|
|
326
318
|
records: objectArray(payload.records, "records"),
|
|
327
|
-
offset:
|
|
319
|
+
offset: trimmedText(payload.offset) ?? null
|
|
328
320
|
};
|
|
329
321
|
}
|
|
330
322
|
async function getRecord(input, ctx) {
|
|
@@ -341,13 +333,13 @@ async function createRecords(input, ctx) {
|
|
|
341
333
|
await request(ctx, {
|
|
342
334
|
method: "POST",
|
|
343
335
|
path: recordCollectionPath(input),
|
|
344
|
-
body:
|
|
336
|
+
body: compactDefined({
|
|
345
337
|
// 创建时只发 fields:带上 id 会被 Airtable 当成非法字段。
|
|
346
338
|
records: records.map((item, index) => ({
|
|
347
339
|
fields: recordFields(inputObject(item, `records[${index}]`).fields, `records[${index}].fields`)
|
|
348
340
|
})),
|
|
349
|
-
typecast:
|
|
350
|
-
returnFieldsByFieldId:
|
|
341
|
+
typecast: booleanValue(input.typecast),
|
|
342
|
+
returnFieldsByFieldId: booleanValue(input.returnFieldsByFieldId)
|
|
351
343
|
})
|
|
352
344
|
}),
|
|
353
345
|
"airtable create records response"
|
|
@@ -361,7 +353,7 @@ async function updateRecords(input, ctx) {
|
|
|
361
353
|
await request(ctx, {
|
|
362
354
|
method: "PATCH",
|
|
363
355
|
path: recordCollectionPath(input),
|
|
364
|
-
body:
|
|
356
|
+
body: compactDefined({
|
|
365
357
|
records: records.map((item, index) => {
|
|
366
358
|
const entry = inputObject(item, `records[${index}]`);
|
|
367
359
|
return {
|
|
@@ -369,8 +361,8 @@ async function updateRecords(input, ctx) {
|
|
|
369
361
|
fields: recordFields(entry.fields, `records[${index}].fields`)
|
|
370
362
|
};
|
|
371
363
|
}),
|
|
372
|
-
typecast:
|
|
373
|
-
returnFieldsByFieldId:
|
|
364
|
+
typecast: booleanValue(input.typecast),
|
|
365
|
+
returnFieldsByFieldId: booleanValue(input.returnFieldsByFieldId)
|
|
374
366
|
})
|
|
375
367
|
}),
|
|
376
368
|
"airtable update records response"
|
|
@@ -1,17 +1,18 @@
|
|
|
1
|
+
import {
|
|
2
|
+
createProviderHttpClient
|
|
3
|
+
} from "./chunk-WW2IMPQK.js";
|
|
4
|
+
import "./chunk-JXHMDBAY.js";
|
|
1
5
|
import {
|
|
2
6
|
createProviderPlugin,
|
|
3
7
|
requireApiKey,
|
|
4
8
|
upstreamError
|
|
5
|
-
} from "./chunk-
|
|
6
|
-
import
|
|
7
|
-
guardedFetch
|
|
8
|
-
} from "./chunk-KH663T3A.js";
|
|
9
|
-
import "./chunk-UI4E4T5Q.js";
|
|
9
|
+
} from "./chunk-YASUMV2K.js";
|
|
10
|
+
import "./chunk-U5UHT7CX.js";
|
|
10
11
|
import {
|
|
11
12
|
TBError,
|
|
12
13
|
external_exports
|
|
13
|
-
} from "./chunk-
|
|
14
|
-
import "./chunk-
|
|
14
|
+
} from "./chunk-RVWZN3CI.js";
|
|
15
|
+
import "./chunk-U67V476Y.js";
|
|
15
16
|
|
|
16
17
|
// ../plugins/src/alt_text_generator_ai/schema.ts
|
|
17
18
|
var generateAltTextInput = external_exports.strictObject({
|
|
@@ -31,7 +32,11 @@ var altTextGeneratorAiActions = {
|
|
|
31
32
|
|
|
32
33
|
// ../plugins/src/alt_text_generator_ai/api.ts
|
|
33
34
|
var SERVICE = "alt_text_generator_ai";
|
|
34
|
-
var
|
|
35
|
+
var http = createProviderHttpClient({
|
|
36
|
+
baseUrl: "https://alttextgeneratorai.com/",
|
|
37
|
+
crossOriginRedirect: "error",
|
|
38
|
+
service: SERVICE
|
|
39
|
+
});
|
|
35
40
|
function unwrapText(body) {
|
|
36
41
|
const trimmed = body.trim();
|
|
37
42
|
if (trimmed === "") return void 0;
|
|
@@ -43,16 +48,20 @@ function unwrapText(body) {
|
|
|
43
48
|
return trimmed;
|
|
44
49
|
}
|
|
45
50
|
async function generateAltText(input, ctx) {
|
|
46
|
-
const
|
|
51
|
+
const apiKey = requireApiKey(ctx, SERVICE);
|
|
52
|
+
const { data } = await http.request({
|
|
53
|
+
path: "api/wp",
|
|
47
54
|
method: "POST",
|
|
48
|
-
headers: {
|
|
49
|
-
|
|
55
|
+
headers: { accept: "text/plain" },
|
|
56
|
+
json: { image: input.imageUrl ?? "", wpkey: apiKey },
|
|
57
|
+
responseType: "text",
|
|
58
|
+
sensitiveValues: [apiKey],
|
|
59
|
+
mapError: ({ data: body, status }) => upstreamError(
|
|
60
|
+
status,
|
|
61
|
+
typeof body === "string" && body.trim() !== "" ? body.trim() : `Alt Text Generator AI \u8FD4\u56DE HTTP ${status}`
|
|
62
|
+
)
|
|
50
63
|
});
|
|
51
|
-
const
|
|
52
|
-
if (!response.ok) {
|
|
53
|
-
throw upstreamError(response.status, body.trim() || `Alt Text Generator AI \u8FD4\u56DE HTTP ${response.status}`);
|
|
54
|
-
}
|
|
55
|
-
const altText = unwrapText(body);
|
|
64
|
+
const altText = unwrapText(data ?? "");
|
|
56
65
|
if (altText === void 0) {
|
|
57
66
|
throw new TBError("unavailable", "Alt Text Generator AI \u8FD4\u56DE\u4E86\u7A7A\u7ED3\u679C", { retryable: true });
|
|
58
67
|
}
|